def test_sequentially_removing_intervals_yields_empty(ls): running = IntSet.from_intervals(ls) for i in ls: inter = IntSet.interval(*i) extra = inter & running original = running.size() assert (running - inter) == (running - extra) running -= inter assert running.size() == original - extra.size() assert running.size() == 0
def test_unioning_a_value_in_includes_it(intervals, i): mp = IntSet.from_intervals(intervals) assume(i not in mp) mp2 = mp | IntSet.interval(i, i + 1) assert i in mp2
imper = imp.insert(i) assert imp.issubset(imper) @example(IntSet.empty(), IntSet.empty()) @example(IntSet.single(0), IntSet.from_iterable([0, 2])) @given(IntSets, IntSets) def test_subtracting_a_superset_is_empty(x, y): assume(x.issubset(y)) assert (x - y).size() == 0 @example( IntSet.interval(4611686018427387904, 4611686018427387907), IntSet.from_intervals([ (0, 4611686018427387904), (4611686018427387904, 4611686018427387905), (4611686018427387906, 4611686018427387907)])) @example(IntSet.single(0), IntSet.empty()) @example(IntSet.interval(0, 2), IntSet.from_iterable([0, 2])) @example(IntSet.interval(0, 3), IntSet.from_iterable([0, 2])) @example(IntSet.single(0), IntSet.from_iterable([1, 3])) @example(IntSet.interval(0, 3), IntSet.from_iterable([0, 2, 3, 4])) @example(IntSet.interval(0, 5), IntSet.from_iterable([0, 2])) @example(IntSet.single(1), IntSet.from_iterable([0, 2])) @example(IntSet.single(3), IntSet.from_iterable([0, 2])) @given(IntSets, IntSets) def test_subtracting_a_non_superset_is_non_empty(x, y): assume(not x.issubset(y)) assert (x - y).size() > 0
def test_concatenation_of_lists_is_union(x, y): assert IntSet.from_intervals(x + y) == \ IntSet.from_intervals(x) | IntSet.from_intervals(y)
def test_iterable_equivalent_to_intervals_of_length_one(xs): assert IntSet.from_iterable(xs) == \ IntSet.from_intervals((x, x + 1) for x in xs)
def test_concatenation_of_lists_is_union(x, y): assert IntSet.from_intervals(x + y) == \ IntSet.from_intervals(x) | IntSet.from_intervals(y)
def test_iterable_equivalent_to_intervals_of_length_one(xs): assert IntSet.from_iterable(xs) == \ IntSet.from_intervals((x, x + 1) for x in xs)