def test_reader(l):
    n = create_numbering(l)
    r = Reader(n)
    for i, elt in enumerate(l):
        assert r.items_read == i
        item = r.next_item()
        assert elt == item
Пример #2
0
def test_pack_unpack():
    examples = [
        [1, 2, 3, 4, 257, 10000, 13, 15],
        [1, 2, 3, 4],
        range(1, 10, 2),
        [13000, 12000, 10000, 256, 255, 254, 257, -3, -1000]
    ]
    for l in examples:
        n = create_numbering(l)
        assert unpack_numbering(n) == l
Пример #3
0
def Numbering(l):
    return create_numbering([len(l)] + l) # prefix index to the end of thing
def test_compressing(l):
    n = create_numbering(l)
    assert len(n.code) <= len(l) * 3
def test_roundtrip(l):
    n = create_numbering(l)
    assert unpack_numbering(n) == l
Пример #6
0
def test_compressing(l):
    n = create_numbering(l)
    assert len(n.code) <= len(l) * 3
Пример #7
0
def test_roundtrip(l):
    n = create_numbering(l)
    assert unpack_numbering(n) == l