[libcxx] [test] Fix moneypunct grouping tests on Windows

For grouping strings, "\3" and "\3\3" are equivalent.

Differential Revision: https://reviews.llvm.org/D120091
This commit is contained in:
Martin Storsjö 2022-01-18 09:33:08 +00:00
parent 9f8cb68570
commit 865c7ab421
2 changed files with 27 additions and 12 deletions

View File

@ -11,8 +11,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
// XFAIL: LIBCXX-WINDOWS-FIXME
// REQUIRES: locale.en_US.UTF-8
// REQUIRES: locale.fr_FR.UTF-8
// REQUIRES: locale.ru_RU.UTF-8
@ -89,22 +87,27 @@ int main(int, char**)
}
#endif
#ifdef _WIN32
std::string us_grouping = "\3";
#else
std::string us_grouping = "\3\3";
#endif
{
Fnf f(LOCALE_en_US_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == us_grouping);
}
{
Fnt f(LOCALE_en_US_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == us_grouping);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
Fwf f(LOCALE_en_US_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == us_grouping);
}
{
Fwt f(LOCALE_en_US_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == us_grouping);
}
#endif
@ -127,22 +130,27 @@ int main(int, char**)
}
#endif
#ifdef _WIN32
std::string ru_grouping = "\3";
#else
std::string ru_grouping = "\3\3";
#endif
{
Fnf f(LOCALE_ru_RU_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == ru_grouping);
}
{
Fnt f(LOCALE_ru_RU_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == ru_grouping);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
Fwf f(LOCALE_ru_RU_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == ru_grouping);
}
{
Fwt f(LOCALE_ru_RU_UTF_8, 1);
assert(f.grouping() == "\3\3");
assert(f.grouping() == ru_grouping);
}
#endif

View File

@ -9,7 +9,6 @@
// NetBSD does not support LC_NUMERIC at the moment
// XFAIL: netbsd
// XFAIL: LIBCXX-WINDOWS-FIXME
// XFAIL: LIBCXX-AIX-FIXME
// REQUIRES: locale.en_US.UTF-8
@ -49,19 +48,27 @@ int main(int, char**)
{
typedef char C;
const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
#ifdef _WIN32
assert(np.grouping() == "\3");
#else
assert(np.grouping() == "\3\3");
#endif
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef wchar_t C;
const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
#ifdef _WIN32
assert(np.grouping() == "\3");
#else
assert(np.grouping() == "\3\3");
#endif
}
#endif
}
{
std::locale l(LOCALE_fr_FR_UTF_8);
#if defined(TEST_HAS_GLIBC)
#if defined(TEST_HAS_GLIBC) || defined(_WIN32)
const char* const group = "\3";
#else
const char* const group = "\x7f";