Ejemplo n.º 1
0
def test_no_overlap():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_above_exclusive(part.b)
        y = u.get_rand_int_above_exclusive(x)
        other = RangePart(x, y)
        diff = [part, other] if part < other else [other, part]
        assert part - other == other - part == diff
Ejemplo n.º 2
0
def test_no_overlap():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_above_exclusive(part.b)
        y = u.get_rand_int_above_exclusive(x)
        other = RangePart(x, y)
        assert not other.right_overlap_with(
            part) and not other.left_overlap_with(part)
        assert other > part and part < other and part != other
Ejemplo n.º 3
0
def test_add_same_left_bound():
    for _ in range(1000):
        part = u.get_rand_range_part()
        y = u.get_rand_int_above_exclusive(part.a)
        other = RangePart(part.a, y)
        sum_b = max(part.b, other.b)
        assert other + part == part + other == RangePart(
            part.a, sum_b) == RangePart(other.a, sum_b)
Ejemplo n.º 4
0
def test_super_sub_range_exclusive():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_below_exclusive(part.a)
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(x, y)
        assert other.is_super_range(part) and part.is_sub_range(other)
        assert other > part and part < other and part != other
Ejemplo n.º 5
0
def test_right_overlap_in_range():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_in_range(part.a, part.b)
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(x, y)
        assert part.a < other.a < part.b < other.b
        assert part.right_overlap_with(other) and other.left_overlap_with(part)
Ejemplo n.º 6
0
def test_right_overlap_on_bounds():
    for _ in range(1000):
        part = u.get_rand_range_part()
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(part.b, y)
        diff = [part, other]
        assert part.right_overlap_with(other)
        assert part.a < other.a == part.b < other.b
        assert part - other == other - part == diff
Ejemplo n.º 7
0
def test_right_overlap_in_bounds():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_in_range_exclusive(part.a, part.b)
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(x, y)
        diff = [RangePart(part.a, other.a), RangePart(part.b, other.b)]
        assert part.right_overlap_with(other)
        assert part.a < other.a < part.b < other.b
        assert part - other == other - part == diff
Ejemplo n.º 8
0
def test_super_sub_range():
    for _ in range(1000):
        part = u.get_rand_range_part()
        x = u.get_rand_int_below_exclusive(part.a)
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(x, y)
        diff = [RangePart(other.a, part.a), RangePart(part.b, other.b)]
        assert other.a < part.a < part.b < other.b
        assert other.is_super_range(part)
        assert part.is_sub_range(other)
        assert part - other == other - part == diff
Ejemplo n.º 9
0
def test_same_left_bound_right_bound_out_range():
    for _ in range(1000):
        part = u.get_rand_range_part()
        y = u.get_rand_int_above_exclusive(part.b)
        other = RangePart(part.a, y)
        assert other > part and part < other and other != part
Ejemplo n.º 10
0
def test_above_range():
    for _ in range(1000):
        part = u.get_rand_range_part()
        item = u.get_rand_int_above_exclusive(part.b)
        assert item not in part