ICU-21480 brs 69rc, add tests to verify that rbnf spellout is the same for no,nb

This commit is contained in:
Peter Edberg 2021-03-09 16:36:07 -08:00 committed by Peter Edberg
parent 54b896962b
commit 6cdfe2dc1f
3 changed files with 67 additions and 0 deletions
icu4c/source/test/intltest
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format

View file

@ -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()
{

View file

@ -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
*/

View file

@ -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()
{