Search in sources :

Example 21 with MonthDay

use of java.time.MonthDay in project jdk8u_jdk by JetBrains.

the class TCKMonthDay method doTest_comparisons_MonthDay.

void doTest_comparisons_MonthDay(MonthDay... localDates) {
    for (int i = 0; i < localDates.length; i++) {
        MonthDay a = localDates[i];
        for (int j = 0; j < localDates.length; j++) {
            MonthDay b = localDates[j];
            if (i < j) {
                assertTrue(a.compareTo(b) < 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), true, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else if (i > j) {
                assertTrue(a.compareTo(b) > 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), true, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else {
                assertEquals(a.compareTo(b), 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), true, a + " <=> " + b);
            }
        }
    }
}
Also used : MonthDay(java.time.MonthDay)

Example 22 with MonthDay

use of java.time.MonthDay in project jdk8u_jdk by JetBrains.

the class TCKMonthDay method factory_parse_success.

@Test(dataProvider = "goodParseData")
public void factory_parse_success(String text, MonthDay expected) {
    MonthDay monthDay = MonthDay.parse(text);
    assertEquals(monthDay, expected);
}
Also used : MonthDay(java.time.MonthDay) Test(org.testng.annotations.Test)

Example 23 with MonthDay

use of java.time.MonthDay in project jdk8u_jdk by JetBrains.

the class TCKMonthDay method test_equals.

//-----------------------------------------------------------------------
// equals()
//-----------------------------------------------------------------------
@Test
public void test_equals() {
    MonthDay a = MonthDay.of(1, 1);
    MonthDay b = MonthDay.of(1, 1);
    MonthDay c = MonthDay.of(2, 1);
    MonthDay d = MonthDay.of(1, 2);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), true);
    assertEquals(a.equals(c), false);
    assertEquals(a.equals(d), false);
    assertEquals(b.equals(a), true);
    assertEquals(b.equals(b), true);
    assertEquals(b.equals(c), false);
    assertEquals(b.equals(d), false);
    assertEquals(c.equals(a), false);
    assertEquals(c.equals(b), false);
    assertEquals(c.equals(c), true);
    assertEquals(c.equals(d), false);
    assertEquals(d.equals(a), false);
    assertEquals(d.equals(b), false);
    assertEquals(d.equals(c), false);
    assertEquals(d.equals(d), true);
}
Also used : MonthDay(java.time.MonthDay) Test(org.testng.annotations.Test)

Example 24 with MonthDay

use of java.time.MonthDay in project jdk8u_jdk by JetBrains.

the class TCKMonthDay method test_atYear_int_invalidYear.

@Test(expectedExceptions = DateTimeException.class)
public void test_atYear_int_invalidYear() {
    MonthDay test = MonthDay.of(6, 30);
    test.atYear(Integer.MIN_VALUE);
}
Also used : MonthDay(java.time.MonthDay) Test(org.testng.annotations.Test)

Example 25 with MonthDay

use of java.time.MonthDay in project jdk8u_jdk by JetBrains.

the class TCKMonthDay method test_get.

@Test(dataProvider = "sampleDates")
public void test_get(int m, int d) {
    MonthDay a = MonthDay.of(m, d);
    assertEquals(a.getMonth(), Month.of(m));
    assertEquals(a.getMonthValue(), m);
    assertEquals(a.getDayOfMonth(), d);
}
Also used : MonthDay(java.time.MonthDay) Test(org.testng.annotations.Test)

Aggregations

MonthDay (java.time.MonthDay)28 Test (org.testng.annotations.Test)25 LocalDate (java.time.LocalDate)4 IOException (java.io.IOException)1 Clock (java.time.Clock)1 Instant (java.time.Instant)1 YearMonth (java.time.YearMonth)1 ZoneId (java.time.ZoneId)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Test (org.junit.Test)1