Esempio n. 1
0
 public void test_registerLeapSecond_justAfterLastDate_minusOne() {
   long[] dates = rules.getLeapSecondDates();
   long mjd = dates[dates.length - 1] + 1;
   rules.register(mjd, -1);
   long[] test = rules.getLeapSecondDates();
   assertEquals(test.length, dates.length + 1);
   assertEquals(test[test.length - 1], mjd);
   assertEquals(rules.getLeapSecondAdjustment(mjd), -1);
 }
Esempio n. 2
0
 public void test_registerLeapSecond_equalEarlierDate_sameLeap() {
   long[] dates = rules.getLeapSecondDates();
   long mjd = dates[dates.length - 2];
   int adj = rules.getLeapSecondAdjustment(mjd);
   rules.register(mjd, adj);
   long[] test = rules.getLeapSecondDates();
   assertEquals(Arrays.equals(test, dates), true);
   assertEquals(rules.getLeapSecondAdjustment(mjd), adj);
 }
Esempio n. 3
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void test_registerLeapSecond_equalEarlierDate_differentLeap() {
   long[] dates = rules.getLeapSecondDates();
   long mjd = dates[dates.length - 2];
   int adj = rules.getLeapSecondAdjustment(mjd);
   rules.register(mjd, -adj);
 }
Esempio n. 4
0
  @Test(dataProvider = "LeapSeconds")
  public void test_leapSeconds(long mjd, int adjust, int offset, String checkDate) {
    assertEquals(
        mjd, LocalDate.parse(checkDate).getLong(JulianFields.MODIFIED_JULIAN_DAY), "Invalid test");

    assertEquals(rules.getLeapSecondAdjustment(mjd), adjust);
    assertEquals(rules.getTaiOffset(mjd), offset);
    if (adjust != 0) {
      long[] leaps = rules.getLeapSecondDates();
      Arrays.sort(leaps);
      assertEquals(Arrays.binarySearch(leaps, mjd) >= 0, true);
    }
  }
Esempio n. 5
0
 @Test(expectedExceptions = IllegalArgumentException.class)
 public void test_registerLeapSecond_beforeLastDate() {
   long[] dates = rules.getLeapSecondDates();
   long mjd = dates[dates.length - 1] - 1;
   rules.register(mjd, 1);
 }