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)
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
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)
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"
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"
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)
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)
def test_contains2(): a = index.Span(1, 10) b = index.Span(1, 10) assert a in b assert b in a
def test_gt(): a = index.Span(1, 10) b = index.Span(11, 15) assert b > a assert not a > b assert not a > a
def test_le2(): a = index.Span(1, 10) assert a <= a
def test_le(): a = index.Span(1, 10) b = index.Span(2, 12) assert a <= b assert not b <= a
def test_equals(): a = index.Span(1, 2) b = index.Span(1, 2) assert a == b
def test_ge2(): a = index.Span(1, 10) assert a >= a
def test_ge(): a = index.Span(1, 10) b = index.Span(2, 12) assert b >= a assert not a >= b
def test_contains3(): a = index.Span(1, 10) b = index.Span(2, 12) assert not a in b assert not b in a
def test_lt(): a = index.Span(1, 10) b = index.Span(11, 15) assert a < b assert not b < a assert not a < a
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]
def test_contains1(): a = index.Span(1, 10) b = index.Span(2, 6) assert b in a assert not (a in b)