[libcxx-commits] [libcxx] 1521162 - [libcxx] [test] Fix the monetary locale curr_symbol test on Windows, Apple and FreeBSD
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Feb 28 13:41:44 PST 2022
Author: Martin Storsjö
Date: 2022-02-28T23:41:14+02:00
New Revision: 1521162d788a297531e18ddb8cf9a901ac8689a2
URL: https://github.com/llvm/llvm-project/commit/1521162d788a297531e18ddb8cf9a901ac8689a2
DIFF: https://github.com/llvm/llvm-project/commit/1521162d788a297531e18ddb8cf9a901ac8689a2.diff
LOG: [libcxx] [test] Fix the monetary locale curr_symbol test on Windows, Apple and FreeBSD
International currency symbols (like USD, EUR) are returned with a
trailing space, like "USD ", on previously supported Unix platforms.
On Windows, the locales return them without a trailing space.
Also adjust the test for expecting a different unicode sequence for
the national currency symbol for ru_RU.UTF-8 and zh_CN.UTF-8.
Differential Revision: https://reviews.llvm.org/D120547
Added:
Modified:
libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
index 99c509776fd31..407a08884c3d8 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -6,13 +6,9 @@
//
//===----------------------------------------------------------------------===//
//
-// XFAIL: darwin
-//
// 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
@@ -86,28 +82,42 @@ int main(int, char**)
}
#endif
+#ifdef _WIN32
+ std::string curr_space = "";
+#else
+ std::string curr_space = " ";
+#endif
{
Fnf f(LOCALE_en_US_UTF_8, 1);
assert(f.curr_symbol() == "$");
}
{
Fnt f(LOCALE_en_US_UTF_8, 1);
- assert(f.curr_symbol() == "USD ");
+ assert(f.curr_symbol() == "USD" + curr_space);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#ifdef _WIN32
+ std::wstring w_curr_space = L"";
+#else
+ std::wstring w_curr_space = L" ";
+#endif
{
Fwf f(LOCALE_en_US_UTF_8, 1);
assert(f.curr_symbol() == L"$");
}
{
Fwt f(LOCALE_en_US_UTF_8, 1);
- assert(f.curr_symbol() == L"USD ");
+ assert(f.curr_symbol() == L"USD" + w_curr_space);
}
#endif
{
Fnf f(LOCALE_fr_FR_UTF_8, 1);
+#ifdef __APPLE__
+ assert(f.curr_symbol() == " Eu");
+#else
assert(f.curr_symbol() == " \u20ac");
+#endif
}
{
Fnt f(LOCALE_fr_FR_UTF_8, 1);
@@ -116,7 +126,11 @@ int main(int, char**)
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
Fwf f(LOCALE_fr_FR_UTF_8, 1);
+#ifdef __APPLE__
+ assert(f.curr_symbol() == L" Eu");
+#else
assert(f.curr_symbol() == L" \u20ac");
+#endif
}
{
Fwt f(LOCALE_fr_FR_UTF_8, 1);
@@ -131,11 +145,13 @@ int main(int, char**)
// GLIBC >= 2.24 uses currency_symbol="<U20BD>"
// See also: http://www.fileformat.info/info/unicode/char/20bd/index.htm
if (!glibc_version_less_than("2.24"))
- assert(f.curr_symbol() == " \u20BD");
+ assert(f.curr_symbol() == " \xE2\x82\xBD"); // \u20BD
else
- assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
+ assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1"); // \u0440\u0443\u0431
+#elif defined(_WIN32) || defined(__FreeBSD__)
+ assert(f.curr_symbol() == " \xE2\x82\xBD"); // \u20BD
#else
- assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
+ assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1."); // \u0440\u0443\u0431.
#endif
}
{
@@ -149,9 +165,11 @@ int main(int, char**)
if (!glibc_version_less_than("2.24"))
assert(f.curr_symbol() == L" \u20BD");
else
- assert(f.curr_symbol() == L" \x440\x443\x431");
+ assert(f.curr_symbol() == L" \u0440\u0443\u0431");
+#elif defined(_WIN32) || defined(__FreeBSD__)
+ assert(f.curr_symbol() == L" \u20BD");
#else
- assert(f.curr_symbol() == L" \x440\x443\x431");
+ assert(f.curr_symbol() == L" \u0440\u0443\u0431.");
#endif
}
@@ -163,20 +181,28 @@ int main(int, char**)
{
Fnf f(LOCALE_zh_CN_UTF_8, 1);
- assert(f.curr_symbol() == "\xEF\xBF\xA5");
+#ifdef _WIN32
+ assert(f.curr_symbol() == "\xC2\xA5"); // \u00A5
+#else
+ assert(f.curr_symbol() == "\xEF\xBF\xA5"); // \uFFE5
+#endif
}
{
Fnt f(LOCALE_zh_CN_UTF_8, 1);
- assert(f.curr_symbol() == "CNY ");
+ assert(f.curr_symbol() == "CNY" + curr_space);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
Fwf f(LOCALE_zh_CN_UTF_8, 1);
- assert(f.curr_symbol() == L"\xFFE5");
+#ifdef _WIN32
+ assert(f.curr_symbol() == L"\u00A5");
+#else
+ assert(f.curr_symbol() == L"\uFFE5");
+#endif
}
{
Fwt f(LOCALE_zh_CN_UTF_8, 1);
- assert(f.curr_symbol() == L"CNY ");
+ assert(f.curr_symbol() == L"CNY" + w_curr_space);
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
More information about the libcxx-commits
mailing list