下面列出了java.time.LocalDate#datesUntil ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void test_datesUntil_staticType() {
// Test the types of the Stream and elements of the stream
LocalDate date = date(2015, 2, 10);
Stream<LocalDate> stream = date.datesUntil(date.plusDays(5));
long sum = stream.mapToInt(LocalDate::getDayOfMonth).sum();
assertEquals(sum, 60, "sum of 10, 11, 12, 13, 14 is wrong");
}
@Test(expectedExceptions=NullPointerException.class)
public void test_datesUntil_nullEnd() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(null);
}
@Test(expectedExceptions=NullPointerException.class)
public void test_datesUntil_nullEndStep() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(null, Period.ofDays(1));
}
@Test(expectedExceptions=NullPointerException.class)
public void test_datesUntil_nullStep() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(date, null);
}
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_datesUntil_zeroStep() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(date, Period.ZERO);
}
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_datesUntil_oppositeSign() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(date, Period.of(1, 0, -1));
}
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_datesUntil_oppositeSign2() {
LocalDate date = date(2015, 1, 31);
date.datesUntil(date, Period.of(0, -1, 1));
}