diff options
author | Tim Hatch <tim@timhatch.com> | 2012-08-26 23:45:56 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2012-08-26 23:45:56 -0700 |
commit | cce195e4b0beda79fc2037b3c323255195f498a3 (patch) | |
tree | 9844976a097073fe7b04c6640c0bbe39e012799d /tests/test_util.py | |
parent | bff97c8b026c9dad45751be77a2191d82f4862fc (diff) | |
download | pygments-cce195e4b0beda79fc2037b3c323255195f498a3.tar.gz |
Handle non-BMP Unicode ranges consistently, regardless of Python build.
Diffstat (limited to 'tests/test_util.py')
-rw-r--r-- | tests/test_util.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_util.py b/tests/test_util.py index 6b931eb2..be1662f9 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -7,6 +7,7 @@ :license: BSD, see LICENSE for details. """ +import re import unittest from pygments import util @@ -114,3 +115,20 @@ class UtilTest(unittest.TestCase): '<?xml ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">')) self.assertTrue(util.looks_like_xml('<html xmlns>abc</html>')) self.assertFalse(util.looks_like_xml('<html>')) + + def test_unirange(self): + first_non_bmp = u'\U00010000' + r = re.compile(util.unirange(0x10000, 0x20000)) + m = r.match(first_non_bmp) + self.assertTrue(m) + self.assertEquals(m.end(), len(first_non_bmp)) + self.assertFalse(r.match(u'\uffff')) + self.assertFalse(r.match(u'xxx')) + # Tests that end is inclusive + r = re.compile(util.unirange(0x10000, 0x10000) + '+') + # Tests that the plus works for the entire unicode point, if narrow + # build + m = r.match(first_non_bmp * 2) + self.assertTrue(m) + self.assertEquals(m.end(), len(first_non_bmp) * 2) + |