Search in sources :

Example 1 with JapaneseEra

use of java.time.chrono.JapaneseEra in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_JapaneseEra_singletons.

@Test(dataProvider = "japaneseEras")
public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) {
    JapaneseEra actualEra = JapaneseEra.valueOf(name);
    assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)");
    actualEra = JapaneseEra.of(eraValue);
    assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)");
    String string = actualEra.toString();
    assertEquals(string, name, "JapaneseEra.toString()");
}
Also used : JapaneseEra(java.time.chrono.JapaneseEra) Test(org.testng.annotations.Test)

Example 2 with JapaneseEra

use of java.time.chrono.JapaneseEra in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_getDayOfYear.

//-----------------------------------------------------------------------
// JapaneseChronology.dateYearDay, getDayOfYear
//-----------------------------------------------------------------------
@Test
public void test_getDayOfYear() {
    // Test all the Eras
    for (JapaneseEra era : JapaneseEra.values()) {
        // Until Era supports range(YEAR_OF_ERA)
        int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1;
        JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1);
        ValueRange range = hd1.range(DAY_OF_YEAR);
        assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()");
        for (int i = 1; i <= hd1.lengthOfYear(); i++) {
            JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i);
            int doy = hd.get(DAY_OF_YEAR);
            assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd);
        }
    }
}
Also used : ValueRange(java.time.temporal.ValueRange) JapaneseDate(java.time.chrono.JapaneseDate) JapaneseEra(java.time.chrono.JapaneseEra) Test(org.testng.annotations.Test)

Example 3 with JapaneseEra

use of java.time.chrono.JapaneseEra in project jdk8u_jdk by JetBrains.

the class TCKJapaneseEra method test_values.

//-----------------------------------------------------------------------
// values()
//-----------------------------------------------------------------------
@Test
public void test_values() {
    List<Era> eraList = JapaneseChronology.INSTANCE.eras();
    JapaneseEra[] eras = JapaneseEra.values();
    assertEquals(eraList.size(), eras.length);
    for (JapaneseEra era : eras) {
        assertTrue(eraList.contains(era));
    }
}
Also used : JapaneseEra(java.time.chrono.JapaneseEra) Era(java.time.chrono.Era) JapaneseEra(java.time.chrono.JapaneseEra) Test(org.testng.annotations.Test)

Example 4 with JapaneseEra

use of java.time.chrono.JapaneseEra in project jdk8u_jdk by JetBrains.

the class TCKJapaneseEra method test_range.

//-----------------------------------------------------------------------
// range()
//-----------------------------------------------------------------------
@Test
public void test_range() {
    // eras may be added after release
    for (JapaneseEra era : JapaneseEra.values()) {
        assertEquals(era.range(ERA).getMinimum(), -1);
        assertEquals(era.range(ERA).getLargestMinimum(), -1);
        assertEquals(era.range(ERA).getSmallestMaximum(), era.range(ERA).getMaximum());
        assertEquals(era.range(ERA).getMaximum() >= 2, true);
    }
}
Also used : JapaneseEra(java.time.chrono.JapaneseEra) Test(org.testng.annotations.Test)

Example 5 with JapaneseEra

use of java.time.chrono.JapaneseEra in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method data_resolve_styleByEra.

//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
@DataProvider(name = "resolve_styleByEra")
Object[][] data_resolve_styleByEra() {
    Object[][] result = new Object[ResolverStyle.values().length * JapaneseEra.values().length][];
    int i = 0;
    for (ResolverStyle style : ResolverStyle.values()) {
        for (JapaneseEra era : JapaneseEra.values()) {
            result[i++] = new Object[] { style, era };
        }
    }
    return result;
}
Also used : ResolverStyle(java.time.format.ResolverStyle) JapaneseEra(java.time.chrono.JapaneseEra) DataProvider(org.testng.annotations.DataProvider)

Aggregations

JapaneseEra (java.time.chrono.JapaneseEra)7 Test (org.testng.annotations.Test)6 JapaneseDate (java.time.chrono.JapaneseDate)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 OffsetDateTime (java.time.OffsetDateTime)1 Era (java.time.chrono.Era)1 ResolverStyle (java.time.format.ResolverStyle)1 ValueRange (java.time.temporal.ValueRange)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 Locale (java.util.Locale)1 DataProvider (org.testng.annotations.DataProvider)1 AbstractTCKTest (tck.java.time.AbstractTCKTest)1