/** Test of lessThan method, of class Range. */
 @Test
 public void testLessThan() {
   System.out.println("lessThan");
   Range r = new Range(5, 12);
   Range instance = new Range(13, 18);
   boolean expResult = false;
   boolean result = instance.lessThan(r);
   assertEquals(expResult, result);
 }
 /** Test of classify method, of class Range. */
 @Test
 public void testClassify() {
   System.out.println("classify");
   Range r = new Range(1, 10);
   Range instance = new Range(2, 5);
   Range.Relation expResult = Range.Relation.SUPERSET;
   Range.Relation result = r.classify(instance);
   assertEquals(expResult, result);
 }
 /** Test of isOverlapping method, of class Range. */
 @Test
 public void testIsOverlapping() {
   System.out.println("isOverlapping");
   Range r = new Range(2, 12);
   Range instance = new Range(1, 5);
   boolean expResult = true;
   boolean result = instance.isOverlapping(r);
   assertEquals(expResult, result);
 }
 /** Test of isDisjoint method, of class Range. */
 @Test
 public void testIsDisjoint() {
   System.out.println("isDisjoint");
   Range r = new Range(5, 15);
   Range instance = new Range(1, 4);
   boolean expResult = true;
   boolean result = instance.isDisjoint(r);
   assertEquals(expResult, result);
 }
 /** Test of equals method, of class Range. */
 @Test
 public void testEquals() {
   System.out.println("equals");
   Range r = new Range(3, 5);
   Range instance = new Range(3, 5);
   boolean expResult = true;
   boolean result = instance.equals(r);
   assertEquals(expResult, result);
 }
 /** Test of contains method, of class Range. */
 @Test
 public void testContains_Range() {
   System.out.println("contains");
   Range r = new Range(3, 6);
   Range instance = new Range(4, 5);
   boolean expResult = false;
   boolean result = instance.contains(r);
   assertEquals(expResult, result);
 }
 /** Test of contains method, of class Range. */
 @Test
 public void testContains_int() {
   System.out.println("contains");
   int x = 5;
   Range instance = new Range(4, 10);
   boolean expResult = true;
   boolean result = instance.contains(x);
   assertEquals(expResult, result);
 }
  @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());
  }
  @Test
  public void whenCreateRangeOfIntegersSet_thenCreated() {
    final int start = 10;
    final int end = 30;
    final ContiguousSet<Integer> set =
        ContiguousSet.create(Range.closed(start, end), DiscreteDomain.integers());

    assertEquals(21, set.size());
    assertEquals(10, set.first().intValue());
    assertEquals(30, set.last().intValue());
  }
Esempio n. 10
0
  @Test
  public void testGetPreviousReturnsValidRange() throws Exception {
    Range _r = new Range(10, 10);
    Range _r2 = _r.previous();
    assertEquals(0, _r2.getStart());
    assertEquals(9, _r2.getEnd());
    assertEquals(10, _r2.getBatchSize());
    assertEquals(10, _r2.getSize());

    _r = new Range(0, 10, 14);
    _r2 = _r.previous();
    assertEquals(_r, _r2);

    _r = new Range(3, 10, 14);
    _r2 = _r.previous();
    assertEquals(0, _r2.getStart());
    assertEquals(9, _r2.getEnd());
    assertEquals(10, _r2.getBatchSize());
    assertEquals(10, _r2.getSize());
  }
Esempio n. 11
0
  @Test
  public void testGetNextReturnsValidRange() throws Exception {
    Range _r = new Range(0, 10);
    Range _r2 = _r.next();
    assertEquals(10, _r2.getStart());
    assertEquals(19, _r2.getEnd());
    assertEquals(10, _r2.getBatchSize());
    assertEquals(10, _r2.getSize());

    _r = new Range(0, 10, 14);
    _r2 = _r.next();
    assertEquals(10, _r2.getStart());
    assertEquals(14, _r2.getEnd());
    assertEquals(10, _r2.getBatchSize());
    assertEquals(4, _r2.getSize());
  }
Esempio n. 12
0
  @Test
  public void testSimpleCases() throws Exception {
    Range _r = new Range(0, 10);
    assertEquals(0, _r.getStart());
    assertEquals(9, _r.getEnd());
    assertEquals(10, _r.getBatchSize());
    assertEquals(10, _r.getSize());
    assertEquals(Integer.MAX_VALUE, _r.getTotal());
    assertTrue(_r.hasNext());
    assertFalse(_r.hasPrevious());
    assertEquals("1 to 10 of " + Integer.MAX_VALUE, _r.toString());

    _r = new Range(10, 10);
    assertEquals(10, _r.getStart());
    assertEquals(19, _r.getEnd());
    assertEquals(10, _r.getBatchSize());
    assertEquals(10, _r.getSize());
    assertEquals(Integer.MAX_VALUE, _r.getTotal());
    assertTrue(_r.hasNext());
    assertTrue(_r.hasPrevious());
    assertEquals("11 to 20 of " + Integer.MAX_VALUE, _r.toString());

    _r = new Range(0, 10, 34);
    assertEquals(0, _r.getStart());
    assertEquals(9, _r.getEnd());
    assertEquals(10, _r.getBatchSize());
    assertEquals(10, _r.getSize());
    assertEquals(34, _r.getTotal());
    assertTrue(_r.hasNext());
    assertFalse(_r.hasPrevious());
    assertEquals("1 to 10 of 34", _r.toString());

    _r = new Range(10, 10, 34);
    assertEquals(10, _r.getStart());
    assertEquals(19, _r.getEnd());
    assertEquals(10, _r.getBatchSize());
    assertEquals(10, _r.getSize());
    assertEquals(34, _r.getTotal());
    assertTrue(_r.hasNext());
    assertTrue(_r.hasPrevious());
    assertEquals("11 to 20 of 34", _r.toString());

    _r = new Range(10, 10, 16);
    assertEquals(10, _r.getStart());
    assertEquals(16, _r.getEnd());
    assertEquals(10, _r.getBatchSize());
    assertEquals(6, _r.getSize());
    assertEquals(16, _r.getTotal());
    assertFalse(_r.hasNext());
    assertTrue(_r.hasPrevious());
    assertEquals("11 to 16 of 16", _r.toString());
  }
Esempio n. 13
0
  @Test
  public void testAlwaysMakesAValidRange() throws Exception {
    Range _r = new Range(-20, -6);
    assertEquals(0, _r.getStart());
    assertEquals(0, _r.getEnd());
    assertEquals(1, _r.getBatchSize());
    assertEquals(0, _r.getSize());
    assertTrue(_r.hasNext());
    assertFalse(_r.hasPrevious());
    assertEquals(_r, _r.previous());

    _r = new Range(-3, -3, -3);
    assertEquals(0, _r.getStart());
    assertEquals(0, _r.getEnd());
    assertEquals(1, _r.getBatchSize());
    assertEquals(0, _r.getSize());
    assertFalse(_r.hasNext());
    assertFalse(_r.hasPrevious());
    assertEquals(_r, _r.next());
    assertEquals(_r, _r.previous());
  }