예제 #1
0
    def test_bitmap_union(self, n_xs_ys):
        n, xs, ys = n_xs_ys
        x, y = BitmapRLE.from_indices(n, xs), BitmapRLE.from_indices(n, ys)

        # tests __or__
        z = x | y
        assert (z == BitmapRLE.from_indices(n, xs | ys))

        # tests __ior__
        x |= y
        assert (x == z)
예제 #2
0
    def test_bitmap_intersection(self, n_xs_ys):
        n, xs, ys = n_xs_ys
        x, y = BitmapRLE.from_indices(n, xs), BitmapRLE.from_indices(n, ys)

        # tests __and__
        z = x & y
        assert (z == BitmapRLE.from_indices(n, xs & ys))

        # tests __iand__
        x &= y
        assert (x == z)
예제 #3
0
  def test_bitmap_intersection(self, n_xs_ys):
    n, xs, ys = n_xs_ys
    x, y = BitmapRLE.from_indices(n, xs), BitmapRLE.from_indices(n, ys)

    # tests __and__
    z = x & y
    assert(z == BitmapRLE.from_indices(n, xs & ys))

    # tests __iand__
    x &= y
    assert(x == z)
예제 #4
0
  def test_bitmap_union(self, n_xs_ys):
    n, xs, ys = n_xs_ys
    x, y = BitmapRLE.from_indices(n, xs), BitmapRLE.from_indices(n, ys)

    # tests __or__
    z = x | y
    assert(z == BitmapRLE.from_indices(n, xs | ys))

    # tests __ior__
    x |= y
    assert(x == z)
예제 #5
0
    def test_bitmap_find_first_zero(self, n_xs):
        n, xs = n_xs
        x = BitmapRLE.from_indices(n, xs)

        expected = -1 if x.full() else min(set(range(0, n)) - xs)
        first = x.find_first_zero()
        assert (first == expected)
예제 #6
0
    def test_bitmap_find_first_bit(self, n_xs):
        n, xs = n_xs
        x = BitmapRLE.from_indices(n, xs)

        expected = -1 if x.empty() else min(xs)
        first = x.find_first_bit()
        assert (first == expected)
예제 #7
0
  def test_bitmap_find_first_zero(self, n_xs):
    n, xs = n_xs
    x = BitmapRLE.from_indices(n, xs)

    expected = -1 if x.full() else min(set(range(0, n)) - xs)
    first = x.find_first_zero()
    assert(first == expected)
예제 #8
0
  def test_bitmap_find_first_bit(self, n_xs):
    n, xs = n_xs
    x = BitmapRLE.from_indices(n, xs)

    expected = -1 if x.empty() else min(xs)
    first = x.find_first_bit()
    assert(first == expected)
예제 #9
0
    def test_bitmap_negation(self, n_xs):
        n, xs = n_xs
        x = BitmapRLE.from_indices(n, xs)

        y = -x

        for idx in xs:
            assert (idx not in y)

        assert (x != y)
        assert (x == -y)
예제 #10
0
  def test_bitmap_negation(self, n_xs):
    n, xs = n_xs
    x = BitmapRLE.from_indices(n, xs)

    y = -x

    for idx in xs:
      assert(idx not in y)

    assert(x != y)
    assert(x == -y)