コード例 #1
0
 def test_current(self):
     _input = '# test\n'
     buffer = cga.Buffer(_input)
     for _ in _input:
         expect = buffer.next()
         self.assertEqual(expect, buffer.current())
         expect = 'ff'
         self.assertNotEqual(expect, buffer.current())
コード例 #2
0
 def test_ll_text_line(self):
     buffer = cga.Buffer('## this is h2\n')
     act = ds.ll_text_line(buffer)
     expect = {
         'matched': True,
         'token': 'text_line',
         'sign': '## this is h2',
         'remain': ''
     }
     self.assertDictEqual(expect, act)
コード例 #3
0
    def test_seeks(self):
        _input = '012345\n'
        buffer = cga.Buffer(_input)
        for i in range(3):
            buffer.next()

        self.assertEqual('01', buffer.seeks(-2))
        self.assertEqual('2', buffer.seeks(0))
        self.assertEqual('34', buffer.seeks(2))
        self.assertEqual('345\n', buffer.seeks(4))
コード例 #4
0
 def test_ll_title_normal(self):
     buffer = cga.Buffer('## this is h2\n')
     act = ds.ll_title(buffer)
     self.assertEqual(4, len(act))
     expect = {
         'matched': True,
         'token': 'h2',
         'sign': '##',
         'remain': 'this is h2\n'
     }
     self.assertDictEqual(expect, act)
コード例 #5
0
 def test_seek(self):
     _input = '012345\n'
     buffer = cga.Buffer(_input)
     for i in range(3):
         buffer.next()
     self.assertEqual('2', buffer.seek(0))
     self.assertEqual('0', buffer.seek(-2))
     self.assertEqual('\n', buffer.seek(4))
     self.assertEqual('4', buffer.seek(2))
     self.assertEqual(buffer.current(), buffer.seek(0))
     self.assertEqual(buffer.seek(1), buffer.next())
     self.assertEqual(buffer.next(), buffer.seek(0))
コード例 #6
0
 def test_lexer(self):
     buffer = cga.Buffer('# this is h1\n')
     act = ds.lexer(buffer)
     expect = [{'h1': '#'}, {'text_line': 'this is h1'}]
     self.assertListEqual(expect, act)
コード例 #7
0
 def test_ll_title_exception(self):
     buffer = cga.Buffer(' ## this is h2\n')
     act = ds.ll_title(buffer)
     expect = {'matched': False, 'remain': ' ## this is h2\n'}
     self.assertEqual(2, len(act))
     self.assertDictEqual(expect, act)
コード例 #8
0
 def test_next(self):
     _input = '# test\n'
     buffer = cga.Buffer(_input)
     for i in _input:
         self.assertEqual(i, buffer.next())