Exemple #1
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());
  }
Exemple #2
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());
  }