< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2012, 2013, 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


  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     private static final int YDIFF_HEISEI = 1988;
 115     private static final int YDIFF_MEIJI = 1867;
 116     private static final int YDIFF_SHOWA = 1925;
 117     private static final int YDIFF_TAISHO = 1911;
 118 
 119     //-----------------------------------------------------------------------
 120     // Chronology.of(String)
 121     //-----------------------------------------------------------------------
 122     @Test
 123     public void test_chrono_byName() {
 124         Chronology c = JapaneseChronology.INSTANCE;
 125         Chronology test = Chronology.of("Japanese");
 126         Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
 127         Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
 128         Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
 129         Assert.assertEquals(test, c);
 130     }
 131 
 132     //-----------------------------------------------------------------------
 133     // Chronology.ofLocale(Locale)


 156     @Test
 157     public void test_chrono_byLocale_oldJP_variant() {
 158         Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
 159         Assert.assertEquals(test.getId(), "Japanese");
 160         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 161     }
 162 
 163     @Test
 164     public void test_chrono_byLocale_iso() {
 165         Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
 166         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
 167         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
 168     }
 169 
 170     //-----------------------------------------------------------------------
 171     // creation and cross-checks
 172     //-----------------------------------------------------------------------
 173     @DataProvider(name="createByEra")
 174     Object[][] data_createByEra() {
 175         return new Object[][] {

 176                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
 177                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
 178                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
 179                 {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)},
 180                 {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)},
 181                 {JapaneseEra.MEIJI, 6, 1, 1, 1, LocalDate.of(1873, 1, 1)},
 182                 {JapaneseEra.MEIJI, 45, 7, 29, 211, LocalDate.of(1912, 7, 29)},
 183                 {JapaneseEra.TAISHO, 1, 7, 30, 1, LocalDate.of(1912, 7, 30)},
 184                 {JapaneseEra.TAISHO, 15, 12, 24, 358, LocalDate.of(1926, 12, 24)},
 185                 {JapaneseEra.SHOWA, 1, 12, 25, 1, LocalDate.of(1926, 12, 25)},
 186                 {JapaneseEra.SHOWA, 64, 1, 7, 7, LocalDate.of(1989, 1, 7)},
 187                 {JapaneseEra.HEISEI, 1, 1, 8, 1, LocalDate.of(1989, 1, 8)},
 188         };
 189     }
 190 
 191     @Test(dataProvider="createByEra")
 192     public void test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
 193         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(era, yoe, moy, dom);
 194         JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom);
 195         assertEquals(dateByChronoFactory, dateByDateFactory);


 348 
 349             {1725, 2, 29},
 350             {500, 2, 29},
 351             {2100, 2, 29},
 352 
 353             {1872, 12, 31},     // Last day of MEIJI 5
 354         };
 355     }
 356 
 357     @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class)
 358     public void test_badDates(int year, int month, int dom) {
 359         JapaneseChronology.INSTANCE.date(year, month, dom);
 360     }
 361 
 362     //-----------------------------------------------------------------------
 363     // prolepticYear() and is LeapYear()
 364     //-----------------------------------------------------------------------
 365     @DataProvider(name="prolepticYear")
 366     Object[][] data_prolepticYear() {
 367         return new Object[][] {



 368                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
 369                 {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true},
 370 
 371                 {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true},
 372                 {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false},
 373 
 374                 {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false},
 375                 {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true},
 376 
 377                 {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true},
 378                 {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false},
 379         };
 380     }
 381 
 382     @Test(dataProvider="prolepticYear")
 383     public void test_prolepticYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
 384         Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue);
 385         assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj));
 386         assertEquals(eraObj, era);
 387         assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear);
 388     }
 389 


 531         assertEquals(test, LocalDate.of(1928, 10, 29));
 532     }
 533 
 534     @Test
 535     public void test_LocalDateTime_adjustToJapaneseDate() {
 536         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
 537         LocalDateTime test = LocalDateTime.MIN.with(jdate);
 538         assertEquals(test, LocalDateTime.of(1928, 10, 29, 0, 0));
 539     }
 540 
 541     //-----------------------------------------------------------------------
 542     // Check Japanese Eras
 543     //-----------------------------------------------------------------------
 544     @DataProvider(name="japaneseEras")
 545     Object[][] data_japanseseEras() {
 546         return new Object[][] {
 547             { JapaneseEra.MEIJI, -1, "Meiji"},
 548             { JapaneseEra.TAISHO, 0, "Taisho"},
 549             { JapaneseEra.SHOWA, 1, "Showa"},
 550             { JapaneseEra.HEISEI, 2, "Heisei"},

 551         };
 552     }
 553 
 554     @Test(dataProvider="japaneseEras")
 555     public void test_Japanese_Eras(Era era, int eraValue, String name) {
 556         assertEquals(era.getValue(), eraValue, "EraValue");
 557         assertEquals(era.toString(), name, "Era Name");
 558         assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()");
 559         List<Era> eras = JapaneseChronology.INSTANCE.eras();
 560         assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()");
 561     }
 562 
 563     @Test
 564     public void test_Japanese_badEras() {
 565         int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000};
 566         for (int badEra : badEras) {
 567             try {
 568                 Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
 569                 fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
 570             } catch (DateTimeException ex) {
 571                 // ignore expected exception
 572             }
 573         }
 574     }
 575 
 576     @Test(dataProvider="japaneseEras")
 577     public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) {
 578         JapaneseEra actualEra = JapaneseEra.valueOf(name);
 579         assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)");
 580 
 581         actualEra = JapaneseEra.of(eraValue);
 582         assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)");
 583 
 584         String string = actualEra.toString();
 585         assertEquals(string, name, "JapaneseEra.toString()");


 666             assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
 667         }
 668     }
 669 
 670     //-----------------------------------------------------------------------
 671     // toString()
 672     //-----------------------------------------------------------------------
 673     @DataProvider(name="toString")
 674     Object[][] data_toString() {
 675         return new Object[][] {
 676             {JapaneseChronology.INSTANCE.date(1873, 12,  5), "Japanese Meiji 6-12-05"},
 677             {JapaneseChronology.INSTANCE.date(1873, 12,  6), "Japanese Meiji 6-12-06"},
 678             {JapaneseChronology.INSTANCE.date(1873,  9,  8), "Japanese Meiji 6-09-08"},
 679             {JapaneseChronology.INSTANCE.date(1912,  7, 29), "Japanese Meiji 45-07-29"},
 680             {JapaneseChronology.INSTANCE.date(1912,  7, 30), "Japanese Taisho 1-07-30"},
 681             {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
 682             {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
 683             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
 684             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
 685             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},

 686         };
 687     }
 688 
 689     @Test(dataProvider="toString")
 690     public void test_toString(JapaneseDate jdate, String expected) {
 691         assertEquals(jdate.toString(), expected);
 692     }
 693 
 694     //-----------------------------------------------------------------------
 695     // equals()
 696     //-----------------------------------------------------------------------
 697     @Test
 698     public void test_equals_true() {
 699         assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE));
 700     }
 701 
 702     @Test
 703     public void test_equals_false() {
 704         assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE));
 705     }


   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


  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     private static final int YDIFF_NEWERA = 2018;
 115     private static final int YDIFF_HEISEI = 1988;
 116     private static final int YDIFF_MEIJI = 1867;
 117     private static final int YDIFF_SHOWA = 1925;
 118     private static final int YDIFF_TAISHO = 1911;
 119 
 120     //-----------------------------------------------------------------------
 121     // Chronology.of(String)
 122     //-----------------------------------------------------------------------
 123     @Test
 124     public void test_chrono_byName() {
 125         Chronology c = JapaneseChronology.INSTANCE;
 126         Chronology test = Chronology.of("Japanese");
 127         Assert.assertNotNull(test, "The Japanese calendar could not be found byName");
 128         Assert.assertEquals(test.getId(), "Japanese", "ID mismatch");
 129         Assert.assertEquals(test.getCalendarType(), "japanese", "Type mismatch");
 130         Assert.assertEquals(test, c);
 131     }
 132 
 133     //-----------------------------------------------------------------------
 134     // Chronology.ofLocale(Locale)


 157     @Test
 158     public void test_chrono_byLocale_oldJP_variant() {
 159         Chronology test = Chronology.ofLocale(new Locale("ja", "JP", "JP"));
 160         Assert.assertEquals(test.getId(), "Japanese");
 161         Assert.assertEquals(test, JapaneseChronology.INSTANCE);
 162     }
 163 
 164     @Test
 165     public void test_chrono_byLocale_iso() {
 166         Assert.assertEquals(Chronology.ofLocale(new Locale("ja", "JP")).getId(), "ISO");
 167         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP")).getId(), "ISO");
 168         Assert.assertEquals(Chronology.ofLocale(Locale.forLanguageTag("ja-JP-JP")).getId(), "ISO");
 169     }
 170 
 171     //-----------------------------------------------------------------------
 172     // creation and cross-checks
 173     //-----------------------------------------------------------------------
 174     @DataProvider(name="createByEra")
 175     Object[][] data_createByEra() {
 176         return new Object[][] {
 177                 {JapaneseEra.of(3), 2020 - YDIFF_NEWERA, 2, 29, 60, LocalDate.of(2020, 2, 29)}, // NEWERA
 178                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
 179                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
 180                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
 181                 {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)},
 182                 {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)},
 183                 {JapaneseEra.MEIJI, 6, 1, 1, 1, LocalDate.of(1873, 1, 1)},
 184                 {JapaneseEra.MEIJI, 45, 7, 29, 211, LocalDate.of(1912, 7, 29)},
 185                 {JapaneseEra.TAISHO, 1, 7, 30, 1, LocalDate.of(1912, 7, 30)},
 186                 {JapaneseEra.TAISHO, 15, 12, 24, 358, LocalDate.of(1926, 12, 24)},
 187                 {JapaneseEra.SHOWA, 1, 12, 25, 1, LocalDate.of(1926, 12, 25)},
 188                 {JapaneseEra.SHOWA, 64, 1, 7, 7, LocalDate.of(1989, 1, 7)},
 189                 {JapaneseEra.HEISEI, 1, 1, 8, 1, LocalDate.of(1989, 1, 8)},
 190         };
 191     }
 192 
 193     @Test(dataProvider="createByEra")
 194     public void test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
 195         JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(era, yoe, moy, dom);
 196         JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom);
 197         assertEquals(dateByChronoFactory, dateByDateFactory);


 350 
 351             {1725, 2, 29},
 352             {500, 2, 29},
 353             {2100, 2, 29},
 354 
 355             {1872, 12, 31},     // Last day of MEIJI 5
 356         };
 357     }
 358 
 359     @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class)
 360     public void test_badDates(int year, int month, int dom) {
 361         JapaneseChronology.INSTANCE.date(year, month, dom);
 362     }
 363 
 364     //-----------------------------------------------------------------------
 365     // prolepticYear() and is LeapYear()
 366     //-----------------------------------------------------------------------
 367     @DataProvider(name="prolepticYear")
 368     Object[][] data_prolepticYear() {
 369         return new Object[][] {
 370                 {3, JapaneseEra.of(3), 1, 1 + YDIFF_NEWERA, false}, // NEWERA
 371                 {3, JapaneseEra.of(3), 102, 102 + YDIFF_NEWERA, true}, // NEWERA
 372 
 373                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
 374                 {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true},
 375 
 376                 {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true},
 377                 {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false},
 378 
 379                 {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false},
 380                 {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true},
 381 
 382                 {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true},
 383                 {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false},
 384         };
 385     }
 386 
 387     @Test(dataProvider="prolepticYear")
 388     public void test_prolepticYear(int eraValue, Era  era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) {
 389         Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue);
 390         assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj));
 391         assertEquals(eraObj, era);
 392         assertEquals(JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear);
 393     }
 394 


 536         assertEquals(test, LocalDate.of(1928, 10, 29));
 537     }
 538 
 539     @Test
 540     public void test_LocalDateTime_adjustToJapaneseDate() {
 541         JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
 542         LocalDateTime test = LocalDateTime.MIN.with(jdate);
 543         assertEquals(test, LocalDateTime.of(1928, 10, 29, 0, 0));
 544     }
 545 
 546     //-----------------------------------------------------------------------
 547     // Check Japanese Eras
 548     //-----------------------------------------------------------------------
 549     @DataProvider(name="japaneseEras")
 550     Object[][] data_japanseseEras() {
 551         return new Object[][] {
 552             { JapaneseEra.MEIJI, -1, "Meiji"},
 553             { JapaneseEra.TAISHO, 0, "Taisho"},
 554             { JapaneseEra.SHOWA, 1, "Showa"},
 555             { JapaneseEra.HEISEI, 2, "Heisei"},
 556             { JapaneseEra.of(3), 3, "NewEra"}, // NEWERA
 557         };
 558     }
 559 
 560     @Test(dataProvider="japaneseEras")
 561     public void test_Japanese_Eras(Era era, int eraValue, String name) {
 562         assertEquals(era.getValue(), eraValue, "EraValue");
 563         assertEquals(era.toString(), name, "Era Name");
 564         assertEquals(era, JapaneseChronology.INSTANCE.eraOf(eraValue), "JapaneseChronology.eraOf()");
 565         List<Era> eras = JapaneseChronology.INSTANCE.eras();
 566         assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()");
 567     }
 568 
 569     @Test
 570     public void test_Japanese_badEras() {
 571         int badEras[] = {-1000, -998, -997, -2, 4, 5, 1000};
 572         for (int badEra : badEras) {
 573             try {
 574                 Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
 575                 fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
 576             } catch (DateTimeException ex) {
 577                 // ignore expected exception
 578             }
 579         }
 580     }
 581 
 582     @Test(dataProvider="japaneseEras")
 583     public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) {
 584         JapaneseEra actualEra = JapaneseEra.valueOf(name);
 585         assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)");
 586 
 587         actualEra = JapaneseEra.of(eraValue);
 588         assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)");
 589 
 590         String string = actualEra.toString();
 591         assertEquals(string, name, "JapaneseEra.toString()");


 672             assertEquals(doy, i, "with(DAY_OF_YEAR) incorrect for " + i + " " + hd2);
 673         }
 674     }
 675 
 676     //-----------------------------------------------------------------------
 677     // toString()
 678     //-----------------------------------------------------------------------
 679     @DataProvider(name="toString")
 680     Object[][] data_toString() {
 681         return new Object[][] {
 682             {JapaneseChronology.INSTANCE.date(1873, 12,  5), "Japanese Meiji 6-12-05"},
 683             {JapaneseChronology.INSTANCE.date(1873, 12,  6), "Japanese Meiji 6-12-06"},
 684             {JapaneseChronology.INSTANCE.date(1873,  9,  8), "Japanese Meiji 6-09-08"},
 685             {JapaneseChronology.INSTANCE.date(1912,  7, 29), "Japanese Meiji 45-07-29"},
 686             {JapaneseChronology.INSTANCE.date(1912,  7, 30), "Japanese Taisho 1-07-30"},
 687             {JapaneseChronology.INSTANCE.date(1926, 12, 24), "Japanese Taisho 15-12-24"},
 688             {JapaneseChronology.INSTANCE.date(1926, 12, 25), "Japanese Showa 1-12-25"},
 689             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
 690             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
 691             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
 692             {JapaneseChronology.INSTANCE.date(2020,  1,  6), "Japanese NewEra 2-01-06"},
 693         };
 694     }
 695 
 696     @Test(dataProvider="toString")
 697     public void test_toString(JapaneseDate jdate, String expected) {
 698         assertEquals(jdate.toString(), expected);
 699     }
 700 
 701     //-----------------------------------------------------------------------
 702     // equals()
 703     //-----------------------------------------------------------------------
 704     @Test
 705     public void test_equals_true() {
 706         assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE));
 707     }
 708 
 709     @Test
 710     public void test_equals_false() {
 711         assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE));
 712     }


< prev index next >