test/java/time/test/java/time/TestDuration.java

Print this page




 201 
 202     @Test(groups={"implementation"})
 203     public void minusNanos_zeroSingleton() {
 204         Duration t = Duration.ofSeconds(1, 2000000);
 205         assertSame(t.minusNanos(1002000000), Duration.ZERO);
 206     }
 207 
 208     @Test(groups={"implementation"})
 209     public void test_abs_same() {
 210         Duration base = Duration.ofSeconds(12);
 211         assertSame(base.abs(), base);
 212     }
 213 
 214     void doTest_comparisons_Duration(Duration... durations) {
 215         for (int i = 0; i < durations.length; i++) {
 216             Duration a = durations[i];
 217             for (int j = 0; j < durations.length; j++) {
 218                 Duration b = durations[j];
 219                 if (i < j) {
 220                     assertEquals(a.compareTo(b)< 0, true, a + " <=> " + b);
 221                     assertEquals(a.isLessThan(b), true, a + " <=> " + b);
 222                     assertEquals(a.isGreaterThan(b), false, a + " <=> " + b);
 223                     assertEquals(a.equals(b), false, a + " <=> " + b);
 224                 } else if (i > j) {
 225                     assertEquals(a.compareTo(b) > 0, true, a + " <=> " + b);
 226                     assertEquals(a.isLessThan(b), false, a + " <=> " + b);
 227                     assertEquals(a.isGreaterThan(b), true, a + " <=> " + b);
 228                     assertEquals(a.equals(b), false, a + " <=> " + b);
 229                 } else {
 230                     assertEquals(a.compareTo(b), 0, a + " <=> " + b);
 231                     assertEquals(a.isLessThan(b), false, a + " <=> " + b);
 232                     assertEquals(a.isGreaterThan(b), false, a + " <=> " + b);
 233                     assertEquals(a.equals(b), true, a + " <=> " + b);
 234                 }
 235             }
 236         }
 237     }
 238 
 239 }


 201 
 202     @Test(groups={"implementation"})
 203     public void minusNanos_zeroSingleton() {
 204         Duration t = Duration.ofSeconds(1, 2000000);
 205         assertSame(t.minusNanos(1002000000), Duration.ZERO);
 206     }
 207 
 208     @Test(groups={"implementation"})
 209     public void test_abs_same() {
 210         Duration base = Duration.ofSeconds(12);
 211         assertSame(base.abs(), base);
 212     }
 213 
 214     void doTest_comparisons_Duration(Duration... durations) {
 215         for (int i = 0; i < durations.length; i++) {
 216             Duration a = durations[i];
 217             for (int j = 0; j < durations.length; j++) {
 218                 Duration b = durations[j];
 219                 if (i < j) {
 220                     assertEquals(a.compareTo(b)< 0, true, a + " <=> " + b);


 221                     assertEquals(a.equals(b), false, a + " <=> " + b);
 222                 } else if (i > j) {
 223                     assertEquals(a.compareTo(b) > 0, true, a + " <=> " + b);


 224                     assertEquals(a.equals(b), false, a + " <=> " + b);
 225                 } else {
 226                     assertEquals(a.compareTo(b), 0, a + " <=> " + b);


 227                     assertEquals(a.equals(b), true, a + " <=> " + b);
 228                 }
 229             }
 230         }
 231     }
 232 
 233 }