diff options
Diffstat (limited to 'tests/glibext')
-rw-r--r-- | tests/glibext/buffercache.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/glibext/buffercache.py b/tests/glibext/buffercache.py new file mode 100644 index 0000000..30488f7 --- /dev/null +++ b/tests/glibext/buffercache.py @@ -0,0 +1,49 @@ + +from chrysacase import ChrysalideTestCase +from gi.repository import GObject +from pychrysalide.analysis.contents import MemoryContent +from pychrysalide.glibext import BufferCache +from pychrysalide.glibext import BufferLine +from pychrysalide.glibext import LineGenerator + + +class CommentBuilder(GObject.Object, LineGenerator): + def _count_lines(self): + return 1 + def _get_flags(self, index, repeat): + return BufferLine.BufferLineFlags.NONE + def _print(self, line, index, repeat, content): + line.append_text(0, '# Comment', BufferLine.RenderingTagType.PRINTABLE) + + +class TestBufferCache(ChrysalideTestCase): + """TestCase for glibext.BufferCache*""" + + def testCacheConstructor(self): + """Build all possible kinds of buffer caches.""" + + cache = BufferCache() + self.assertIsNotNone(cache) + self.assertIsNone(cache.content) + + cache = BufferCache(None) + self.assertIsNotNone(cache) + self.assertIsNone(cache.content) + + cnt = MemoryContent(b'\x00' * 8) + + cache = BufferCache(cnt) + self.assertIsNotNone(cache) + self.assertIsNotNone(cache.content) + + + def testCacheRendering(self): + """Check a buffer cache simple content.""" + + cache = BufferCache() + + cache.append(CommentBuilder(), BufferLine.BufferLineFlags.NONE) + + cache.append(CommentBuilder()) + + self.assertEqual(2, cache.lines_count) |