ICU-20396 add RelativeDateTimeFormatter test for af

This commit is contained in:
Peter Edberg 2019-08-28 00:47:34 -07:00 committed by pedberg-icu
parent 7814980f51
commit c98e90c670

View file

@ -746,6 +746,26 @@ static WithQuantityExpectedRelativeDateTimeUnit kEnglishFormat[] = {
{-2.0, UDAT_REL_UNIT_SATURDAY, "2 Saturdays ago"}
};
static WithQuantityExpected kAfrikaans[] = {
{1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "oor 1 maand"},
{2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "oor 2 maande"},
{1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 maand gelede"},
{2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 maande gelede"},
};
static WithoutQuantityExpected kAfrikaansNoQuantity[] = {
{UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "volgende maand"},
{UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "verlede maand"},
};
static WithQuantityExpectedRelativeDateTimeUnit kAfrikaansFormatNumeric[] = {
{0.0, UDAT_REL_UNIT_MONTH, "oor 0 maande"},
{1.0, UDAT_REL_UNIT_MONTH, "oor 1 maand"},
{2.0, UDAT_REL_UNIT_MONTH, "oor 2 maande"},
{-0.0, UDAT_REL_UNIT_MONTH, "0 maande gelede"},
{-1.0, UDAT_REL_UNIT_MONTH, "1 maand gelede"},
{-2.0, UDAT_REL_UNIT_MONTH, "2 maande gelede"},
};
class RelativeDateTimeFormatterTest : public IntlTestWithFieldPosition {
public:
@ -765,6 +785,7 @@ private:
void TestEnglishNoQuantityShort();
void TestEnglishNoQuantityNarrow();
void TestSpanishNoQuantity();
void TestAfrikaans();
void TestFormatWithQuantityIllegalArgument();
void TestFormatWithoutQuantityIllegalArgument();
void TestCustomNumberFormat();
@ -857,6 +878,7 @@ void RelativeDateTimeFormatterTest::runIndexedTest(
TESTCASE_AUTO(TestEnglishNoQuantityShort);
TESTCASE_AUTO(TestEnglishNoQuantityNarrow);
TESTCASE_AUTO(TestSpanishNoQuantity);
TESTCASE_AUTO(TestAfrikaans);
TESTCASE_AUTO(TestFormatWithQuantityIllegalArgument);
TESTCASE_AUTO(TestFormatWithoutQuantityIllegalArgument);
TESTCASE_AUTO(TestCustomNumberFormat);
@ -955,6 +977,12 @@ void RelativeDateTimeFormatterTest::TestSpanishNoQuantity() {
RunTest("es", kSpanishNoQuantity, UPRV_LENGTHOF(kSpanishNoQuantity));
}
void RelativeDateTimeFormatterTest::TestAfrikaans() {
RunTest("af", kAfrikaans, UPRV_LENGTHOF(kAfrikaans));
RunTest("af", kAfrikaansNoQuantity, UPRV_LENGTHOF(kAfrikaansNoQuantity));
RunTest("af", kAfrikaansFormatNumeric, UPRV_LENGTHOF(kAfrikaansFormatNumeric), true);
}
void RelativeDateTimeFormatterTest::TestFormatWithQuantityIllegalArgument() {
UErrorCode status = U_ZERO_ERROR;
RelativeDateTimeFormatter fmt("en", status);