Skip to content

Commit

Permalink
[libcxx] [test] Fix moneypunct grouping tests on Windows
Browse files Browse the repository at this point in the history
For grouping strings, "\3" and "\3\3" are equivalent.

Differential Revision: https://reviews.llvm.org/D120091
  • Loading branch information
mstorsjo committed Feb 21, 2022
1 parent 9f8cb68 commit 865c7ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 865c7ab

Please sign in to comment.