Ejemplo n.º 1
0
 void doTestComparisons(MinguoDate... dates) {
   for (int i = 0; i < dates.length; i++) {
     MinguoDate a = dates[i];
     for (int j = 0; j < dates.length; j++) {
       MinguoDate b = dates[j];
       if (i < j) {
         assertTrue(a.compareTo(b) < 0, a + " <=> " + b);
         assertEquals(a.isBefore(b), true, a + " <=> " + b);
         assertEquals(a.isAfter(b), false, a + " <=> " + b);
         assertEquals(a.equals(b), false, a + " <=> " + b);
       } else if (i > j) {
         assertTrue(a.compareTo(b) > 0, a + " <=> " + b);
         assertEquals(a.isBefore(b), false, a + " <=> " + b);
         assertEquals(a.isAfter(b), true, a + " <=> " + b);
         assertEquals(a.equals(b), false, a + " <=> " + b);
       } else {
         assertEquals(a.compareTo(b), 0, a + " <=> " + b);
         assertEquals(a.isBefore(b), false, a + " <=> " + b);
         assertEquals(a.isAfter(b), false, a + " <=> " + b);
         assertEquals(a.equals(b), true, a + " <=> " + b);
       }
     }
   }
 }
Ejemplo n.º 2
0
 @Test(expectedExceptions = NullPointerException.class)
 public void testCompareToObjectNull() throws Exception {
   testDate.compareTo(null);
 }