Exemplo n.º 1
0
 private static void assertDurationFields(
     String label,
     int years,
     int months,
     int days,
     int hours,
     int minutes,
     int seconds,
     int milliseconds,
     String string,
     TimeDuration duration,
     boolean isNegative,
     boolean isZero) {
   assertEquals(label + ".years()", years, duration.years());
   assertEquals(label + ".months()", months, duration.months());
   assertEquals(label + ".days()", days, duration.days());
   assertEquals(label + ".hours()", hours, duration.hours());
   assertEquals(label + ".minutes()", minutes, duration.minutes());
   assertEquals(label + ".seconds()", seconds, duration.seconds());
   assertEquals(label + ".milliseconds()", milliseconds, duration.milliseconds());
   assertEquals(label + ".isNegative()", isNegative, duration.isNegative());
   assertEquals(label + ".toString()", string, duration.toString());
   assertEquals(
       label + ".equals(from/to long)",
       duration,
       TimeDuration.fromLong(TimeDuration.toLong(duration)));
   assertEquals(
       label + ".equals(from/to number)",
       duration,
       TimeDuration.fromNumber(TimeDuration.toLong(duration)));
   assertEquals(label + ".isZero", isZero, duration.isZero());
   if (isZero) {
     assertEquals(
         label + ".compareTo(zero) == 0", 0, doCompare(TimeDuration.ZeroTimeDuration, duration));
     assertEquals(
         label + ".compareTo(zero) == 0", 0, doCompare(duration, TimeDuration.ZeroTimeDuration));
   } else {
     assertNotSame(
         label + ".compareTo(zero) != 0", 0, doCompare(TimeDuration.ZeroTimeDuration, duration));
     assertNotSame(
         label + ".compareTo(zero) != 0", 0, doCompare(duration, TimeDuration.ZeroTimeDuration));
   }
 }