Exemplo n.º 1
0
def test_filter_tree():
    tree = charstree.ascii_tree()
    new_tree = charstree.filter_tree(tree,
                                     min_codepoint=ord('0'),
                                     max_codepoint=ord('9'))
    expected = list(range(ord('0'), ord('9') + 1))
    actual = list(charstree.codepoints(new_tree))
    assert expected == actual
Exemplo n.º 2
0
    def try_ascii(self, random, template):
        tree = self.ascii_tree

        if not tree:
            return

        zero_point = self.zero_point
        template = ord(template)

        if template < zero_point:
            min_codepoint, max_codepoint = template, zero_point
        elif template > zero_point:
            min_codepoint, max_codepoint = zero_point, template
        else:
            return

        subtree = charstree.filter_tree(tree, min_codepoint=min_codepoint, max_codepoint=max_codepoint)

        for codepoint in charstree.codepoints(subtree):
            yield hunichr(codepoint)
    def try_ascii(self, random, template):
        tree = self.ascii_tree

        if not tree:
            return

        zero_point = self.zero_point
        template = ord(template)

        if template < zero_point:
            min_codepoint, max_codepoint = template, zero_point
        elif template > zero_point:
            min_codepoint, max_codepoint = zero_point, template
        else:
            return

        subtree = charstree.filter_tree(tree,
                                        min_codepoint=min_codepoint,
                                        max_codepoint=max_codepoint)

        for codepoint in charstree.codepoints(subtree):
            yield hunichr(codepoint)
Exemplo n.º 4
0
def test_unicode_tree_codepoints():
    tree = charstree.unicode_tree()
    expected = list(range(0, sys.maxunicode + 1))
    actual = sorted(list(charstree.codepoints(tree)))
    assert expected == actual
Exemplo n.º 5
0
def test_ascii_tree_codepoints():
    tree = charstree.ascii_tree()
    expected = list(range(0, 128))
    actual = sorted(list(charstree.codepoints(tree)))
    assert expected == actual