@Test public void whenCreateRangeSet_thenCreated() { final RangeSet<Integer> rangeSet = TreeRangeSet.create(); rangeSet.add(Range.closed(1, 10)); rangeSet.add(Range.closed(12, 15)); assertEquals(2, rangeSet.asRanges().size()); rangeSet.add(Range.closed(10, 12)); assertTrue(rangeSet.encloses(Range.closed(1, 15))); assertEquals(1, rangeSet.asRanges().size()); }
public void testEnclosing(RangeSet<Integer> rangeSet) { for (Range<Integer> query : QUERY_RANGES) { boolean expectEnclose = false; for (Range<Integer> expectedRange : rangeSet.asRanges()) { if (expectedRange.encloses(query)) { expectEnclose = true; break; } } assertEquals( rangeSet + " was incorrect on encloses(" + query + ")", expectEnclose, rangeSet.encloses(query)); } }