コード例 #1
0
def test_split2():
    a = index.Span(1, 6)
    b = index.Span(2, 5)
    (x, y, z) = index.Span.split(a, b)
    assert x == index.Span(1, 2)
    assert y == index.Span(2, 5)
    assert z == index.Span(5, 6)
コード例 #2
0
def test_add():
    a = index.Span(1, 3)
    b = index.Span(2, 5)
    c = index.Span(3, 5)
    assert a + b == index.Span(1, 5)
    with pytest.raises(ValueError):
        a + c
コード例 #3
0
def test_split1():
    a = index.Span(1, 3)
    b = index.Span(2, 5)
    (x, y, z) = index.Span.split(a, b)
    assert x == index.Span(1, 2)
    assert y == index.Span(2, 3)
    assert z == index.Span(3, 5)
コード例 #4
0
def test_contains():
    bt = BPlusTree(20)
    key_a = index.Span(1, 6)
    key_b = index.Span(6, 10)
    bt.insert(key_a, "a_value")
    bt.insert(key_b, "b_value")
    assert key_a in bt
    assert key_b in bt
    assert bt[key_a] == "a_value"
    assert bt[key_b] == "b_value"
コード例 #5
0
def test_split():
    bt = BPlusTree(20)
    key_a = index.Span(1, 6)
    key_b = index.Span(3, 10)
    key_a_prime = index.Span(1, 3)
    bt.insert(key_a, "a_value")
    bt.insert(key_b, "b_value")
    assert not (key_a in bt)
    assert key_a_prime in bt
    assert key_b in bt
    assert bt[key_a_prime] == "a_value"
    assert bt[key_b] == "b_value"
コード例 #6
0
def test_additions_sorted():
    bt = BPlusTree(20)
    rl = [index.Span(a, a + 5) for a in range(0, 100, 5)]

    for item in rl:
        bt.insert(item, str(item))

    for item in rl:
        assert str(item) == bt[item]

    assert rl == list(bt)
コード例 #7
0
def test_mul():
    a = index.Span(1, 3)
    b = index.Span(2, 5)
    assert a * b == index.Span(2, 3)
    c = index.Span(3, 5)
    assert a * c == index.Span(3, 3)
コード例 #8
0
def test_contains2():
    a = index.Span(1, 10)
    b = index.Span(1, 10)
    assert a in b
    assert b in a
コード例 #9
0
def test_gt():
    a = index.Span(1, 10)
    b = index.Span(11, 15)
    assert b > a
    assert not a > b
    assert not a > a
コード例 #10
0
def test_le2():
    a = index.Span(1, 10)
    assert a <= a
コード例 #11
0
def test_le():
    a = index.Span(1, 10)
    b = index.Span(2, 12)
    assert a <= b
    assert not b <= a
コード例 #12
0
def test_equals():
    a = index.Span(1, 2)
    b = index.Span(1, 2)
    assert a == b
コード例 #13
0
def test_ge2():
    a = index.Span(1, 10)
    assert a >= a
コード例 #14
0
def test_ge():
    a = index.Span(1, 10)
    b = index.Span(2, 12)
    assert b >= a
    assert not a >= b
コード例 #15
0
def test_contains3():
    a = index.Span(1, 10)
    b = index.Span(2, 12)
    assert not a in b
    assert not b in a
コード例 #16
0
def test_lt():
    a = index.Span(1, 10)
    b = index.Span(11, 15)
    assert a < b
    assert not b < a
    assert not a < a
コード例 #17
0
def test_additions():
    bt = BTree(20)
    rl = [index.Span(a, a + 5) for a in range(0, 100, 5)]
    for i, r in enumerate(rl):
        bt.insert(r)
        assert list(bt) == rl[:i + 1]
コード例 #18
0
def test_contains1():
    a = index.Span(1, 10)
    b = index.Span(2, 6)
    assert b in a
    assert not (a in b)