From: Peter Edberg Date: Wed, 10 Mar 2021 00:36:07 +0000 (-0800) Subject: ICU-21480 brs 69rc, add tests to verify that rbnf spellout is the same for no,nb X-Git-Tag: release-69-rc~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cdfe2dc1faa3b40a68448133857c2c9887c48bd;p=icu ICU-21480 brs 69rc, add tests to verify that rbnf spellout is the same for no,nb --- diff --git a/icu4c/source/test/intltest/itrbnf.cpp b/icu4c/source/test/intltest/itrbnf.cpp index d5487cc6ae5..73f55325634 100644 --- a/icu4c/source/test/intltest/itrbnf.cpp +++ b/icu4c/source/test/intltest/itrbnf.cpp @@ -77,6 +77,7 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name, TESTCASE(25, TestCompactDecimalFormatStyle); TESTCASE(26, TestParseFailure); TESTCASE(27, TestMinMaxIntegerDigitsIgnored); + TESTCASE(28, TestNorwegianSpellout); #else TESTCASE(0, TestRBNFDisabled); #endif @@ -1604,6 +1605,38 @@ IntlTestRBNF::TestThaiSpellout() delete formatter; } +void +IntlTestRBNF::TestNorwegianSpellout() +{ + UErrorCode status = U_ZERO_ERROR; + RuleBasedNumberFormat* noFormatter + = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("no"), status); + RuleBasedNumberFormat* nbFormatter + = new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("nb"), status); + + if (U_FAILURE(status)) { + errcheckln(status, "FAIL: could not construct formatter - %s", u_errorName(status)); + } else { + static const char* testDataDefault[][2] = { + { "1", "\\u00E9n" }, + { "2", "to" }, + { "3", "tre" }, + { "4", "fire" }, + { "101", "hundre og \\u00E9n" }, + { "123", "hundre og tjue\\u00ADtre" }, + { "1,001", "tusen og \\u00E9n" }, + { "1,100", "tusen hundre" }, + { "6.789", "seks komma sju \\u00E5tte ni" }, + { "-5.678", "minus fem komma seks sju \\u00E5tte" }, + { NULL, NULL } + }; + doTest(noFormatter, testDataDefault, TRUE); + doTest(nbFormatter, testDataDefault, TRUE); + } + delete nbFormatter; + delete noFormatter; +} + void IntlTestRBNF::TestSwedishSpellout() { diff --git a/icu4c/source/test/intltest/itrbnf.h b/icu4c/source/test/intltest/itrbnf.h index c82b50d86fe..5cb97ea2b5f 100644 --- a/icu4c/source/test/intltest/itrbnf.h +++ b/icu4c/source/test/intltest/itrbnf.h @@ -101,6 +101,11 @@ class IntlTestRBNF : public IntlTest { */ void TestThaiSpellout(); + /** + * Perform a simple spot check on the Norwegian (no,nb) spellout rules + */ + void TestNorwegianSpellout(); + /** * Perform a simple spot check on the Swedish spellout rules */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java index c062f5e52d8..e7973255982 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RbnfTest.java @@ -820,6 +820,35 @@ public class RbnfTest extends TestFmwk { doTest(formatter, testData, false); // exact values aren't parsable from fractions } + @Test + public void TestNorwegianSpellout() + { + Locale noLocale = new Locale("no", "", ""); + Locale nbLocale = new Locale("nb", "", ""); + RuleBasedNumberFormat noFormatter = new RuleBasedNumberFormat(noLocale, + RuleBasedNumberFormat.SPELLOUT); + RuleBasedNumberFormat nbFormatter = new RuleBasedNumberFormat(nbLocale, + RuleBasedNumberFormat.SPELLOUT); + + String[][] testDataDefault = { + { "1", "\u00E9n" }, + { "2", "to" }, + { "3", "tre" }, + { "4", "fire" }, + { "101", "hundre og \u00E9n" }, + { "123", "hundre og tjue\u00ADtre" }, + { "1,001", "tusen og \u00E9n" }, + { "1,100", "tusen hundre" }, + { "6.789", "seks komma sju \u00E5tte ni" }, + { "-5.678", "minus fem komma seks sju \u00E5tte" }, + }; + + logln("testing default rules"); + doTest(noFormatter, testDataDefault, true); + doTest(nbFormatter, testDataDefault, true); + + } + @Test public void TestSwedishSpellout() {