< prev index next >

test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -109,10 +109,11 @@
 /**
  * Test.
  */
 @Test
 public class TCKJapaneseChronology {
+    private static final int YDIFF_NEWERA = 2018;
     private static final int YDIFF_HEISEI = 1988;
     private static final int YDIFF_MEIJI = 1867;
     private static final int YDIFF_SHOWA = 1925;
     private static final int YDIFF_TAISHO = 1911;
 

@@ -171,10 +172,11 @@
     // creation and cross-checks
     //-----------------------------------------------------------------------
     @DataProvider(name="createByEra")
     Object[][] data_createByEra() {
         return new Object[][] {
+                {JapaneseEra.of(3), 2020 - YDIFF_NEWERA, 2, 29, 60, LocalDate.of(2020, 2, 29)}, // NEWERA
                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
                 {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)},
                 {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)},

@@ -363,12 +365,15 @@
     // prolepticYear() and is LeapYear()
     //-----------------------------------------------------------------------
     @DataProvider(name="prolepticYear")
     Object[][] data_prolepticYear() {
         return new Object[][] {
+                {3, JapaneseEra.of(3), 1, 1 + YDIFF_NEWERA, false}, // NEWERA
+                {3, JapaneseEra.of(3), 102, 102 + YDIFF_NEWERA, true}, // NEWERA
+
                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
-                {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true},
+                {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true},
 
                 {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true},
                 {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false},
 
                 {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false},

@@ -546,10 +551,11 @@
         return new Object[][] {
             { JapaneseEra.MEIJI, -1, "Meiji"},
             { JapaneseEra.TAISHO, 0, "Taisho"},
             { JapaneseEra.SHOWA, 1, "Showa"},
             { JapaneseEra.HEISEI, 2, "Heisei"},
+            { JapaneseEra.of(3), 3, "NewEra"}, // NEWERA
         };
     }
 
     @Test(dataProvider="japaneseEras")
     public void test_Japanese_Eras(Era era, int eraValue, String name) {

@@ -560,11 +566,11 @@
         assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()");
     }
 
     @Test
     public void test_Japanese_badEras() {
-        int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000};
+        int badEras[] = {-1000, -998, -997, -2, 4, 5, 1000};
         for (int badEra : badEras) {
             try {
                 Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
                 fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
             } catch (DateTimeException ex) {

@@ -681,10 +687,11 @@
             {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
             {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
+            {JapaneseChronology.INSTANCE.date(2020,  1,  6), "Japanese NewEra 2-01-06"},
         };
     }
 
     @Test(dataProvider="toString")
     public void test_toString(JapaneseDate jdate, String expected) {
< prev index next >