[libcxx-commits] [libcxx] f081cc5 - [libcxx] [test] Fix the locale get_one_wide test for windows and glibc

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


Author: Martin Storsjö
Date: 2022-02-17T10:54:18+02:00
New Revision: f081cc50372f9415ef4fa2204a4b7f54153af455

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

LOG: [libcxx] [test] Fix the locale get_one_wide test for windows and glibc

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
index c762f970016ba..3aac42048ee41 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
+++ b/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 @@ int main(int, char**)
     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 @@ int main(int, char**)
         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 @@ int main(int, char**)
     }
     {
         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 @@ int main(int, char**)
         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 @@ int main(int, char**)
 #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');


        


More information about the libcxx-commits mailing list