Python源码示例:pygments.util.unirange()

示例1
def test_unirange():
    first_non_bmp = u'\U00010000'
    r = re.compile(util.unirange(0x10000, 0x20000))
    m = r.match(first_non_bmp)
    assert m
    assert m.end() == len(first_non_bmp)
    assert not r.match(u'\uffff')
    assert not 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)
    assert m
    assert m.end() == len(first_non_bmp) * 2