[libcxx-commits] [PATCH] D119790: [libcxx] [test] Fix the locale get_one_wide test for windows and glibc

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 17 00:55:19 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf081cc50372f: [libcxx] [test] Fix the locale get_one_wide test for windows and glibc (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119790/new/

https://reviews.llvm.org/D119790

Files:
  libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp


Index: libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
===================================================================
--- libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
+++ libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
@@ -9,8 +9,6 @@
 // NetBSD does not support LC_TIME at the moment
 // XFAIL: netbsd
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // XFAIL: libcpp-has-no-wide-characters
 
 // REQUIRES: locale.en_US.UTF-8
@@ -25,9 +23,6 @@
 // iter_type get(iter_type s, iter_type end, ios_base& f,
 //               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
 
-// TODO: investigation needed
-// XFAIL: target={{.*}}-linux-gnu{{.*}}
-
 #include <locale>
 #include <cassert>
 #include "test_macros.h"
@@ -54,7 +49,15 @@
     std::tm t;
     {
         const my_facet f(LOCALE_en_US_UTF_8, 1);
+#ifdef _WIN32
+        // On Windows, the "%c" format lacks the leading week day, which
+        // means that t.tm_wday doesn't get set when parsing the string.
+        const wchar_t in[] = L"12/31/2061 11:55:59 PM";
+#elif defined(TEST_HAS_GLIBC)
+        const wchar_t in[] = L"Sat 31 Dec 2061 11:55:59 PM";
+#else
         const wchar_t in[] = L"Sat Dec 31 23:55:59 2061";
+#endif
         err = std::ios_base::goodbit;
         t = std::tm();
         I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
@@ -65,12 +68,18 @@
         assert(t.tm_mday == 31);
         assert(t.tm_mon == 11);
         assert(t.tm_year == 161);
+#ifndef _WIN32
         assert(t.tm_wday == 6);
+#endif
         assert(err == std::ios_base::eofbit);
     }
     {
         const my_facet f(LOCALE_en_US_UTF_8, 1);
+#if defined(_WIN32) || defined(TEST_HAS_GLIBC)
+        const wchar_t in[] = L"11:55:59 PM";
+#else
         const wchar_t in[] = L"23:55:59";
+#endif
         err = std::ios_base::goodbit;
         t = std::tm();
         I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
@@ -82,7 +91,13 @@
     }
     {
         const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+#ifdef _WIN32
+        const wchar_t in[] = L"31/12/2061 23:55:59";
+#elif defined(TEST_HAS_GLIBC)
+        const wchar_t in[] = L"sam. 31 d" L"\xE9" L"c. 2061 23:55:59";
+#else
         const wchar_t in[] = L"Sam 31 d" L"\xE9" L"c 23:55:59 2061";
+#endif
         err = std::ios_base::goodbit;
         t = std::tm();
         I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
@@ -93,7 +108,9 @@
         assert(t.tm_mday == 31);
         assert(t.tm_mon == 11);
         assert(t.tm_year == 161);
+#ifndef _WIN32
         assert(t.tm_wday == 6);
+#endif
         assert(err == std::ios_base::eofbit);
     }
     {
@@ -164,7 +181,11 @@
 #endif
     {
         const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+#ifdef _WIN32
+        const wchar_t in[] = L"23:55:59";
+#else
         const wchar_t in[] = L"23" L"\x65F6" L"55" L"\x5206" L"59" L"\x79D2";
+#endif
         err = std::ios_base::goodbit;
         t = std::tm();
         I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119790.409517.patch
Type: text/x-patch
Size: 3221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220217/e6460d49/attachment-0001.bin>


More information about the libcxx-commits mailing list