Path: blob/master/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java
41153 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24*25* @test26* @bug 8176841 819414827* @summary Tests *FormatSymbols class deals with Unicode extensions28* correctly.29* @modules jdk.localedata30* @run testng/othervm -Djava.locale.providers=CLDR SymbolsTests31*/3233import static org.testng.Assert.assertEquals;3435import java.text.DateFormatSymbols;36import java.text.DecimalFormatSymbols;37import java.util.Locale;3839import org.testng.annotations.DataProvider;40import org.testng.annotations.Test;4142/**43* Test *FormatSymbols classes with BCP47 U extensions44*/45@Test46public class SymbolsTests {4748private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz");49private static final Locale RG_IE = Locale.forLanguageTag("en-US-u-rg-iezzzz");50private static final Locale RG_AT = Locale.forLanguageTag("en-US-u-rg-atzzzz");5152@DataProvider(name="dateFormatSymbolsData")53Object[][] dateFormatSymbolsData() {54return new Object[][] {55// Locale, expected AM string, expected PM string5657{RG_GB, "am", "pm"},58{RG_IE, "a.m.", "p.m."},59{Locale.US, "AM", "PM"},60};61}6263@DataProvider(name="decimalFormatSymbolsData")64Object[][] decimalFormatSymbolsData() {65return new Object[][] {66// Locale, expected decimal separator, expected grouping separator6768{RG_AT, ',', '.'},69{Locale.US, '.', ','},7071// -nu & -rg mixed. -nu should win72{Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), '.', ','},73};74}7576@Test(dataProvider="dateFormatSymbolsData")77public void test_DateFormatSymbols(Locale locale, String amExpected, String pmExpected) {78DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale);79String[] ampm = dfs.getAmPmStrings();80assertEquals(ampm[0], amExpected);81assertEquals(ampm[1], pmExpected);82}8384@Test(dataProvider="decimalFormatSymbolsData")85public void test_DecimalFormatSymbols(Locale locale, char decimal, char grouping) {86DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);87assertEquals(dfs.getDecimalSeparator(), decimal);88assertEquals(dfs.getGroupingSeparator(), grouping);89}90}919293