[libcxx-commits] [libcxx] 6efda5e - [libcxx] [test] Fix the locale ctype widen tests on Windows

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 5 10:07:52 PDT 2022


Author: Martin Storsjö
Date: 2022-04-05T20:06:44+03:00
New Revision: 6efda5e6d6531ced6e35ccb3f6499ca13b8edb60

URL: https://github.com/llvm/llvm-project/commit/6efda5e6d6531ced6e35ccb3f6499ca13b8edb60
DIFF: https://github.com/llvm/llvm-project/commit/6efda5e6d6531ced6e35ccb3f6499ca13b8edb60.diff

LOG: [libcxx] [test] Fix the locale ctype widen tests on Windows

On Windows, like on macOS and FreeBSD, widening char(-5) in the
"C" locale succeeds and produces L'\u00fb'.

Switch widen_many to test \xfb instead of \x85; the mingw
version of btowc widens \x85 in the "C" locale into
\u2026 (which is the corresponding character according to the
Windows-1252 codepage), while Microsoft CRT's btowc widens it
into \u0085 (just like macOS and FreeBSD). Switch this to test \xfb
which is the character tested by the widen_1 test (as `char(-5)`),
which gets handled the same by all Windows implementations of btowc.

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

Added: 
    

Modified: 
    libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
    libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
index 4149764c93f30..6ecf65278be35 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: locale.en_US.UTF-8
-// XFAIL: LIBCXX-WINDOWS-FIXME
 // XFAIL: LIBCXX-AIX-FIXME
 // XFAIL: libcpp-has-no-wide-characters
 
@@ -58,7 +57,7 @@ int main(int, char**)
             assert(f.widen('.') == L'.');
             assert(f.widen('a') == L'a');
             assert(f.widen('1') == L'1');
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32)
             assert(f.widen(char(-5)) == L'\u00fb');
 #else
             assert(f.widen(char(-5)) == wchar_t(-1));

diff  --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
index 56051f18ef2f8..38157de78731c 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: locale.en_US.UTF-8
-// XFAIL: LIBCXX-WINDOWS-FIXME
 // XFAIL: LIBCXX-AIX-FIXME
 // XFAIL: libcpp-has-no-wide-characters
 
@@ -35,7 +34,7 @@ int main(int, char**)
             typedef std::ctype_byname<wchar_t> F;
             std::locale ll(l, new F(LOCALE_en_US_UTF_8));
             F const& f = std::use_facet<F>(ll);
-            std::string in(" A\x07.a1\x85");
+            std::string in(" A\x07.a1\xfb");
             std::vector<wchar_t> v(in.size());
 
             assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
@@ -54,7 +53,7 @@ int main(int, char**)
             typedef std::ctype_byname<wchar_t> F;
             std::locale ll(l, new F("C"));
             const F& f = std::use_facet<F>(ll);
-            std::string in(" A\x07.a1\x85");
+            std::string in(" A\x07.a1\xfb");
             std::vector<wchar_t> v(in.size());
 
             assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
@@ -64,8 +63,8 @@ int main(int, char**)
             assert(v[3] == L'.');
             assert(v[4] == L'a');
             assert(v[5] == L'1');
-#if defined(__APPLE__) || defined(__FreeBSD__)
-            assert(v[6] == L'\x85');
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32)
+            assert(v[6] == L'\xfb');
 #else
             assert(v[6] == wchar_t(-1));
 #endif


        


More information about the libcxx-commits mailing list