blob: 30488f7dcfdc2cdfd9875a655b0d728d486ff02a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)
|