/
githubmirror
/
jdk21u-dev
Обзор
Документация
Войти
/
githubmirror
/
jdk21u-dev
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/jdk/java/util/Locale/bcp47u/SymbolsTests.java
90 строк
3 KB
Goetz Lindenmaier
8368335: Refactor the rest of Locale TestNG based tests to JUnit
08 апр 2026, 10:57
08 апр 2026, 10:57
9f63b49
Код
Авторство
О чём код?
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * * @test * @bug 8176841 8194148 * @summary Tests *FormatSymbols class deals with Unicode extensions * correctly. * @modules jdk.localedata * @run junit/othervm -Djava.locale.providers=CLDR SymbolsTests */ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import java.text.DateFormatSymbols; import java.text.DecimalFormatSymbols; import java.util.Locale; import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test *FormatSymbols classes with BCP47 U extensions */ public class SymbolsTests { private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); private static final Locale RG_IE = Locale.forLanguageTag("en-US-u-rg-iezzzz"); private static final Locale RG_AT = Locale.forLanguageTag("en-US-u-rg-atzzzz"); static Object[][] dateFormatSymbolsData() { return new Object[][] { // Locale, expected AM string, expected PM string {RG_GB, "am", "pm"}, {RG_IE, "a.m.", "p.m."}, {Locale.US, "AM", "PM"}, }; } static Object[][] decimalFormatSymbolsData() { return new Object[][] { // Locale, expected decimal separator, expected grouping separator {RG_AT, ',', '.'}, {Locale.US, '.', ','}, // -nu & -rg mixed. -nu should win {Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), '.', ','}, }; } @MethodSource("dateFormatSymbolsData") @ParameterizedTest void test_DateFormatSymbols(Locale locale, String amExpected, String pmExpected) { DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale); String[] ampm = dfs.getAmPmStrings(); assertEquals(amExpected, ampm[0]); assertEquals(pmExpected, ampm[1]); } @MethodSource("decimalFormatSymbolsData") @ParameterizedTest void test_DecimalFormatSymbols(Locale locale, char decimal, char grouping) { DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); assertEquals(decimal, dfs.getDecimalSeparator()); assertEquals(grouping, dfs.getGroupingSeparator()); } }