[libcxx] [test] Fix the monetary locale negative_sign test for en_US.UTF-8 on Windows
authorMartin Storsjö <martin@martin.st>
Thu, 13 Jan 2022 13:02:16 +0000 (13:02 +0000)
committerMartin Storsjö <martin@martin.st>
Fri, 25 Feb 2022 21:41:35 +0000 (23:41 +0200)
On Windows, the en_US.UTF-8 locale returns `n_sign_posn == 0`, which
means that the sign for a negative currency is parentheses around
the whole value, instead of a leading minus.

Differential Revision: https://reviews.llvm.org/D120549

libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp

index 11904d3..be2f558 100644 (file)
@@ -11,8 +11,6 @@
 // REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // <locale>
 
 // class moneypunct_byname<charT, International>
@@ -83,20 +81,36 @@ int main(int, char**)
 
     {
         Fnf f(LOCALE_en_US_UTF_8, 1);
+#if defined(_WIN32)
+        assert(f.negative_sign() == "()");
+#else
         assert(f.negative_sign() == "-");
+#endif
     }
     {
         Fnt f(LOCALE_en_US_UTF_8, 1);
+#if defined(_WIN32)
+        assert(f.negative_sign() == "()");
+#else
         assert(f.negative_sign() == "-");
+#endif
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
         Fwf f(LOCALE_en_US_UTF_8, 1);
+#if defined(_WIN32)
+        assert(f.negative_sign() == L"()");
+#else
         assert(f.negative_sign() == L"-");
+#endif
     }
     {
         Fwt f(LOCALE_en_US_UTF_8, 1);
+#if defined(_WIN32)
+        assert(f.negative_sign() == L"()");
+#else
         assert(f.negative_sign() == L"-");
+#endif
     }
 #endif