diff options
Diffstat (limited to 'tests/test_clexer.py')
-rw-r--r-- | tests/test_clexer.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_clexer.py b/tests/test_clexer.py new file mode 100644 index 00000000..145c6510 --- /dev/null +++ b/tests/test_clexer.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +""" + Basic CLexer Test + ~~~~~~~~~~~~~~~~~ + + :copyright: 2006 by Armin Ronacher. + :license: GNU GPL, see LICENSE for more details. +""" + +import unittest +import os + +from pygments.token import Text, Number +from pygments.lexers import CLexer + + +class CLexerTest(unittest.TestCase): + + def setUp(self): + self.lexer = CLexer() + + def testNumbers(self): + code = '42 23.42 23. .42 023 0xdeadbeef 23e+42 42e-23' + wanted = [] + for item in zip([Number.Integer, Number.Float, Number.Float, + Number.Float, Number.Oct, Number.Hex, + Number.Float, Number.Float], code.split()): + wanted.append(item) + wanted.append((Text, ' ')) + wanted = [(Text, '')] + wanted[:-1] + [(Text, '\n')] + self.assertEqual(list(self.lexer.get_tokens(code)), wanted) + + +if __name__ == '__main__': + unittest.main(CLexerTest) |