strfmon_test: Add a test for strfmon_l
Attempt to test the correctness of strfmon_l(3). Items marked with XXX represent an invalid output. Obtained from: https://github.com/NetBSD/src/commit/e7eba0044fe6128291cbb7e5923c7cf7d87318cc Reviewed by: kib PR: 267410 Github PR: #620 MFC after: 1 week
This commit is contained in:
committed by
Konstantin Belousov
parent
edcee003e5
commit
29972f06f9
@@ -211,6 +211,38 @@ ATF_TC_BODY(strfmon_international_currency_code, tc)
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC(strfmon_l);
|
||||
ATF_TC_HEAD(strfmon_l, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"checks strfmon_l under different locales");
|
||||
}
|
||||
ATF_TC_BODY(strfmon_l, tc)
|
||||
{
|
||||
const struct {
|
||||
const char *locale;
|
||||
const char *expected;
|
||||
} tests[] = {
|
||||
{ "C", "[ **1234.57 ] [ **1234.57 ]" },
|
||||
{ "de_DE.UTF-8", "[ €**1234.57 ] [ EUR**1234.57 ]" }, /* XXX */
|
||||
{ "en_GB.UTF-8", "[ £**1234.57 ] [ GBP**1234.57 ]" }, /* XXX */
|
||||
};
|
||||
locale_t loc;
|
||||
size_t i;
|
||||
char buf[100];
|
||||
|
||||
for (i = 0; i < nitems(tests); ++i) {
|
||||
loc = newlocale(LC_MONETARY_MASK, tests[i].locale, NULL);
|
||||
ATF_REQUIRE(loc != NULL);
|
||||
|
||||
strfmon_l(buf, sizeof(buf) - 1, loc, "[%^=*#6n] [%=*#6i]",
|
||||
1234.567, 1234.567);
|
||||
ATF_REQUIRE_STREQ(tests[i].expected, buf);
|
||||
|
||||
freelocale(loc);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, strfmon_locale_thousands);
|
||||
@@ -218,5 +250,6 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, strfmon_cs_precedes_0);
|
||||
ATF_TP_ADD_TC(tp, strfmon_cs_precedes_1);
|
||||
ATF_TP_ADD_TC(tp, strfmon_international_currency_code);
|
||||
ATF_TP_ADD_TC(tp, strfmon_l);
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user