@Test
  public void andnottest4A() {
    final MutableRoaringBitmap rb = new MutableRoaringBitmap();
    final MutableRoaringBitmap rb2 = new MutableRoaringBitmap();

    for (int i = 0; i < 200000; i++) {
      if (i % 9 < 6) {
        rb2.add(i);
      }
    }
    for (int i = 200000; i < 400000; i += 14) {
      rb2.add(i);
    }
    rb2.getCardinality();
    rb2.runOptimize();

    // check against an empty bitmap
    final MutableRoaringBitmap andNotresult = MutableRoaringBitmap.andNot(rb, rb2);
    final MutableRoaringBitmap off = MutableRoaringBitmap.andNot(rb2, rb);

    Assert.assertEquals(rb, andNotresult);
    Assert.assertEquals(rb2, off);
    rb2.andNot(rb);
    Assert.assertEquals(rb2, off);
  }
  @Test
  public void ANDNOTtestA() {
    // both have run containers
    final MutableRoaringBitmap rr = new MutableRoaringBitmap();
    for (int k = 4000; k < 4256; ++k) {
      rr.add(k);
    }
    for (int k = 65536; k < 65536 + 4000; ++k) {
      rr.add(k);
    }
    for (int k = 3 * 65536; k < 3 * 65536 + 9000; ++k) {
      rr.add(k);
    }
    for (int k = 4 * 65535; k < 4 * 65535 + 7000; ++k) {
      rr.add(k);
    }
    for (int k = 6 * 65535; k < 6 * 65535 + 10000; ++k) {
      rr.add(k);
    }
    for (int k = 8 * 65535; k < 8 * 65535 + 1000; ++k) {
      rr.add(k);
    }
    for (int k = 9 * 65535; k < 9 * 65535 + 30000; ++k) {
      rr.add(k);
    }

    rr.runOptimize();

    final MutableRoaringBitmap rr2 = new MutableRoaringBitmap();
    for (int k = 4000; k < 4256; ++k) {
      rr2.add(k);
    }
    for (int k = 65536; k < 65536 + 4000; ++k) {
      rr2.add(k);
    }
    for (int k = 3 * 65536 + 2000; k < 3 * 65536 + 6000; ++k) {
      rr2.add(k);
    }
    for (int k = 6 * 65535; k < 6 * 65535 + 1000; ++k) {
      rr2.add(k);
    }
    for (int k = 7 * 65535; k < 7 * 65535 + 1000; ++k) {
      rr2.add(k);
    }
    for (int k = 10 * 65535; k < 10 * 65535 + 5000; ++k) {
      rr2.add(k);
    }
    rr2.runOptimize();
    final MutableRoaringBitmap correct = MutableRoaringBitmap.andNot(rr, rr2);
    rr.andNot(rr2);
    Assert.assertTrue(correct.equals(rr));
    Assert.assertTrue(correct.hashCode() == rr.hashCode());
  }