Пример #1
0
 public void testIsLessThan() {
   assertEquals(false, Minutes.THREE.isLessThan(Minutes.TWO));
   assertEquals(false, Minutes.THREE.isLessThan(Minutes.THREE));
   assertEquals(true, Minutes.TWO.isLessThan(Minutes.THREE));
   assertEquals(false, Minutes.ONE.isLessThan(null));
   assertEquals(true, Minutes.minutes(-1).isLessThan(null));
 }
Пример #2
0
 // -----------------------------------------------------------------------
 public void testConstants() {
   assertEquals(0, Minutes.ZERO.getMinutes());
   assertEquals(1, Minutes.ONE.getMinutes());
   assertEquals(2, Minutes.TWO.getMinutes());
   assertEquals(3, Minutes.THREE.getMinutes());
   assertEquals(Integer.MAX_VALUE, Minutes.MAX_VALUE.getMinutes());
   assertEquals(Integer.MIN_VALUE, Minutes.MIN_VALUE.getMinutes());
 }
Пример #3
0
  public void testMinus_Minutes() {
    Minutes test2 = Minutes.minutes(2);
    Minutes test3 = Minutes.minutes(3);
    Minutes result = test2.minus(test3);
    assertEquals(2, test2.getMinutes());
    assertEquals(3, test3.getMinutes());
    assertEquals(-1, result.getMinutes());

    assertEquals(1, Minutes.ONE.minus(Minutes.ZERO).getMinutes());
    assertEquals(1, Minutes.ONE.minus((Minutes) null).getMinutes());

    try {
      Minutes.MIN_VALUE.minus(Minutes.ONE);
      fail();
    } catch (ArithmeticException ex) {
      // expected
    }
  }
Пример #4
0
  public void testMinus_int() {
    Minutes test2 = Minutes.minutes(2);
    Minutes result = test2.minus(3);
    assertEquals(2, test2.getMinutes());
    assertEquals(-1, result.getMinutes());

    assertEquals(1, Minutes.ONE.minus(0).getMinutes());

    try {
      Minutes.MIN_VALUE.minus(1);
      fail();
    } catch (ArithmeticException ex) {
      // expected
    }
  }
Пример #5
0
  public void testDividedBy_int() {
    Minutes test = Minutes.minutes(12);
    assertEquals(6, test.dividedBy(2).getMinutes());
    assertEquals(12, test.getMinutes());
    assertEquals(4, test.dividedBy(3).getMinutes());
    assertEquals(3, test.dividedBy(4).getMinutes());
    assertEquals(2, test.dividedBy(5).getMinutes());
    assertEquals(2, test.dividedBy(6).getMinutes());
    assertSame(test, test.dividedBy(1));

    try {
      Minutes.ONE.dividedBy(0);
      fail();
    } catch (ArithmeticException ex) {
      // expected
    }
  }