[libcxx-commits] [libcxx] bcee450 - [libcxx] [test] Fix the thousands_sep expectation for fr_FR locales on Windows
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 21 13:09:35 PST 2022
Author: Martin Storsjö
Date: 2022-02-21T23:08:56+02:00
New Revision: bcee450937061139de4f75b4deaa06dee69aaf25
URL: https://github.com/llvm/llvm-project/commit/bcee450937061139de4f75b4deaa06dee69aaf25
DIFF: https://github.com/llvm/llvm-project/commit/bcee450937061139de4f75b4deaa06dee69aaf25.diff
LOG: [libcxx] [test] Fix the thousands_sep expectation for fr_FR locales on Windows
Windows uses U+00A0 NO-BREAK SPACE as thousands separator in the
fr_FR locale.
Differential Revision: https://reviews.llvm.org/D120090
Added:
Modified:
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
index b90677d854de8..16fc12feac62b 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -11,7 +11,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
-// XFAIL: LIBCXX-WINDOWS-FIXME
// XFAIL: LIBCXX-AIX-FIXME
// REQUIRES: locale.fr_FR.UTF-8
@@ -53,11 +52,12 @@ class my_facetw
: Fw(refs) {}
};
-// GLIBC 2.27 and newer use U2027 (narrow non-breaking space) as a thousands sep.
-// this function converts the spaces in string inputs to that character if need
-// be. FreeBSD's locale data also uses U2027 since 2018.
+// GLIBC 2.27 and newer use U+202F NARROW NO-BREAK SPACE as a thousands separator.
+// This function converts the spaces in string inputs to U+202F if need
+// be. FreeBSD's locale data also uses U+202F, since 2018.
+// Windows uses U+00A0 NO-BREAK SPACE.
static std::wstring convert_thousands_sep(std::wstring const& in) {
-#if defined(_CS_GNU_LIBC_VERSION) || defined(__FreeBSD__)
+#if defined(_CS_GNU_LIBC_VERSION) || defined(__FreeBSD__) || defined(_WIN32)
#if defined(_CS_GNU_LIBC_VERSION)
if (glibc_version_less_than("2.27"))
return in;
@@ -72,7 +72,11 @@ static std::wstring convert_thousands_sep(std::wstring const& in) {
continue;
}
assert(in[I] == L' ');
+#if defined(_WIN32)
+ out.push_back(L'\u00A0');
+#else
out.push_back(L'\u202F');
+#endif
}
return out;
#else
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
index 492ad1379e2ac..becb46e091590 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -11,7 +11,6 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
-// XFAIL: LIBCXX-WINDOWS-FIXME
// XFAIL: LIBCXX-AIX-FIXME
// REQUIRES: locale.fr_FR.UTF-8
@@ -53,11 +52,12 @@ class my_facetw
: Fw(refs) {}
};
-// GLIBC 2.27 and newer use U2027 (narrow non-breaking space) as a thousands sep.
-// this function converts the spaces in string inputs to that character if need
-// be. FreeBSD's locale data also uses U2027 since 2018.
+// GLIBC 2.27 and newer use U+202F NARROW NO-BREAK SPACE as a thousands separator.
+// This function converts the spaces in string inputs to U+202F if need
+// be. FreeBSD's locale data also uses U+202F, since 2018.
+// Windows uses U+00A0 NO-BREAK SPACE.
static std::wstring convert_thousands_sep(std::wstring const& in) {
-#if defined(_CS_GNU_LIBC_VERSION) || defined(__FreeBSD__)
+#if defined(_CS_GNU_LIBC_VERSION) || defined(__FreeBSD__) || defined(_WIN32)
#if defined(_CS_GNU_LIBC_VERSION)
if (glibc_version_less_than("2.27"))
return in;
@@ -74,7 +74,11 @@ static std::wstring convert_thousands_sep(std::wstring const& in) {
continue;
}
assert(in[I] == L' ');
+#if defined(_WIN32)
+ out.push_back(L'\u00A0');
+#else
out.push_back(L'\u202F');
+#endif
}
return out;
#else
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
index 4953625916485..17f25d78f0b1c 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -9,8 +9,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
@@ -114,6 +112,8 @@ int main(int, char**)
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
#if defined(_CS_GNU_LIBC_VERSION)
const wchar_t fr_sep = glibc_version_less_than("2.27") ? L' ' : L'\u202F';
+#elif defined(_WIN32)
+ const wchar_t fr_sep = L'\u00A0';
#else
const wchar_t fr_sep = L' ';
#endif
@@ -144,6 +144,8 @@ int main(int, char**)
// FIXME libc++ specifically works around \u00A0 by translating it into
// a regular space.
const wchar_t wsep = glibc_version_less_than("2.27") ? L'\u00A0' : L'\u202F';
+# elif defined(_WIN32)
+ const wchar_t wsep = L'\u00A0';
# else
const wchar_t wsep = L' ';
# endif
diff --git a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
index 3e82e9f81b92b..b3539880253be 100644
--- a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -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
@@ -64,7 +63,7 @@ int main(int, char**)
// The below tests work around GLIBC's use of U202F as LC_NUMERIC thousands_sep.
std::locale l(LOCALE_fr_FR_UTF_8);
{
-#if defined(_CS_GNU_LIBC_VERSION)
+#if defined(_CS_GNU_LIBC_VERSION) || defined(_WIN32)
const char sep = ' ';
#else
const char sep = ',';
@@ -77,6 +76,8 @@ int main(int, char**)
{
#if defined(_CS_GNU_LIBC_VERSION)
const wchar_t wsep = glibc_version_less_than("2.27") ? L' ' : L'\u202f';
+#elif defined(_WIN32)
+ const wchar_t wsep = L'\u00A0';
#else
const wchar_t wsep = L',';
#endif
More information about the libcxx-commits
mailing list