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 d5487cc..73f5532 100644
--- a/icu4c/source/test/intltest/itrbnf.cpp
+++ b/icu4c/source/test/intltest/itrbnf.cpp
@@ -77,6 +77,7 @@
TESTCASE(25, TestCompactDecimalFormatStyle);
TESTCASE(26, TestParseFailure);
TESTCASE(27, TestMinMaxIntegerDigitsIgnored);
+ TESTCASE(28, TestNorwegianSpellout);
#else
TESTCASE(0, TestRBNFDisabled);
#endif
@@ -1605,6 +1606,38 @@
}
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()
{
UErrorCode status = U_ZERO_ERROR;
diff --git a/icu4c/source/test/intltest/itrbnf.h b/icu4c/source/test/intltest/itrbnf.h
index c82b50d..5cb97ea 100644
--- a/icu4c/source/test/intltest/itrbnf.h
+++ b/icu4c/source/test/intltest/itrbnf.h
@@ -102,6 +102,11 @@
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
*/
void TestSwedishSpellout();
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 c062f5e..e797325 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
@@ -821,6 +821,35 @@
}
@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()
{
Locale locale = new Locale("sv", "", "");