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

Differential Revision: https://reviews.llvm.org/D119790
This commit is contained in:
Martin Storsjö 2022-01-25 10:32:55 +00:00
parent 77c7ce0384
commit f081cc5037
1 changed files with 26 additions and 5 deletions

View File

@ -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');