test/java/time/test/java/time/temporal/TestChronoUnit.java

Print this page

        

*** 104,142 **** }; } @Test(dataProvider = "yearsBetween") public void test_yearsBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start, end).getAmount(), expected); ! assertEquals(YEARS.between(start, end).getUnit(), YEARS); } @Test(dataProvider = "yearsBetween") public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(end, start).getAmount(), -expected); ! assertEquals(YEARS.between(end, start).getUnit(), YEARS); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected); } //----------------------------------------------------------------------- @DataProvider(name = "monthsBetween") Object[][] data_monthsBetween() { --- 104,140 ---- }; } @Test(dataProvider = "yearsBetween") public void test_yearsBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start, end), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(end, start), -expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); } @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); } //----------------------------------------------------------------------- @DataProvider(name = "monthsBetween") Object[][] data_monthsBetween() {
*** 171,209 **** }; } @Test(dataProvider = "monthsBetween") public void test_monthsBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start, end).getAmount(), expected); ! assertEquals(MONTHS.between(start, end).getUnit(), MONTHS); } @Test(dataProvider = "monthsBetween") public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(end, start).getAmount(), -expected); ! assertEquals(MONTHS.between(end, start).getUnit(), MONTHS); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected); } //----------------------------------------------------------------------- @DataProvider(name = "weeksBetween") Object[][] data_weeksBetween() { --- 169,205 ---- }; } @Test(dataProvider = "monthsBetween") public void test_monthsBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start, end), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(end, start), -expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); } @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); } //----------------------------------------------------------------------- @DataProvider(name = "weeksBetween") Object[][] data_weeksBetween() {
*** 232,249 **** }; } @Test(dataProvider = "weeksBetween") public void test_weeksBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(WEEKS.between(start, end).getAmount(), expected); ! assertEquals(WEEKS.between(start, end).getUnit(), WEEKS); } @Test(dataProvider = "weeksBetween") public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(WEEKS.between(end, start).getAmount(), -expected); ! assertEquals(WEEKS.between(end, start).getUnit(), WEEKS); } //----------------------------------------------------------------------- @DataProvider(name = "daysBetween") Object[][] data_daysBetween() { --- 228,243 ---- }; } @Test(dataProvider = "weeksBetween") public void test_weeksBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(WEEKS.between(start, end), expected); } @Test(dataProvider = "weeksBetween") public void test_weeksBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(WEEKS.between(end, start), -expected); } //----------------------------------------------------------------------- @DataProvider(name = "daysBetween") Object[][] data_daysBetween() {
*** 277,315 **** }; } @Test(dataProvider = "daysBetween") public void test_daysBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start, end).getAmount(), expected); ! assertEquals(DAYS.between(start, end).getUnit(), DAYS); } @Test(dataProvider = "daysBetween") public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(end, start).getAmount(), -expected); ! assertEquals(DAYS.between(end, start).getUnit(), DAYS); } @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)).getAmount(), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)).getAmount(), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))).getAmount(), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))).getAmount(), expected); } //----------------------------------------------------------------------- private static LocalDate date(int year, Month month, int dom) { return LocalDate.of(year, month, dom); --- 271,307 ---- }; } @Test(dataProvider = "daysBetween") public void test_daysBetween(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start, end), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetweenReversed(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(end, start), -expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeSameTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 30)), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateSameOffset(LocalDate start, LocalDate end, long expected) { ! assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); } @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 ! assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); } //----------------------------------------------------------------------- private static LocalDate date(int year, Month month, int dom) { return LocalDate.of(year, month, dom);