public void testRemoveAllExtendingBothDirections() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closed(2, 7));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).isEmpty();
 }
 public void testRemoveExact() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closed(3, 6));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).isEmpty();
 }
 public void testRemoveAllFromAboveUpperBound() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closed(3, 7));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).isEmpty();
 }
 public void testRemovePartFromBelowLowerBound() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closed(1, 3));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().allOf(Range.openClosed(3, 6)).inOrder();
 }
 public void testRemovePartFromAboveUpperBound() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closed(6, 9));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().allOf(Range.closedOpen(3, 6)).inOrder();
 }
 public void testRemoveNoOverlap() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 6));
   rangeSet.remove(Range.closedOpen(1, 3));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().allOf(Range.closed(3, 6)).inOrder();
 }
 public void testRemoveMiddle() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.atMost(6));
   rangeSet.remove(Range.closedOpen(3, 4));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().allOf(Range.lessThan(3), Range.closed(4, 6)).inOrder();
   ASSERT
       .that(rangeSet.complement().asRanges())
       .has()
       .allOf(Range.closedOpen(3, 4), Range.greaterThan(6))
       .inOrder();
 }
 public void testRemovePartSharingUpperBound() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(3, 5));
   rangeSet.remove(Range.openClosed(3, 5));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().item(Range.singleton(3));
   ASSERT
       .that(rangeSet.complement().asRanges())
       .has()
       .allOf(Range.lessThan(3), Range.greaterThan(3))
       .inOrder();
 }
 public void testRemoveEmpty() {
   TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
   rangeSet.add(Range.closed(1, 6));
   rangeSet.remove(Range.closedOpen(3, 3));
   testInvariants(rangeSet);
   ASSERT.that(rangeSet.asRanges()).has().item(Range.closed(1, 6));
   ASSERT
       .that(rangeSet.complement().asRanges())
       .has()
       .allOf(Range.lessThan(1), Range.greaterThan(6))
       .inOrder();
 }
  public void testAllSingleRangesComplementAgainstRemove() {
    for (Range<Integer> range : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range);

      TreeRangeSet<Integer> complement = TreeRangeSet.create();
      complement.add(Range.<Integer>all());
      complement.remove(range);

      assertEquals(complement, rangeSet.complement());
      ASSERT.that(rangeSet.complement().asRanges()).has().allFrom(complement.asRanges()).inOrder();
    }
  }