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