• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 /*
27  * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
28  *
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions are met:
33  *
34  *  * Redistributions of source code must retain the above copyright notice,
35  *    this list of conditions and the following disclaimer.
36  *
37  *  * Redistributions in binary form must reproduce the above copyright notice,
38  *    this list of conditions and the following disclaimer in the documentation
39  *    and/or other materials provided with the distribution.
40  *
41  *  * Neither the name of JSR-310 nor the names of its contributors
42  *    may be used to endorse or promote products derived from this software
43  *    without specific prior written permission.
44  *
45  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
49  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
50  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
51  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
52  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
53  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
54  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56  */
57 package tck.java.time.chrono;
58 
59 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
60 import static java.time.temporal.ChronoField.DAY_OF_YEAR;
61 import static java.time.temporal.ChronoField.EPOCH_DAY;
62 import static java.time.temporal.ChronoField.ERA;
63 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
64 import static java.time.temporal.ChronoField.YEAR;
65 import static java.time.temporal.ChronoField.YEAR_OF_ERA;
66 import static org.testng.Assert.assertEquals;
67 import static org.testng.Assert.assertFalse;
68 import static org.testng.Assert.assertNotEquals;
69 import static org.testng.Assert.assertTrue;
70 import static org.testng.Assert.fail;
71 
72 import java.time.Clock;
73 import java.time.DateTimeException;
74 import java.time.LocalDate;
75 import java.time.LocalDateTime;
76 import java.time.Month;
77 import java.time.Period;
78 import java.time.Year;
79 import java.time.ZoneId;
80 import java.time.ZoneOffset;
81 import java.time.chrono.ChronoLocalDate;
82 import java.time.chrono.ChronoPeriod;
83 import java.time.chrono.Chronology;
84 import java.time.chrono.Era;
85 import java.time.chrono.IsoChronology;
86 import java.time.chrono.JapaneseChronology;
87 import java.time.chrono.JapaneseDate;
88 import java.time.chrono.JapaneseEra;
89 import java.time.chrono.MinguoChronology;
90 import java.time.chrono.MinguoDate;
91 import java.time.chrono.ThaiBuddhistChronology;
92 import java.time.format.ResolverStyle;
93 import java.time.temporal.ChronoField;
94 import java.time.temporal.ChronoUnit;
95 import java.time.temporal.TemporalAdjusters;
96 import java.time.temporal.TemporalField;
97 import java.time.temporal.TemporalQueries;
98 import java.time.temporal.ValueRange;
99 
100 import java.util.HashMap;
101 import java.util.List;
102 import java.util.Locale;
103 import java.util.Map;
104 
105 import org.testng.Assert;
106 import org.testng.annotations.DataProvider;
107 import org.testng.annotations.Test;
108 
109 /**
110  * Test.
111  */
112 @Test
113 public class TCKJapaneseChronology {
114 
115     // Year differences from Gregorian years.
116     private static final int YDIFF_REIWA = 2018;
117     private static final int YDIFF_HEISEI = 1988;
118     private static final int YDIFF_MEIJI = 1867;
119     private static final int YDIFF_SHOWA = 1925;
120     private static final int YDIFF_TAISHO = 1911;
121 
122     //-----------------------------------------------------------------------
123     // Chronology.of(String)
124     //-----------------------------------------------------------------------
125     @Test
test_chrono_byName()126     public void test_chrono_byName() {
127         Chronology c = JapaneseChronology.INSTANCE;
128         Chronology test = Chronology.of("Japanese");
129         Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
130         Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
131         Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
132         Assert.assertEquals(test, c);
133     }
134 
135     //-----------------------------------------------------------------------
136     // Chronology.ofLocale(Locale)
137     //-----------------------------------------------------------------------
138     @Test
test_chrono_byLocale_fullTag_japaneseCalendarFromJapan()139     public void test_chrono_byLocale_fullTag_japaneseCalendarFromJapan() {
140         Chronology test = Chronology.ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese"));
141         Assert.assertEquals(test.getId(), "Japanese");
142         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
143     }
144 
145     @Test
test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere()146     public void test_chrono_byLocale_fullTag_japaneseCalendarFromElsewhere() {
147         Chronology test = Chronology.ofLocale(Locale.forLanguageTag("en-US-u-ca-japanese"));
148         Assert.assertEquals(test.getId(), "Japanese");
149         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
150     }
151 
152     @Test
test_chrono_byLocale_oldJP_noVariant()153     public void test_chrono_byLocale_oldJP_noVariant() {
154         Chronology test = Chronology.ofLocale(new Locale("ja", "JP"));
155         Assert.assertEquals(test.getId(), "ISO");
156         Assert.assertEquals(test, IsoChronology.INSTANCE);
157     }
158 
159     @Test
test_chrono_byLocale_oldJP_variant()160     public void test_chrono_byLocale_oldJP_variant() {
161         Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
162         Assert.assertEquals(test.getId(), "Japanese");
163         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
164     }
165 
166     @Test
test_chrono_byLocale_iso()167     public void test_chrono_byLocale_iso() {
168         Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
169         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
170         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
171     }
172 
173     //-----------------------------------------------------------------------
174     // creation and cross-checks
175     //-----------------------------------------------------------------------
176     @DataProvider(name="createByEra")
data_createByEra()177     Object[][] data_createByEra() {
178         return new Object[][] {
179                 // Android-changed: Integrate OpenJDK support for Japanese Era Reiwa.
180                 //{JapaneseEra.of(3), 2020 - YDIFF_REIWA, 2, 29, 60, LocalDate.of(2020, 2, 29)},
181                 {JapaneseEra.REIWA, 2020 - YDIFF_REIWA, 2, 29, 60, LocalDate.of(2020, 2, 29)},
182                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
183                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
184                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
185                 {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)},
186                 {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)},
187                 {JapaneseEra.MEIJI, 6, 1, 1, 1, LocalDate.of(1873, 1, 1)},
188                 {JapaneseEra.MEIJI, 45, 7, 29, 211, LocalDate.of(1912, 7, 29)},
189                 {JapaneseEra.TAISHO, 1, 7, 30, 1, LocalDate.of(1912, 7, 30)},
190                 {JapaneseEra.TAISHO, 15, 12, 24, 358, LocalDate.of(1926, 12, 24)},
191                 {JapaneseEra.SHOWA, 1, 12, 25, 1, LocalDate.of(1926, 12, 25)},
192                 {JapaneseEra.SHOWA, 64, 1, 7, 7, LocalDate.of(1989, 1, 7)},
193                 {JapaneseEra.HEISEI, 1, 1, 8, 1, LocalDate.of(1989, 1, 8)},
194         };
195     }
196 
197     @Test(dataProvider="createByEra")
test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)198     public void test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
199         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(era, yoe, moy, dom);
200         JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom);
201         assertEquals(dateByChronoFactory, dateByDateFactory);
202         assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode());
203     }
204 
205     @Test(dataProvider="createByEra")
test_createEyd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)206     public void test_createEyd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
207         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.dateYearDay(era, yoe, doy);
208         JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom);
209         assertEquals(dateByChronoFactory, dateByDateFactory);
210         assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode());
211     }
212 
213     @Test(dataProvider="createByEra")
test_createByEra_isEqual(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)214     public void test_createByEra_isEqual(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
215         JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
216         assertEquals(test.isEqual(iso), true);
217         assertEquals(iso.isEqual(test), true);
218     }
219 
220     @Test(dataProvider="createByEra")
test_createByEra_chronologyTemporalFactory(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)221     public void test_createByEra_chronologyTemporalFactory(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
222         JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
223         assertEquals(IsoChronology.INSTANCE.date(test), iso);
224         assertEquals(JapaneseChronology.INSTANCE.date(iso), test);
225     }
226 
227     @Test(dataProvider="createByEra")
test_createByEra_dateFrom(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)228     public void test_createByEra_dateFrom(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
229         JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
230         assertEquals(LocalDate.from(test), iso);
231         assertEquals(JapaneseDate.from(iso), test);
232     }
233 
234     @Test(dataProvider="createByEra")
test_createByEra_query(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)235     public void test_createByEra_query(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
236         JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
237         assertEquals(test.query(TemporalQueries.localDate()), iso);
238     }
239 
240     @Test(dataProvider="createByEra")
test_createByEra_epochDay(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso)241     public void test_createByEra_epochDay(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
242         JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
243         assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
244         assertEquals(test.toEpochDay(), iso.toEpochDay());
245     }
246 
247     //-----------------------------------------------------------------------
248     @DataProvider(name="createByProleptic")
data_createByProleptic()249     Object[][] data_createByProleptic() {
250         return new Object[][] {
251                 {1928, 2, 28, 59, LocalDate.of(1928, 2, 28)},
252                 {1928, 2, 29, 60, LocalDate.of(1928, 2, 29)},
253 
254                 {1873, 9, 7, 250, LocalDate.of(1873, 9, 7)},
255                 {1873, 9, 8, 251, LocalDate.of(1873, 9, 8)},
256                 {1912, 7, 29, 211, LocalDate.of(1912, 7, 29)},
257                 {1912, 7, 30, 212, LocalDate.of(1912, 7, 30)},
258                 {1926, 12, 24, 358, LocalDate.of(1926, 12, 24)},
259                 {1926, 12, 25, 359, LocalDate.of(1926, 12, 25)},
260                 {1989, 1, 7, 7, LocalDate.of(1989, 1, 7)},
261                 {1989, 1, 8, 8, LocalDate.of(1989, 1, 8)},
262         };
263     }
264 
265     @Test(dataProvider="createByProleptic")
test_createYmd(int y, int moy, int dom, int doy, LocalDate iso)266     public void test_createYmd(int y, int moy, int dom, int doy, LocalDate iso) {
267         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(y, moy, dom);
268         JapaneseDate dateByDateFactory = JapaneseDate.of(y, moy, dom);
269         assertEquals(dateByChronoFactory, dateByDateFactory);
270         assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode());
271     }
272 
273     @Test(dataProvider="createByProleptic")
test_createYd(int y, int moy, int dom, int doy, LocalDate iso)274     public void test_createYd(int y, int moy, int dom, int doy, LocalDate iso) {
275         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.dateYearDay(y, doy);
276         JapaneseDate dateByDateFactory = JapaneseDate.of(y, moy, dom);
277         assertEquals(dateByChronoFactory, dateByDateFactory);
278         assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode());
279     }
280 
281     @Test(dataProvider="createByProleptic")
test_createByProleptic_isEqual(int y, int moy, int dom, int doy, LocalDate iso)282     public void test_createByProleptic_isEqual(int y, int moy, int dom, int doy, LocalDate iso) {
283         JapaneseDate test = JapaneseDate.of(y, moy, dom);
284         assertEquals(test.isEqual(iso), true);
285         assertEquals(iso.isEqual(test), true);
286     }
287 
288     @Test(dataProvider="createByProleptic")
test_createByProleptic_chronologyTemporalFactory(int y, int moy, int dom, int doy, LocalDate iso)289     public void test_createByProleptic_chronologyTemporalFactory(int y, int moy, int dom, int doy, LocalDate iso) {
290         JapaneseDate test = JapaneseDate.of(y, moy, dom);
291         assertEquals(IsoChronology.INSTANCE.date(test), iso);
292         assertEquals(JapaneseChronology.INSTANCE.date(iso), test);
293     }
294 
295     @Test(dataProvider="createByProleptic")
test_createByProleptic_dateFrom(int y, int moy, int dom, int doy, LocalDate iso)296     public void test_createByProleptic_dateFrom(int y, int moy, int dom, int doy, LocalDate iso) {
297         JapaneseDate test = JapaneseDate.of(y, moy, dom);
298         assertEquals(LocalDate.from(test), iso);
299         assertEquals(JapaneseDate.from(iso), test);
300     }
301 
302     @Test(dataProvider="createByProleptic")
test_createByProleptic_query(int y, int moy, int dom, int doy, LocalDate iso)303     public void test_createByProleptic_query(int y, int moy, int dom, int doy, LocalDate iso) {
304         JapaneseDate test = JapaneseDate.of(y, moy, dom);
305         assertEquals(test.query(TemporalQueries.localDate()), iso);
306     }
307 
308     @Test(dataProvider="createByProleptic")
test_createByProleptic_epochDay(int y, int moy, int dom, int doy, LocalDate iso)309     public void test_createByProleptic_epochDay(int y, int moy, int dom, int doy, LocalDate iso) {
310         JapaneseDate test = JapaneseDate.of(y, moy, dom);
311         assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
312         assertEquals(test.toEpochDay(), iso.toEpochDay());
313     }
314 
315     //-----------------------------------------------------------------------
316     @Test
test_dateNow()317     public void test_dateNow(){
318         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now()) ;
319         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(ZoneId.systemDefault())) ;
320         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone())) ;
321         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone().getZone())) ;
322 
323         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
324         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
325         assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;
326 
327         ZoneId zoneId = ZoneId.of("Europe/Paris");
328         assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
329         assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
330         assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId))) ;
331         assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId).getZone())) ;
332 
333         assertEquals(JapaneseChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), JapaneseChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
334     }
335 
336     //-----------------------------------------------------------------------
337     @DataProvider(name="badDates")
data_badDates()338     Object[][] data_badDates() {
339         return new Object[][] {
340             {1928, 0, 0},
341 
342             {1928, -1, 1},
343             {1928, 0, 1},
344             {1928, 14, 1},
345             {1928, 15, 1},
346 
347             {1928, 1, -1},
348             {1928, 1, 0},
349             {1928, 1, 32},
350 
351             {1928, 12, -1},
352             {1928, 12, 0},
353             {1928, 12, 32},
354 
355             {1725, 2, 29},
356             {500, 2, 29},
357             {2100, 2, 29},
358 
359             {1872, 12, 31},     // Last day of MEIJI 5
360         };
361     }
362 
363     @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class)
test_badDates(int year, int month, int dom)364     public void test_badDates(int year, int month, int dom) {
365         JapaneseChronology.INSTANCE.date(year, month, dom);
366     }
367 
368     //-----------------------------------------------------------------------
369     // prolepticYear() and is LeapYear()
370     //-----------------------------------------------------------------------
371     @DataProvider(name="prolepticYear")
data_prolepticYear()372     Object[][] data_prolepticYear() {
373         return new Object[][] {
374                 // Android-changed: Integrate OpenJDK support for Japanese Era Reiwa.
375                 // {3, JapaneseEra.of(3), 1, 1 + YDIFF_REIWA, false},
376                 // {3, JapaneseEra.of(3), 102, 102 + YDIFF_REIWA, true},
377                 {3, JapaneseEra.REIWA, 1, 1 + YDIFF_REIWA, false},
378                 {3, JapaneseEra.REIWA, 102, 102 + YDIFF_REIWA, true},
379 
380                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
381                 {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true},
382 
383                 {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true},
384                 {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false},
385 
386                 {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false},
387                 {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true},
388 
389                 {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true},
390                 {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false},
391         };
392     }
393 
394     @Test(dataProvider="prolepticYear")
test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear)395     public void test_prolepticYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
396         Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue);
397         assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj));
398         assertEquals(eraObj, era);
399         assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear);
400     }
401 
402     @Test(dataProvider="prolepticYear")
test_isLeapYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear)403     public void test_isLeapYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
404         assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear);
405         assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap());
406 
407         JapaneseDate jdate = JapaneseDate.now();
408         jdate = jdate.with(ChronoField.YEAR, expectedProlepticYear).with(ChronoField.MONTH_OF_YEAR, 2);
409         if (isLeapYear) {
410             assertEquals(jdate.lengthOfMonth(), 29);
411         } else {
412             assertEquals(jdate.lengthOfMonth(), 28);
413         }
414     }
415 
416     @DataProvider(name="prolepticYearError")
data_prolepticYearError()417     Object[][] data_prolepticYearError() {
418         return new Object[][] {
419                 {JapaneseEra.MEIJI, 100},
420                 {JapaneseEra.MEIJI, 0},
421                 {JapaneseEra.MEIJI, -10},
422 
423                 {JapaneseEra.SHOWA, 100},
424                 {JapaneseEra.SHOWA, 0},
425                 {JapaneseEra.SHOWA, -10},
426 
427                 {JapaneseEra.TAISHO, 100},
428                 {JapaneseEra.TAISHO, 0},
429                 {JapaneseEra.TAISHO, -10},
430         };
431     }
432 
433     @Test(dataProvider="prolepticYearError", expectedExceptions=DateTimeException.class)
test_prolepticYearError(Era era, int yearOfEra)434     public void test_prolepticYearError(Era era, int yearOfEra) {
435         JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra);
436     }
437 
438     //-----------------------------------------------------------------------
439     // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...)
440     //-----------------------------------------------------------------------
441     @Test
test_InvalidEras()442     public void test_InvalidEras() {
443         // Verify that the eras from every other Chronology are invalid
444         for (Chronology chrono : Chronology.getAvailableChronologies()) {
445             if (chrono instanceof JapaneseChronology) {
446                 continue;
447             }
448             List<Era> eras = chrono.eras();
449             for (Era era : eras) {
450                 try {
451                     ChronoLocalDate date = JapaneseChronology.INSTANCE.date(era, 1, 1, 1);
452                     fail("JapaneseChronology.date did not throw ClassCastException for Era: " + era);
453                 } catch (ClassCastException cex) {
454                     ; // ignore expected exception
455                 }
456                 try {
457                     @SuppressWarnings("unused")
458                     int year = JapaneseChronology.INSTANCE.prolepticYear(era, 1);
459                     fail("JapaneseChronology.prolepticYear did not throw ClassCastException for Era: " + era);
460                 } catch (ClassCastException cex) {
461                     ; // ignore expected exception
462                 }
463 
464             }
465         }
466     }
467 
468     //-----------------------------------------------------------------------
469     // get(TemporalField)
470     //-----------------------------------------------------------------------
471     @Test
test_getLong()472     public void test_getLong() {
473         JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30);
474         assertEquals(base.getLong(ERA), JapaneseEra.SHOWA.getValue());
475         assertEquals(base.getLong(YEAR), 1988L);
476         assertEquals(base.getLong(YEAR_OF_ERA), 63L);
477         assertEquals(base.getLong(MONTH_OF_YEAR), 6L);
478         assertEquals(base.getLong(DAY_OF_MONTH), 30L);
479     }
480 
481     //-----------------------------------------------------------------------
482     // with(TemporalField, long)
483     //-----------------------------------------------------------------------
484     @Test
test_with_TemporalField_long()485     public void test_with_TemporalField_long() {
486         JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30);
487         JapaneseDate test = base.with(YEAR, 1987);
488         assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30));
489 
490         test = test.with(YEAR_OF_ERA, 2);
491         assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30));
492 
493         test = test.with(ERA, JapaneseEra.HEISEI.getValue());
494         assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30));
495 
496         test = test.with(MONTH_OF_YEAR, 3);
497         assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30));
498 
499         test = test.with(DAY_OF_MONTH, 4);
500         assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4));
501     }
502 
503     //-----------------------------------------------------------------------
504     // with(WithAdjuster)
505     //-----------------------------------------------------------------------
506     @Test
test_adjust1()507     public void test_adjust1() {
508         JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 10, 29);
509         JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth());
510         assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 10, 31));
511     }
512 
513     @Test
test_adjust2()514     public void test_adjust2() {
515         JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 12, 2);
516         JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth());
517         assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 12, 31));
518     }
519 
520     //-----------------------------------------------------------------------
521     // JapaneseDate.with(Local*)
522     //-----------------------------------------------------------------------
523     @Test
test_adjust_toLocalDate()524     public void test_adjust_toLocalDate() {
525         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1926, 1, 4);
526         JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6));
527         assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6));
528     }
529 
530     @Test(expectedExceptions=DateTimeException.class)
test_adjust_toMonth()531     public void test_adjust_toMonth() {
532         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1926, 1, 4);
533         jdate.with(Month.APRIL);
534     }
535 
536     //-----------------------------------------------------------------------
537     // LocalDate.with(JapaneseDate)
538     //-----------------------------------------------------------------------
539     @Test
test_LocalDate_adjustToJapaneseDate()540     public void test_LocalDate_adjustToJapaneseDate() {
541         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
542         LocalDate test = LocalDate.MIN.with(jdate);
543         assertEquals(test, LocalDate.of(1928, 10, 29));
544     }
545 
546     @Test
test_LocalDateTime_adjustToJapaneseDate()547     public void test_LocalDateTime_adjustToJapaneseDate() {
548         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
549         LocalDateTime test = LocalDateTime.MIN.with(jdate);
550         assertEquals(test, LocalDateTime.of(1928, 10, 29, 0, 0));
551     }
552 
553     //-----------------------------------------------------------------------
554     // Check Japanese Eras
555     //-----------------------------------------------------------------------
556     @DataProvider(name="japaneseEras")
data_japanseseEras()557     Object[][] data_japanseseEras() {
558         return new Object[][] {
559             { JapaneseEra.MEIJI, -1, "Meiji"},
560             { JapaneseEra.TAISHO, 0, "Taisho"},
561             { JapaneseEra.SHOWA, 1, "Showa"},
562             { JapaneseEra.HEISEI, 2, "Heisei"},
563             // Android-changed: Integrate OpenJDK support for Japanese Era Reiwa.
564             // { JapaneseEra.of(3), 3, "Reiwa"},
565             { JapaneseEra.REIWA, 3, "Reiwa"},
566         };
567     }
568 
569     @Test(dataProvider="japaneseEras")
test_Japanese_Eras(Era era, int eraValue, String name)570     public void test_Japanese_Eras(Era era, int eraValue, String name) {
571         assertEquals(era.getValue(), eraValue, "EraValue");
572         assertEquals(era.toString(), name, "Era Name");
573         assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()");
574         List<Era> eras = JapaneseChronology.INSTANCE.eras();
575         assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()");
576     }
577 
578     @Test
test_Japanese_badEras()579     public void test_Japanese_badEras() {
580         int badEras[] = {-1000, -998, -997, -2, 4, 5, 1000};
581         for (int badEra : badEras) {
582             try {
583                 Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
584                 fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
585             } catch (DateTimeException ex) {
586                 // ignore expected exception
587             }
588         }
589     }
590 
591     @Test(dataProvider="japaneseEras")
test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name)592     public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) {
593         JapaneseEra actualEra = JapaneseEra.valueOf(name);
594         assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)");
595 
596         actualEra = JapaneseEra.of(eraValue);
597         assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)");
598 
599         String string = actualEra.toString();
600         assertEquals(string, name, "JapaneseEra.toString()");
601     }
602 
603     @Test
test_JapaneseEra_values()604     public void test_JapaneseEra_values() {
605         JapaneseEra[] actualEras = JapaneseEra.values();
606         Object[][] erasInfo = data_japanseseEras();
607         assertEquals(actualEras.length, erasInfo.length, "Wrong number of Eras");
608 
609         for (int i = 0; i < erasInfo.length; i++) {
610             Object[] eraInfo = erasInfo[i];
611             assertEquals(actualEras[i], eraInfo[0], "Singleton mismatch");
612         }
613     }
614 
615     @Test
test_JapaneseChronology_eras()616     public void test_JapaneseChronology_eras() {
617         List<Era> actualEras = JapaneseChronology.INSTANCE.eras();
618         Object[][] erasInfo = data_japanseseEras();
619         assertEquals(actualEras.size(), erasInfo.length, "Wrong number of Eras");
620 
621         for (int i = 0; i < erasInfo.length; i++) {
622             Object[] eraInfo = erasInfo[i];
623             assertEquals(actualEras.get(i), eraInfo[0], "Singleton mismatch");
624         }
625     }
626 
627     //-----------------------------------------------------------------------
628     // PeriodUntil()
629     //-----------------------------------------------------------------------
630     @Test
test_periodUntilDate()631     public void test_periodUntilDate() {
632         JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
633         JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
634         ChronoPeriod period = mdate1.until(mdate2);
635         assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
636     }
637 
638     @Test
test_periodUntilUnit()639     public void test_periodUntilUnit() {
640         JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
641         JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
642         long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
643         assertEquals(months, 13);
644     }
645 
646     @Test
test_periodUntilDiffChrono()647     public void test_periodUntilDiffChrono() {
648         JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
649         JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
650         MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
651         ChronoPeriod period = mdate1.until(ldate2);
652         assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
653     }
654 
655     //-----------------------------------------------------------------------
656     // JapaneseChronology.dateYearDay, getDayOfYear
657     //-----------------------------------------------------------------------
658     @Test
test_getDayOfYear()659     public void test_getDayOfYear() {
660         // Test all the Eras
661         for (JapaneseEra era : JapaneseEra.values()) {
662             int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1;  // Until Era supports range(YEAR_OF_ERA)
663             JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1);
664             ValueRange range = hd1.range(DAY_OF_YEAR);
665             assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()");
666 
667             for (int i = 1; i <= hd1.lengthOfYear(); i++) {
668                 JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i);
669                 int doy = hd.get(DAY_OF_YEAR);
670                 assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd);
671             }
672         }
673     }
674 
675     @Test
test_withDayOfYear()676     public void test_withDayOfYear() {
677         JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(1990, 1);
678         for (int i = 1; i <= hd.lengthOfYear(); i++) {
679             JapaneseDate hd2 = hd.with(DAY_OF_YEAR, i);
680             int doy = hd2.get(DAY_OF_YEAR);
681             assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
682         }
683     }
684 
685     //-----------------------------------------------------------------------
686     // toString()
687     //-----------------------------------------------------------------------
688     @DataProvider(name="toString")
data_toString()689     Object[][] data_toString() {
690         return new Object[][] {
691             {JapaneseChronology.INSTANCE.date(1873, 12,  5), "Japanese Meiji 6-12-05"},
692             {JapaneseChronology.INSTANCE.date(1873, 12,  6), "Japanese Meiji 6-12-06"},
693             {JapaneseChronology.INSTANCE.date(1873,  9,  8), "Japanese Meiji 6-09-08"},
694             {JapaneseChronology.INSTANCE.date(1912,  7, 29), "Japanese Meiji 45-07-29"},
695             {JapaneseChronology.INSTANCE.date(1912,  7, 30), "Japanese Taisho 1-07-30"},
696             {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
697             {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
698             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
699             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
700             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
701             {JapaneseChronology.INSTANCE.date(2020,  1,  6), "Japanese Reiwa 2-01-06"},
702         };
703     }
704 
705     @Test(dataProvider="toString")
test_toString(JapaneseDate jdate, String expected)706     public void test_toString(JapaneseDate jdate, String expected) {
707         assertEquals(jdate.toString(), expected);
708     }
709 
710     //-----------------------------------------------------------------------
711     // equals()
712     //-----------------------------------------------------------------------
713     @Test
test_equals_true()714     public void test_equals_true() {
715         assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE));
716     }
717 
718     @Test
test_equals_false()719     public void test_equals_false() {
720         assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE));
721     }
722 
723     //-----------------------------------------------------------------------
724     //-----------------------------------------------------------------------
725     @DataProvider(name = "resolve_styleByEra")
data_resolve_styleByEra()726     Object[][] data_resolve_styleByEra() {
727         Object[][] result = new Object[ResolverStyle.values().length * JapaneseEra.values().length][];
728         int i = 0;
729         for (ResolverStyle style : ResolverStyle.values()) {
730             for (JapaneseEra era : JapaneseEra.values()) {
731                 result[i++] = new Object[] {style, era};
732             }
733         }
734         return result;
735     }
736 
737     @Test(dataProvider = "resolve_styleByEra")
test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, JapaneseEra era)738     public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, JapaneseEra era) {
739         Map<TemporalField, Long> fieldValues = new HashMap<>();
740         fieldValues.put(ChronoField.ERA, (long) era.getValue());
741         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
742         assertEquals(date, null);
743         assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
744         assertEquals(fieldValues.size(), 1);
745     }
746 
747     @Test(dataProvider = "resolve_styleByEra")
test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, JapaneseEra era)748     public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, JapaneseEra era) {
749         Map<TemporalField, Long> fieldValues = new HashMap<>();
750         fieldValues.put(ChronoField.ERA, (long) era.getValue());
751         fieldValues.put(ChronoField.YEAR_OF_ERA, 1L);
752         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
753         assertEquals(date, null);
754         assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
755         assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L);
756         assertEquals(fieldValues.size(), 2);
757     }
758 
759     @Test(dataProvider = "resolve_styleByEra")
test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, JapaneseEra era)760     public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, JapaneseEra era) {
761         Map<TemporalField, Long> fieldValues = new HashMap<>();
762         fieldValues.put(ChronoField.ERA, (long) era.getValue());
763         fieldValues.put(ChronoField.YEAR, 1L);
764         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
765         assertEquals(date, null);
766         assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
767         assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1L);
768         assertEquals(fieldValues.size(), 2);
769     }
770 
771     @DataProvider(name = "resolve_styles")
data_resolve_styles()772     Object[][] data_resolve_styles() {
773         Object[][] result = new Object[ResolverStyle.values().length][];
774         int i = 0;
775         for (ResolverStyle style : ResolverStyle.values()) {
776             result[i++] = new Object[] {style};
777         }
778         return result;
779     }
780 
781     @Test(dataProvider = "resolve_styles")
test_resolve_yearOfEra_yearOfEraOnly_valid(ResolverStyle style)782     public void test_resolve_yearOfEra_yearOfEraOnly_valid(ResolverStyle style) {
783         Map<TemporalField, Long> fieldValues = new HashMap<>();
784         fieldValues.put(ChronoField.YEAR_OF_ERA, 1L);
785         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
786         assertEquals(date, null);
787         assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L);
788         assertEquals(fieldValues.size(), 1);
789     }
790 
791     @Test(dataProvider = "resolve_styles")
test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style)792     public void test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style) {
793         Map<TemporalField, Long> fieldValues = new HashMap<>();
794         fieldValues.put(ChronoField.YEAR_OF_ERA, 1L);
795         fieldValues.put(ChronoField.YEAR, 2012L);
796         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
797         assertEquals(date, null);
798         assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L);
799         assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 2012L);
800         assertEquals(fieldValues.size(), 2);
801     }
802 
test_resolve_yearOfEra_eraOnly_invalidTooSmall()803     public void test_resolve_yearOfEra_eraOnly_invalidTooSmall() {
804         for (ResolverStyle style : ResolverStyle.values()) {
805             Map<TemporalField, Long> fieldValues = new HashMap<>();
806             fieldValues.put(ChronoField.ERA, JapaneseEra.MEIJI.getValue() - 1L);
807             try {
808                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
809                 fail("Should have failed: " + style);
810             } catch (DateTimeException ex) {
811                 // expected
812             }
813         }
814     }
815 
test_resolve_yearOfEra_eraOnly_invalidTooLarge()816     public void test_resolve_yearOfEra_eraOnly_invalidTooLarge() {
817         for (ResolverStyle style : ResolverStyle.values()) {
818             Map<TemporalField, Long> fieldValues = new HashMap<>();
819             fieldValues.put(ChronoField.ERA, JapaneseEra.values()[JapaneseEra.values().length - 1].getValue() + 1L);
820             try {
821                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
822                 fail("Should have failed: " + style);
823             } catch (DateTimeException ex) {
824                 // expected
825             }
826         }
827     }
828 
829     //-----------------------------------------------------------------------
830     //-----------------------------------------------------------------------
831     @DataProvider(name = "resolve_ymd")
data_resolve_ymd()832     Object[][] data_resolve_ymd() {
833         return new Object[][] {
834                 {2012, 1, -365, date(2010, 12, 31), false, false},
835                 {2012, 1, -364, date(2011, 1, 1), false, false},
836                 {2012, 1, -31, date(2011, 11, 30), false, false},
837                 {2012, 1, -30, date(2011, 12, 1), false, false},
838                 {2012, 1, -12, date(2011, 12, 19), false, false},
839                 {2012, 1, 1, date(2012, 1, 1), true, true},
840                 {2012, 1, 59, date(2012, 2, 28), false, false},
841                 {2012, 1, 60, date(2012, 2, 29), false, false},
842                 {2012, 1, 61, date(2012, 3, 1), false, false},
843                 {2012, 1, 365, date(2012, 12, 30), false, false},
844                 {2012, 1, 366, date(2012, 12, 31), false, false},
845                 {2012, 1, 367, date(2013, 1, 1), false, false},
846                 {2012, 1, 367 + 364, date(2013, 12, 31), false, false},
847                 {2012, 1, 367 + 365, date(2014, 1, 1), false, false},
848 
849                 {2012, 2, 1, date(2012, 2, 1), true, true},
850                 {2012, 2, 28, date(2012, 2, 28), true, true},
851                 {2012, 2, 29, date(2012, 2, 29), true, true},
852                 {2012, 2, 30, date(2012, 3, 1), date(2012, 2, 29), false},
853                 {2012, 2, 31, date(2012, 3, 2), date(2012, 2, 29), false},
854                 {2012, 2, 32, date(2012, 3, 3), false, false},
855 
856                 {2012, -12, 1, date(2010, 12, 1), false, false},
857                 {2012, -11, 1, date(2011, 1, 1), false, false},
858                 {2012, -1, 1, date(2011, 11, 1), false, false},
859                 {2012, 0, 1, date(2011, 12, 1), false, false},
860                 {2012, 1, 1, date(2012, 1, 1), true, true},
861                 {2012, 12, 1, date(2012, 12, 1), true, true},
862                 {2012, 13, 1, date(2013, 1, 1), false, false},
863                 {2012, 24, 1, date(2013, 12, 1), false, false},
864                 {2012, 25, 1, date(2014, 1, 1), false, false},
865 
866                 {2012, 6, -31, date(2012, 4, 30), false, false},
867                 {2012, 6, -30, date(2012, 5, 1), false, false},
868                 {2012, 6, -1, date(2012, 5, 30), false, false},
869                 {2012, 6, 0, date(2012, 5, 31), false, false},
870                 {2012, 6, 1, date(2012, 6, 1), true, true},
871                 {2012, 6, 30, date(2012, 6, 30), true, true},
872                 {2012, 6, 31, date(2012, 7, 1), date(2012, 6, 30), false},
873                 {2012, 6, 61, date(2012, 7, 31), false, false},
874                 {2012, 6, 62, date(2012, 8, 1), false, false},
875 
876                 {2011, 2, 1, date(2011, 2, 1), true, true},
877                 {2011, 2, 28, date(2011, 2, 28), true, true},
878                 {2011, 2, 29, date(2011, 3, 1), date(2011, 2, 28), false},
879                 {2011, 2, 30, date(2011, 3, 2), date(2011, 2, 28), false},
880                 {2011, 2, 31, date(2011, 3, 3), date(2011, 2, 28), false},
881                 {2011, 2, 32, date(2011, 3, 4), false, false},
882         };
883     }
884 
885     @Test(dataProvider = "resolve_ymd")
test_resolve_ymd_lenient(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict)886     public void test_resolve_ymd_lenient(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) {
887         Map<TemporalField, Long> fieldValues = new HashMap<>();
888         fieldValues.put(ChronoField.YEAR, (long) y);
889         fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
890         fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
891         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
892         assertEquals(date, expected);
893         assertEquals(fieldValues.size(), 0);
894     }
895 
896     @Test(dataProvider = "resolve_ymd")
test_resolve_ymd_smart(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict)897     public void test_resolve_ymd_smart(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) {
898         Map<TemporalField, Long> fieldValues = new HashMap<>();
899         fieldValues.put(ChronoField.YEAR, (long) y);
900         fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
901         fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
902         if (Boolean.TRUE.equals(smart)) {
903             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
904             assertEquals(date, expected);
905             assertEquals(fieldValues.size(), 0);
906         } else if (smart instanceof JapaneseDate) {
907             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
908             assertEquals(date, smart);
909         } else {
910             try {
911                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
912                 fail("Should have failed");
913             } catch (DateTimeException ex) {
914                 // expected
915             }
916         }
917     }
918 
919     @Test(dataProvider = "resolve_ymd")
test_resolve_ymd_strict(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict)920     public void test_resolve_ymd_strict(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) {
921         Map<TemporalField, Long> fieldValues = new HashMap<>();
922         fieldValues.put(ChronoField.YEAR, (long) y);
923         fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
924         fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
925         if (strict) {
926             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
927             assertEquals(date, expected);
928             assertEquals(fieldValues.size(), 0);
929         } else {
930             try {
931                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
932                 fail("Should have failed");
933             } catch (DateTimeException ex) {
934                 // expected
935             }
936         }
937     }
938 
939     //-----------------------------------------------------------------------
940     //-----------------------------------------------------------------------
941     @DataProvider(name = "resolve_yd")
data_resolve_yd()942     Object[][] data_resolve_yd() {
943         return new Object[][] {
944                 {2012, -365, date(2010, 12, 31), false, false},
945                 {2012, -364, date(2011, 1, 1), false, false},
946                 {2012, -31, date(2011, 11, 30), false, false},
947                 {2012, -30, date(2011, 12, 1), false, false},
948                 {2012, -12, date(2011, 12, 19), false, false},
949                 {2012, -1, date(2011, 12, 30), false, false},
950                 {2012, 0, date(2011, 12, 31), false, false},
951                 {2012, 1, date(2012, 1, 1), true, true},
952                 {2012, 2, date(2012, 1, 2), true, true},
953                 {2012, 31, date(2012, 1, 31), true, true},
954                 {2012, 32, date(2012, 2, 1), true, true},
955                 {2012, 59, date(2012, 2, 28), true, true},
956                 {2012, 60, date(2012, 2, 29), true, true},
957                 {2012, 61, date(2012, 3, 1), true, true},
958                 {2012, 365, date(2012, 12, 30), true, true},
959                 {2012, 366, date(2012, 12, 31), true, true},
960                 {2012, 367, date(2013, 1, 1), false, false},
961                 {2012, 367 + 364, date(2013, 12, 31), false, false},
962                 {2012, 367 + 365, date(2014, 1, 1), false, false},
963 
964                 {2011, 59, date(2011, 2, 28), true, true},
965                 {2011, 60, date(2011, 3, 1), true, true},
966         };
967     }
968 
969     @Test(dataProvider = "resolve_yd")
test_resolve_yd_lenient(int y, int d, JapaneseDate expected, boolean smart, boolean strict)970     public void test_resolve_yd_lenient(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
971         Map<TemporalField, Long> fieldValues = new HashMap<>();
972         fieldValues.put(ChronoField.YEAR, (long) y);
973         fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
974         JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT);
975         assertEquals(date, expected);
976         assertEquals(fieldValues.size(), 0);
977     }
978 
979     @Test(dataProvider = "resolve_yd")
test_resolve_yd_smart(int y, int d, JapaneseDate expected, boolean smart, boolean strict)980     public void test_resolve_yd_smart(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
981         Map<TemporalField, Long> fieldValues = new HashMap<>();
982         fieldValues.put(ChronoField.YEAR, (long) y);
983         fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
984         if (smart) {
985             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
986             assertEquals(date, expected);
987             assertEquals(fieldValues.size(), 0);
988         } else {
989             try {
990                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
991                 fail("Should have failed");
992             } catch (DateTimeException ex) {
993                 // expected
994             }
995         }
996     }
997 
998     @Test(dataProvider = "resolve_yd")
test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict)999     public void test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
1000         Map<TemporalField, Long> fieldValues = new HashMap<>();
1001         fieldValues.put(ChronoField.YEAR, (long) y);
1002         fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
1003         if (strict) {
1004             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
1005             assertEquals(date, expected);
1006             assertEquals(fieldValues.size(), 0);
1007         } else {
1008             try {
1009                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
1010                 fail("Should have failed");
1011             } catch (DateTimeException ex) {
1012                 // expected
1013             }
1014         }
1015     }
1016 
1017     //-----------------------------------------------------------------------
1018     //-----------------------------------------------------------------------
1019     @DataProvider(name = "resolve_eymd")
data_resolve_eymd()1020     Object[][] data_resolve_eymd() {
1021         return new Object[][] {
1022                 // lenient
1023                 {ResolverStyle.LENIENT, JapaneseEra.HEISEI, 1, 1, 1, date(1989, 1, 1)},  // SHOWA, not HEISEI
1024                 {ResolverStyle.LENIENT, JapaneseEra.HEISEI, 1, 1, 7, date(1989, 1, 7)},  // SHOWA, not HEISEI
1025                 {ResolverStyle.LENIENT, JapaneseEra.HEISEI, 1, 1, 8, date(1989, 1, 8)},
1026                 {ResolverStyle.LENIENT, JapaneseEra.HEISEI, 1, 12, 31, date(1989, 12, 31)},
1027                 {ResolverStyle.LENIENT, JapaneseEra.HEISEI, 2, 1, 1, date(1990, 1, 1)},
1028 
1029                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 1, date(1989, 1, 1)},
1030                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 7, date(1989, 1, 7)},
1031                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 8, date(1989, 1, 8)},  // HEISEI, not SHOWA
1032                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 12, 31, date(1989, 12, 31)},  // HEISEI, not SHOWA
1033                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 65, 1, 1, date(1990, 1, 1)},  // HEISEI, not SHOWA
1034 
1035                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, -366, date(1987, 12, 31)},
1036                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, -365, date(1988, 1, 1)},
1037                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, -31, date(1988, 11, 30)},
1038                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, -30, date(1988, 12, 1)},
1039                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 0, date(1988, 12, 31)},
1040                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 1, date(1989, 1, 1)},
1041                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 27, date(1989, 1, 27)},
1042                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 28, date(1989, 1, 28)},
1043                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 29, date(1989, 1, 29)},
1044                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 30, date(1989, 1, 30)},
1045                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 31, date(1989, 1, 31)},
1046                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 32, date(1989, 2, 1)},
1047                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 58, date(1989, 2, 27)},
1048                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 59, date(1989, 2, 28)},
1049                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 60, date(1989, 3, 1)},
1050                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 365, date(1989, 12, 31)},
1051                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 1, 366, date(1990, 1, 1)},
1052 
1053                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 1, date(1988, 1, 1)},
1054                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 31, date(1988, 1, 31)},
1055                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 32, date(1988, 2, 1)},
1056                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 58, date(1988, 2, 27)},
1057                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 59, date(1988, 2, 28)},
1058                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 60, date(1988, 2, 29)},
1059                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 1, 61, date(1988, 3, 1)},
1060 
1061                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 2, 1, date(1989, 2, 1)},
1062                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 2, 28, date(1989, 2, 28)},
1063                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 64, 2, 29, date(1989, 3, 1)},
1064 
1065                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 2, 1, date(1988, 2, 1)},
1066                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 2, 28, date(1988, 2, 28)},
1067                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 2, 29, date(1988, 2, 29)},
1068                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 63, 2, 30, date(1988, 3, 1)},
1069 
1070                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 62, -11, 1, date(1986, 1, 1)},
1071                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 62, -1, 1, date(1986, 11, 1)},
1072                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 62, 0, 1, date(1986, 12, 1)},
1073                 {ResolverStyle.LENIENT, JapaneseEra.SHOWA, 62, 13, 1, date(1988, 1, 1)},
1074 
1075                 // smart
1076                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 0, 1, 1, null},
1077                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 1, 1, 1, date(1989, 1, 1)},  // SHOWA, not HEISEI
1078                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 1, 1, 7, date(1989, 1, 7)},  // SHOWA, not HEISEI
1079                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 1, 1, 8, date(1989, 1, 8)},
1080                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 1, 12, 31, date(1989, 12, 31)},
1081                 {ResolverStyle.SMART, JapaneseEra.HEISEI, 2, 1, 1, date(1990, 1, 1)},
1082 
1083                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 64, 1, 1, date(1989, 1, 1)},
1084                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 64, 1, 7, date(1989, 1, 7)},
1085                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 64, 1, 8, date(1989, 1, 8)},  // HEISEI, not SHOWA
1086                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 64, 12, 31, date(1989, 12, 31)},  // HEISEI, not SHOWA
1087                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 65, 1, 1, null},  // HEISEI, not SHOWA
1088 
1089                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 0, null},
1090                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 1, date(1987, 1, 1)},
1091                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 27, date(1987, 1, 27)},
1092                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 28, date(1987, 1, 28)},
1093                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 29, date(1987, 1, 29)},
1094                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 30, date(1987, 1, 30)},
1095                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 31, date(1987, 1, 31)},
1096                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 1, 32, null},
1097 
1098                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 0, null},
1099                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 1, date(1987, 2, 1)},
1100                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 27, date(1987, 2, 27)},
1101                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 28, date(1987, 2, 28)},
1102                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 29, date(1987, 2, 28)},
1103                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 30, date(1987, 2, 28)},
1104                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 31, date(1987, 2, 28)},
1105                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 2, 32, null},
1106 
1107                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 0, null},
1108                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 1, date(1988, 2, 1)},
1109                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 27, date(1988, 2, 27)},
1110                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 28, date(1988, 2, 28)},
1111                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 29, date(1988, 2, 29)},
1112                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 30, date(1988, 2, 29)},
1113                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 31, date(1988, 2, 29)},
1114                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 63, 2, 32, null},
1115 
1116                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, -12, 1, null},
1117                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, -1, 1, null},
1118                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 0, 1, null},
1119                 {ResolverStyle.SMART, JapaneseEra.SHOWA, 62, 13, 1, null},
1120 
1121                 // strict
1122                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 0, 1, 1, null},
1123                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 1, 1, 1, null},  // SHOWA, not HEISEI
1124                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 1, 1, 7, null},  // SHOWA, not HEISEI
1125                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 1, 1, 8, date(1989, 1, 8)},
1126                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 1, 12, 31, date(1989, 12, 31)},
1127                 {ResolverStyle.STRICT, JapaneseEra.HEISEI, 2, 1, 1, date(1990, 1, 1)},
1128 
1129                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 64, 1, 1, date(1989, 1, 1)},
1130                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 64, 1, 7, date(1989, 1, 7)},
1131                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 64, 1, 8, null},  // HEISEI, not SHOWA
1132                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 64, 12, 31, null},  // HEISEI, not SHOWA
1133                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 65, 1, 1, null},  // HEISEI, not SHOWA
1134 
1135                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 0, null},
1136                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 1, date(1987, 1, 1)},
1137                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 27, date(1987, 1, 27)},
1138                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 28, date(1987, 1, 28)},
1139                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 29, date(1987, 1, 29)},
1140                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 30, date(1987, 1, 30)},
1141                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 31, date(1987, 1, 31)},
1142                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 1, 32, null},
1143 
1144                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 0, null},
1145                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 1, date(1987, 2, 1)},
1146                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 27, date(1987, 2, 27)},
1147                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 28, date(1987, 2, 28)},
1148                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 29, null},
1149                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 30, null},
1150                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 31, null},
1151                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 2, 32, null},
1152 
1153                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 0, null},
1154                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 1, date(1988, 2, 1)},
1155                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 27, date(1988, 2, 27)},
1156                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 28, date(1988, 2, 28)},
1157                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 29, date(1988, 2, 29)},
1158                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 30, null},
1159                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 31, null},
1160                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 63, 2, 32, null},
1161 
1162                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, -12, 1, null},
1163                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, -1, 1, null},
1164                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 0, 1, null},
1165                 {ResolverStyle.STRICT, JapaneseEra.SHOWA, 62, 13, 1, null},
1166         };
1167     }
1168 
1169     @Test(dataProvider = "resolve_eymd")
test_resolve_eymd(ResolverStyle style, JapaneseEra era, int yoe, int m, int d, JapaneseDate expected)1170     public void test_resolve_eymd(ResolverStyle style, JapaneseEra era, int yoe, int m, int d, JapaneseDate expected) {
1171         Map<TemporalField, Long> fieldValues = new HashMap<>();
1172         fieldValues.put(ChronoField.ERA, (long) era.getValue());
1173         fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
1174         fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
1175         fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
1176         if (expected != null) {
1177             JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
1178             assertEquals(date, expected);
1179             assertEquals(fieldValues.size(), 0);
1180         } else {
1181             try {
1182                 JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
1183                 fail("Should have failed");
1184             } catch (DateTimeException ex) {
1185                 // expected
1186             }
1187         }
1188     }
1189 
1190     //-----------------------------------------------------------------------
date(int y, int m, int d)1191     private static JapaneseDate date(int y, int m, int d) {
1192         return JapaneseDate.of(y, m, d);
1193     }
1194 
1195 }
1196