< prev index next >

test/java/time/tck/java/time/chrono/TCKJapaneseEra.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


  60 import static org.testng.Assert.assertEquals;
  61 import static org.testng.Assert.assertTrue;
  62 
  63 import java.time.chrono.Era;
  64 import java.time.chrono.JapaneseChronology;
  65 import java.time.chrono.JapaneseEra;
  66 import java.util.List;
  67 
  68 import org.testng.annotations.DataProvider;
  69 import org.testng.annotations.Test;
  70 
  71 /**
  72  * Test.
  73  */
  74 @Test
  75 public class TCKJapaneseEra {
  76 
  77     @DataProvider(name = "JapaneseEras")
  78     Object[][] data_of_eras() {
  79         return new Object[][] {

  80                     {JapaneseEra.HEISEI, "Heisei", 2},
  81                     {JapaneseEra.SHOWA, "Showa", 1},
  82                     {JapaneseEra.TAISHO, "Taisho", 0},
  83                     {JapaneseEra.MEIJI, "Meiji", -1},
  84         };
  85     }
  86 
  87     @Test(dataProvider="JapaneseEras")
  88     public void test_valueOf(JapaneseEra era , String eraName, int eraValue) {
  89         assertEquals(era.getValue(), eraValue);
  90         assertEquals(JapaneseEra.of(eraValue), era);
  91         assertEquals(JapaneseEra.valueOf(eraName), era);
  92     }
  93 
  94     //-----------------------------------------------------------------------
  95     // values()
  96     //-----------------------------------------------------------------------
  97     @Test
  98     public void test_values() {
  99         List<Era> eraList = JapaneseChronology.INSTANCE.eras();


   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


  60 import static org.testng.Assert.assertEquals;
  61 import static org.testng.Assert.assertTrue;
  62 
  63 import java.time.chrono.Era;
  64 import java.time.chrono.JapaneseChronology;
  65 import java.time.chrono.JapaneseEra;
  66 import java.util.List;
  67 
  68 import org.testng.annotations.DataProvider;
  69 import org.testng.annotations.Test;
  70 
  71 /**
  72  * Test.
  73  */
  74 @Test
  75 public class TCKJapaneseEra {
  76 
  77     @DataProvider(name = "JapaneseEras")
  78     Object[][] data_of_eras() {
  79         return new Object[][] {
  80                     {JapaneseEra.of(3), "NewEra", 3}, // NEWERA
  81                     {JapaneseEra.HEISEI, "Heisei", 2},
  82                     {JapaneseEra.SHOWA, "Showa", 1},
  83                     {JapaneseEra.TAISHO, "Taisho", 0},
  84                     {JapaneseEra.MEIJI, "Meiji", -1},
  85         };
  86     }
  87 
  88     @Test(dataProvider="JapaneseEras")
  89     public void test_valueOf(JapaneseEra era , String eraName, int eraValue) {
  90         assertEquals(era.getValue(), eraValue);
  91         assertEquals(JapaneseEra.of(eraValue), era);
  92         assertEquals(JapaneseEra.valueOf(eraName), era);
  93     }
  94 
  95     //-----------------------------------------------------------------------
  96     // values()
  97     //-----------------------------------------------------------------------
  98     @Test
  99     public void test_values() {
 100         List<Era> eraList = JapaneseChronology.INSTANCE.eras();


< prev index next >