/
githubmirror
/
panama-vector
Обзор
Документация
Войти
/
githubmirror
/
panama-vector
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/jdk/java/util/Locale/bcp47u/CurrencyFormatTests.java
103 строки
5 KB
Justin Lu
8368335: Refactor the rest of Locale TestNG based tests to JUnit
24 сен 2025, 22:29
24 сен 2025, 22:29
5d93242
Код
Авторство
О чём код?
/* * Copyright (c) 2019, 2025, 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 8215181 8230284 8231273 8284840 * @summary Tests the "u-cf" extension * @modules jdk.localedata * @run junit CurrencyFormatTests */ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import java.text.NumberFormat; import java.util.Locale; import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test NumberFormat with BCP47 u-cf extensions. Note that this test depends * on the particular CLDR release. Results may vary on other CLDR releases. */ public class CurrencyFormatTests { static Object[][] getInstanceData() { return new Object[][] { // Locale, amount, expected // US dollar {Locale.US, -100, "-$100.00"}, {Locale.forLanguageTag("en-US-u-cf-standard"), -100, "-$100.00"}, {Locale.forLanguageTag("en-US-u-cf-account"), -100, "($100.00)"}, {Locale.forLanguageTag("en-US-u-cf-bogus"), -100, "-$100.00"}, // Euro {Locale.forLanguageTag("en-AT"), -100, "-\u20ac\u00a0100,00"}, {Locale.forLanguageTag("en-AT-u-cf-standard"), -100, "-\u20ac\u00a0100,00"}, {Locale.forLanguageTag("en-AT-u-cf-account"), -100, "-\u20ac\u00a0100,00"}, {Locale.forLanguageTag("en-AT-u-cf-bogus"), -100, "-\u20ac\u00a0100,00"}, // Rupee {Locale.forLanguageTag("en-IN"), -100, "-\u20b9100.00"}, {Locale.forLanguageTag("en-IN-u-cf-standard"), -100, "-\u20b9100.00"}, {Locale.forLanguageTag("en-IN-u-cf-account"), -100, "(\u20b9100.00)"}, {Locale.forLanguageTag("en-IN-u-cf-bogus"), -100, "-\u20b9100.00"}, // Swiss franc {Locale.forLanguageTag("en-CH"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-CH-u-cf-standard"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-CH-u-cf-account"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-CH-u-cf-bogus"), -100, "CHF-100.00"}, // Region override {Locale.forLanguageTag("en-US-u-rg-CHZZZZ"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-standard"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-account"), -100, "CHF-100.00"}, {Locale.forLanguageTag("en-US-u-rg-CHZZZZ-cf-bogus"), -100, "CHF-100.00"}, // Numbering systems // explicit {Locale.forLanguageTag("zh-CN-u-nu-arab"), -100, "\u061c-\u00a5\u0661\u0660\u0660\u066b\u0660\u0660"}, {Locale.forLanguageTag("zh-CN-u-nu-arab-cf-standard"), -100, "\u061c-\u00a5\u0661\u0660\u0660\u066b\u0660\u0660"}, {Locale.forLanguageTag("zh-CN-u-nu-arab-cf-account"), -100, "\u061c-\u00a5\u0661\u0660\u0660\u066b\u0660\u0660"}, {Locale.forLanguageTag("zh-CN-u-nu-arab-cf-bogus"), -100, "\u061c-\u00a5\u0661\u0660\u0660\u066b\u0660\u0660"}, // implicit {Locale.forLanguageTag("zh-CN"), -100, "-\u00a5100.00"}, {Locale.forLanguageTag("zh-CN-u-cf-standard"), -100, "-\u00a5100.00"}, {Locale.forLanguageTag("zh-CN-u-cf-account"), -100, "(\u00a5100.00)"}, {Locale.forLanguageTag("zh-CN-u-cf-bogus"), -100, "-\u00a5100.00"}, {Locale.forLanguageTag("ar-SA"), -100, "\u061c-\u200f\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, {Locale.forLanguageTag("ar-SA-u-cf-standard"), -100, "\u061c-\u200f\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, {Locale.forLanguageTag("ar-SA-u-cf-account"), -100, "\u061c-\u200f\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, {Locale.forLanguageTag("ar-SA-u-cf-bogus"), -100, "\u061c-\u200f\u0661\u0660\u0660\u066b\u0660\u0660\u00a0\u0631.\u0633.\u200f"}, }; } @MethodSource("getInstanceData") @ParameterizedTest void test_getInstance(Locale locale, int amount, String expected) { assertEquals(expected, NumberFormat.getCurrencyInstance(locale).format(amount)); } }