[libcxx-commits] [PATCH] D120547: [libcxx] [test] Fix the monetary locale curr_symbol test on Windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 25 01:31:25 PST 2022


mstorsjo created this revision.
mstorsjo added reviewers: Quuxplusone, Mordante.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120547

Files:
  libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp


Index: libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
===================================================================
--- libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
+++ libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -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
@@ -86,22 +84,32 @@
     }
 #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
 
@@ -134,6 +142,8 @@
           assert(f.curr_symbol() == " \u20BD");
         else
           assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
+#elif defined(_WIN32)
+        assert(f.curr_symbol() == " \u20BD");
 #else
         assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
 #endif
@@ -150,6 +160,8 @@
           assert(f.curr_symbol() == L" \u20BD");
         else
           assert(f.curr_symbol() == L" \x440\x443\x431");
+#elif defined(_WIN32)
+        assert(f.curr_symbol() == L" \u20BD");
 #else
         assert(f.curr_symbol() == L" \x440\x443\x431");
 #endif
@@ -163,20 +175,28 @@
 
     {
         Fnf f(LOCALE_zh_CN_UTF_8, 1);
+#ifdef _WIN32
+        assert(f.curr_symbol() == "\xC2\xA5");
+#else
         assert(f.curr_symbol() == "\xEF\xBF\xA5");
+#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);
+#ifdef _WIN32
+        assert(f.curr_symbol() == L"\x00A5");
+#else
         assert(f.curr_symbol() == L"\xFFE5");
+#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
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120547.411348.patch
Type: text/x-patch
Size: 2788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220225/3ce41529/attachment.bin>


More information about the libcxx-commits mailing list