diff --git a/libcxx/include/__format/unicode.h b/libcxx/include/__format/unicode.h --- a/libcxx/include/__format/unicode.h +++ b/libcxx/include/__format/unicode.h @@ -87,17 +87,15 @@ } // https://www.unicode.org/glossary/#surrogate_code_point -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool __is_surrogate(char32_t __value) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate(char32_t __value) { return __value >= 0xd800 && __value <= 0xdfff; } // https://www.unicode.org/glossary/#code_point -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool __is_code_point(char32_t __value) { - return __value <= 0x10ffff; -} +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __is_code_point(char32_t __value) { return __value <= 0x10ffff; } // https://www.unicode.org/glossary/#unicode_scalar_value -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool __is_scalar_value(char32_t __value) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __is_scalar_value(char32_t __value) { return __unicode::__is_code_point(__value) && !__unicode::__is_surrogate(__value); } diff --git a/libcxx/test/std/time/time.syn/formatter.hh_mm_ss.pass.cpp b/libcxx/test/std/time/time.syn/formatter.hh_mm_ss.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.hh_mm_ss.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.hh_mm_ss.pass.cpp @@ -9,9 +9,6 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // XFAIL: LIBCXX-FREEBSD-FIXME // XFAIL: availability-fp_to_chars-missing @@ -293,7 +290,7 @@ std::chrono::hh_mm_ss(std::chrono::duration(3661.123456))); // Use supplied locale (ja_JP). This locale has a different alternate. -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='00'\t" @@ -314,6 +311,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -343,6 +344,10 @@ "%r='11:31:30 PM'\t" "%X='23時31分30秒'\t" "%EX='23時31分30秒'\t" +# elif defined(_WIN32) + "%r='23:31:30'\t" + "%X='23:31:30'\t" + "%EX='23:31:30'\t" # else "%r='午後11:31:30'\t" "%X='23:31:30'\t" @@ -372,6 +377,10 @@ "%r='03:02:01 AM'\t" "%X='03時02分01秒'\t" "%EX='03時02分01秒'\t" +# elif defined(_WIN32) + "%r='3:02:01'\t" + "%X='3:02:01'\t" + "%EX='3:02:01'\t" # else "%r='午前03:02:01'\t" "%X='03:02:01'\t" @@ -401,6 +410,10 @@ "%r='01:01:01 AM'\t" "%X='01時01分01秒'\t" "%EX='01時01分01秒'\t" +# elif defined(_WIN32) + "%r='1:01:01'\t" + "%X='1:01:01'\t" + "%EX='1:01:01'\t" # else "%r='午前01:01:01'\t" "%X='01:01:01'\t" @@ -409,7 +422,7 @@ "\n"), lfmt, std::chrono::hh_mm_ss(std::chrono::duration(3661.123456))); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='〇'\t" @@ -486,7 +499,7 @@ "\n"), lfmt, std::chrono::hh_mm_ss(std::chrono::duration(3661.123456))); -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } diff --git a/libcxx/test/std/time/time.syn/formatter.day.pass.cpp b/libcxx/test/std/time/time.syn/formatter.day.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.day.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.day.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -64,41 +64,59 @@ std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); // Non localized output using C-locale +#if defined(_WIN32) + check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 0d); +#else check(SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), fmt, 0d); +#endif check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), fmt, 1d); check(SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), fmt, 31d); -#if defined(_AIX) +#if defined(_WIN32) + check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 0d); +#elif defined(_AIX) check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), fmt, 255d); #else check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), fmt, 255d); #endif // Use the global locale (fr_FR) +#if defined(_WIN32) + check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 0d); +#else check(SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), lfmt, 0d); +#endif check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), lfmt, 1d); check(SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), lfmt, 31d); -#if defined(_AIX) +#if defined(_WIN32) + check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 255d); +#elif defined(_AIX) check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), lfmt, 255d); #else check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), lfmt, 255d); #endif // Use supplied locale (ja_JP). This locale has a different alternate on some platforms. -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) +# if defined(_WIN32) + check(loc, SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 0d); +# else check(loc, SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), lfmt, 0d); +# endif check(loc, SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), lfmt, 1d); check(loc, SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), lfmt, 31d); -# if defined(_AIX) +# if defined(_WIN32) + check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 255d); +# elif defined(_AIX) check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), fmt, 255d); # else check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), fmt, 255d); # endif -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%d='00'\t%Od='〇'\t%e=' 0'\t%Oe='〇'\n"), lfmt, 0d); check(loc, SV("%d='01'\t%Od='一'\t%e=' 1'\t%Oe='一'\n"), lfmt, 1d); check(loc, SV("%d='31'\t%Od='三十一'\t%e='31'\t%Oe='三十一'\n"), lfmt, 31d); check(loc, SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), lfmt, 255d); -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } diff --git a/libcxx/test/std/time/time.syn/formatter.duration.pass.cpp b/libcxx/test/std/time/time.syn/formatter.duration.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.duration.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.duration.pass.cpp @@ -11,9 +11,6 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // XFAIL: availability-fp_to_chars-missing // REQUIRES: locale.fr_FR.UTF-8 @@ -247,7 +244,7 @@ "%R='00:00'\t" "%T='00:00:00'\t" #ifdef _WIN32 - "%r='12:00:00'\t" + "%r='00:00:00'\t" #elif defined(_AIX) "%r='12:00:00 AM'\t" #elif defined(__APPLE__) @@ -313,7 +310,7 @@ "%R='12:00'\t" "%T='12:00:00'\t" #ifdef _WIN32 - "%r='00:00:00'\t" + "%r='12:00:00'\t" #elif defined(_AIX) "%r='12:00:00 PM'\t" #elif defined(__APPLE__) @@ -349,6 +346,8 @@ "%r='11:59:59 PM'\t" #elif defined(__APPLE__) "%r=''\t" +#elif defined(_WIN32) + "%r='23:59:59'\t" #else "%r='11:59:59 '\t" #endif @@ -377,11 +376,13 @@ "%R='00:00'\t" "%T='00:00:00'\t" #ifdef _WIN32 - "%r='12:00:00'\t" + "%r='00:00:00'\t" #elif defined(_AIX) "%r='12:00:00 AM'\t" #elif defined(__APPLE__) "%r=''\t" +#elif defined(_WIN32) + "%r='12:00:00'\t" #else "%r='12:00:00 '\t" #endif @@ -395,7 +396,7 @@ std::chrono::duration>(7)); // Use supplied locale (ja_JP). This locale has a different alternate. -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='00'\t" @@ -416,6 +417,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -448,6 +453,10 @@ "%r='11:59:59 AM'\t" "%X='11時59分59秒'\t" "%EX='11時59分59秒'\t" +# elif defined(_WIN32) + "%r='11:59:59'\t" + "%X='11:59:59'\t" + "%EX='11:59:59'\t" # else "%r='午前11:59:59'\t" "%X='11:59:59'\t" @@ -481,7 +490,11 @@ "%X='12時00分00秒'\t" "%EX='12時00分00秒'\t" # else +# ifdef _WIN32 + "%r='12:00:00'\t" +# else "%r='午後12:00:00'\t" +# endif "%X='12:00:00'\t" "%EX='12:00:00'\t" # endif @@ -513,7 +526,11 @@ "%X='23時59分59秒'\t" "%EX='23時59分59秒'\t" # else +# ifdef _WIN32 + "%r='23:59:59'\t" +# else "%r='午後11:59:59'\t" +# endif "%X='23:59:59'\t" "%EX='23:59:59'\t" # endif @@ -544,6 +561,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -555,7 +576,7 @@ "\n"), lfmt, std::chrono::duration>(7)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='〇'\t" @@ -665,8 +686,8 @@ "\n"), lfmt, std::chrono::duration>(7)); +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) -#endif // defined(__APPLE__) || defined(_AIX) std::locale::global(std::locale::classic()); } @@ -767,6 +788,8 @@ "%r='11:59:59 PM'\t" #elif defined(__APPLE__) "%r=''\t" +#elif defined(_WIN32) + "%r='23:59:59'\t" #else "%r='11:59:59 '\t" #endif @@ -780,7 +803,7 @@ -(23h + 59min + 59s)); // Use supplied locale (ja_JP). This locale has a different alternate. -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("-%H='23'\t" "%OH='23'\t" @@ -801,6 +824,10 @@ "%r='11:59:59 PM'\t" "%X='23時59分59秒'\t" "%EX='23時59分59秒'\t" +# elif defined(_WIN32) + "%r='23:59:59'\t" + "%X='23:59:59'\t" + "%EX='23:59:59'\t" # else "%r='午後11:59:59'\t" "%X='23:59:59'\t" @@ -812,7 +839,7 @@ "\n"), lfmt, -(23h + 59min + 59s)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("-%H='23'\t" "%OH='二十三'\t" @@ -834,7 +861,7 @@ "\n"), lfmt, -(23h + 59min + 59s)); -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } @@ -987,7 +1014,7 @@ check(loc, SV("00.011"), SV("{:L%S}"), std::chrono::duration(11.123456789)); check(loc, SV("01"), SV("{:L%S}"), std::chrono::duration(61.123456789)); -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(SV("00.000000001"), SV("{:%OS}"), 1ns); check(SV("00.000000501"), SV("{:%OS}"), 501ns); check(SV("00.000001000"), SV("{:%OS}"), 1000ns); @@ -1003,7 +1030,7 @@ check(SV("00.001"), SV("{:%OS}"), std::chrono::duration(1.123456789)); check(SV("00.011"), SV("{:%OS}"), std::chrono::duration(11.123456789)); check(SV("01"), SV("{:%OS}"), std::chrono::duration(61.123456789)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("〇.000000001"), SV("{:L%OS}"), 1ns); check(loc, SV("〇.000000501"), SV("{:L%OS}"), 501ns); check(loc, SV("〇.000001000"), SV("{:L%OS}"), 1000ns); @@ -1019,7 +1046,7 @@ check(loc, SV("〇.001"), SV("{:L%OS}"), std::chrono::duration(1.123456789)); check(loc, SV("〇.011"), SV("{:L%OS}"), std::chrono::duration(11.123456789)); check(loc, SV("一"), SV("{:L%OS}"), std::chrono::duration(61.123456789)); -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("01:05:06.000000001"), SV("{:L%T}"), 1h + 5min + 6s + 1ns); check(loc, SV("01:05:06.000000501"), SV("{:L%T}"), 1h + 5min + 6s + 501ns); diff --git a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp b/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp @@ -14,9 +14,6 @@ // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -245,7 +242,7 @@ lfmt, file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // _WIN32 +#endif // _WIN32 std::locale::global(std::locale::classic()); } @@ -336,7 +333,7 @@ check(SV("%j='138'\n"), lfmt, file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033 // Use supplied locale (ja_JP). This locale has a different alternate. - check(loc, SV("%j='001'\n"), lfmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + check(loc, SV("%j='001'\n"), lfmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 check(loc, SV("%j='138'\n"), lfmt, file_seconds(2'000'000'000s)); // 03:33:20 UTC on Wednesday, 18 May 2033 @@ -641,6 +638,8 @@ "%r='11:31:30 PM'\t" #elif defined(__APPLE__) "%r=''\t" +#elif defined(_WIN32) + "%r='23:31:30 '\t" #else "%r='11:31:30 '\t" #endif @@ -652,7 +651,7 @@ 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 // Use supplied locale (ja_JP). This locale has a different alternate.a -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='00'\t" @@ -673,6 +672,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -702,6 +705,10 @@ "%r='11:31:30 PM'\t" "%X='23時31分30秒'\t" "%EX='23時31分30秒'\t" +# elif defined(_WIN32) + "%r='23:31:30'\t" + "%X='23:31:30'\t" + "%EX='23:31:30'\t" # else "%r='午後11:31:30'\t" "%X='23:31:30'\t" @@ -710,7 +717,7 @@ "\n"), lfmt, std::chrono::hh_mm_ss(23h + 31min + 30s + 123ms)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='〇'\t" @@ -749,7 +756,7 @@ lfmt, std::chrono::sys_time( 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } @@ -782,6 +789,8 @@ SV("%c=' 1 janvier 1970 à 00:00:00 UTC'\t%Ec=' 1 janvier 1970 à 00:00:00 UTC'\n"), #elif defined(__APPLE__) SV("%c='Jeu 1 jan 00:00:00 1970'\t%Ec='Jeu 1 jan 00:00:00 1970'\n"), +#elif defined(_WIN32) + SV("%c='01/01/1970 00:00:00'\t%Ec='01/01/1970 00:00:00'\n"), #else SV("%c='jeu. 01 janv. 1970 00:00:00'\t%Ec='jeu. 01 janv. 1970 00:00:00'\n"), #endif @@ -796,6 +805,8 @@ SV("%c='13 février 2009 à 23:31:30 UTC'\t%Ec='13 février 2009 à 23:31:30 UTC'\n"), #elif defined(__APPLE__) SV("%c='Ven 13 fév 23:31:30 2009'\t%Ec='Ven 13 fév 23:31:30 2009'\n"), +#elif defined(_WIN32) + SV("%c='13/02/2009 23:31:30'\t%Ec='13/02/2009 23:31:30'\n"), #else SV("%c='ven. 13 févr. 2009 23:31:30'\t%Ec='ven. 13 févr. 2009 23:31:30'\n"), #endif @@ -821,6 +832,15 @@ SV("%c='2009年02月13日 23:31:30 UTC'\t%Ec='2009年02月13日 23:31:30 UTC'\n"), lfmt, file_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 +#elif defined(_WIN32) // __APPLE__ + check(loc, + SV("%c='1970/01/01 0:00:00'\t%Ec='1970/01/01 0:00:00'\n"), + lfmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + check(loc, + SV("%c='2009/02/13 23:31:30'\t%Ec='2009/02/13 23:31:30'\n"), + lfmt, + std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 #else // __APPLE__ check(loc, SV("%c='1970年01月01日 00時00分00秒'\t%Ec='昭和45年01月01日 00時00分00秒'\n"), @@ -866,6 +886,22 @@ SV("%z='UTC'\t%Ez='UTC'\t%Oz='UTC'\t%Z='UTC'\n"), lfmt, file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 +# elif defined(_WIN32) // defined(_AIX) + // Non localized output using C-locale + check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + fmt, + file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + + // Use the global locale (fr_FR) + check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + lfmt, + file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + + // Use supplied locale (ja_JP). This locale has a different alternate.a + check(loc, + SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + lfmt, + file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 # else // defined(_AIX) // Non localized output using C-locale check(SV("%z='+0000'\t%Ez='+0000'\t%Oz='+0000'\t%Z='UTC'\n"), @@ -884,7 +920,7 @@ file_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 # endif // defined(_AIX) std::locale::global(std::locale::classic()); -#endif // !defined(__APPLE__) +#endif // !defined(__APPLE__) } template diff --git a/libcxx/test/std/time/time.syn/formatter.local_time.pass.cpp b/libcxx/test/std/time/time.syn/formatter.local_time.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.local_time.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.local_time.pass.cpp @@ -14,9 +14,6 @@ // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -240,7 +237,7 @@ lfmt, std::chrono::local_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // _WIN32 +#endif // _WIN32 std::locale::global(std::locale::classic()); } @@ -654,7 +651,7 @@ 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 // Use supplied locale (ja_JP). This locale has a different alternate.a -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='00'\t" @@ -675,6 +672,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -704,6 +705,10 @@ "%r='11:31:30 PM'\t" "%X='23時31分30秒'\t" "%EX='23時31分30秒'\t" +# elif defined(_WIN32) + "%r='23:31:30'\t" + "%X='23:31:30'\t" + "%EX='23:31:30'\t" # else "%r='午後11:31:30'\t" "%X='23:31:30'\t" @@ -712,7 +717,7 @@ "\n"), lfmt, std::chrono::hh_mm_ss(23h + 31min + 30s + 123ms)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='〇'\t" @@ -751,7 +756,7 @@ lfmt, std::chrono::local_time( 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } @@ -784,6 +789,8 @@ SV("%c=' 1 janvier 1970 à 00:00:00 UTC'\t%Ec=' 1 janvier 1970 à 00:00:00 UTC'\n"), #elif defined(__APPLE__) SV("%c='Jeu 1 jan 00:00:00 1970'\t%Ec='Jeu 1 jan 00:00:00 1970'\n"), +#elif defined(_WIN32) + SV("%c='01/01/1970 00:00:00'\t%Ec='01/01/1970 00:00:00'\n"), #else SV("%c='jeu. 01 janv. 1970 00:00:00'\t%Ec='jeu. 01 janv. 1970 00:00:00'\n"), #endif @@ -798,6 +805,8 @@ SV("%c='13 février 2009 à 23:31:30 UTC'\t%Ec='13 février 2009 à 23:31:30 UTC'\n"), #elif defined(__APPLE__) SV("%c='Ven 13 fév 23:31:30 2009'\t%Ec='Ven 13 fév 23:31:30 2009'\n"), +#elif defined(_WIN32) + SV("%c='13/02/2009 23:31:30'\t%Ec='13/02/2009 23:31:30'\n"), #else SV("%c='ven. 13 févr. 2009 23:31:30'\t%Ec='ven. 13 févr. 2009 23:31:30'\n"), #endif @@ -823,6 +832,15 @@ SV("%c='2009年02月13日 23:31:30 UTC'\t%Ec='2009年02月13日 23:31:30 UTC'\n"), lfmt, std::chrono::local_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 +#elif defined(_WIN32) // __APPLE__ + check(loc, + SV("%c='1970/01/01 0:00:00'\t%Ec='1970/01/01 0:00:00'\n"), + lfmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + check(loc, + SV("%c='2009/02/13 23:31:30'\t%Ec='2009/02/13 23:31:30'\n"), + lfmt, + std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 #else // __APPLE__ check(loc, SV("%c='1970年01月01日 00時00分00秒'\t%Ec='昭和45年01月01日 00時00分00秒'\n"), diff --git a/libcxx/test/std/time/time.syn/formatter.month_day.pass.cpp b/libcxx/test/std/time/time.syn/formatter.month_day.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.month_day.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.month_day.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -112,9 +112,15 @@ std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); // Non localized output using C-locale +#ifdef _WIN32 + check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::month_day{std::chrono::January, std::chrono::day{0}}); +#else check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), fmt, std::chrono::month_day{std::chrono::January, std::chrono::day{0}}); +#endif check(SV("%b='Feb'\t%B='February'\t%h='Feb'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), fmt, std::chrono::month_day{std::chrono::February, std::chrono::day{1}}); @@ -136,27 +142,42 @@ check(SV("%b='Aug'\t%B='August'\t%h='Aug'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), fmt, std::chrono::month_day{std::chrono::August, std::chrono::day{31}}); +#ifdef _WIN32 + check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::month_day{std::chrono::September, std::chrono::day{32}}); + check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::month_day{std::chrono::October, std::chrono::day{99}}); + check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); + check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); +#else // _WIN32 check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"), fmt, std::chrono::month_day{std::chrono::September, std::chrono::day{32}}); check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"), fmt, std::chrono::month_day{std::chrono::October, std::chrono::day{99}}); -#if defined(_AIX) +# if defined(_AIX) check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), fmt, std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"), fmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); -#else // defined(_AIX) +# else // defined(_AIX) check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), fmt, std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), fmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); -#endif // defined(_AIX) +# endif // defined(_AIX) +#endif // _WIN32 // Use the global locale (fr_FR) #if defined(__APPLE__) @@ -196,10 +217,16 @@ check(SV("%b='déc'\t%B='décembre'\t%h='déc'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), lfmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); -#else // defined(__APPLE__) +#else // defined(__APPLE__) +# if defined(_WIN32) + check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::month_day{std::chrono::January, std::chrono::day{0}}); +# else check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), lfmt, std::chrono::month_day{std::chrono::January, std::chrono::day{0}}); +# endif check(SV("%b='févr.'\t%B='février'\t%h='févr.'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), lfmt, std::chrono::month_day{std::chrono::February, std::chrono::day{1}}); @@ -226,77 +253,92 @@ check(SV("%b='août'\t%B='août'\t%h='août'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), lfmt, std::chrono::month_day{std::chrono::August, std::chrono::day{31}}); +# if defined(_WIN32) + check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::month_day{std::chrono::September, std::chrono::day{32}}); + check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::month_day{std::chrono::October, std::chrono::day{99}}); + check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); + check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); +# else // defined(_WIN32) check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"), lfmt, std::chrono::month_day{std::chrono::September, std::chrono::day{32}}); check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"), lfmt, std::chrono::month_day{std::chrono::October, std::chrono::day{99}}); -# if defined(_AIX) +# if defined(_AIX) check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), lfmt, std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"), lfmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); -# else // defined(_AIX) +# else // defined(_AIX) check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), lfmt, std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), lfmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); -# endif // defined(_AIX) -#endif // defined(__APPLE__) +# endif // defined(_AIX) +# endif // defined(_WIN32) +#endif // defined(__APPLE__) // Use supplied locale (ja_JP) #if defined(_WIN32) check(loc, - SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='〇'\t%Oe='〇'\n"), + SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::month_day{std::chrono::January, std::chrono::day{0}}); check(loc, - SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='一'\t%Oe='一'\n"), + SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), lfmt, std::chrono::month_day{std::chrono::February, std::chrono::day{1}}); check(loc, - SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='九'\t%Oe='九'\n"), + SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"), lfmt, std::chrono::month_day{std::chrono::March, std::chrono::day{9}}); check(loc, - SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='十'\t%Oe='十'\n"), + SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"), lfmt, std::chrono::month_day{std::chrono::April, std::chrono::day{10}}); check(loc, - SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='二十八'\t%Oe='二十八'\n"), + SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"), lfmt, std::chrono::month_day{std::chrono::May, std::chrono::day{28}}); check(loc, - SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='二十九'\t%Oe='二十九'\n"), + SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"), lfmt, std::chrono::month_day{std::chrono::June, std::chrono::day{29}}); check(loc, - SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='三十'\t%Oe='三十'\n"), + SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"), lfmt, std::chrono::month_day{std::chrono::July, std::chrono::day{30}}); check(loc, - SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='三十一'\t%Oe='三十一'\n"), + SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), lfmt, std::chrono::month_day{std::chrono::August, std::chrono::day{31}}); check(loc, - SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='三十二'\t%Oe='三十二'\n"), + SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::month_day{std::chrono::September, std::chrono::day{32}}); check(loc, - SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='九十九'\t%Oe='九十九'\n"), + SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::month_day{std::chrono::October, std::chrono::day{99}}); check(loc, - SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), + SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::month_day{std::chrono::November, std::chrono::day{100}}); check(loc, - SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), + SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::month_day{std::chrono::December, std::chrono::day{255}}); #elif defined(_AIX) // defined(_WIN32) diff --git a/libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp b/libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.sys_time.pass.cpp @@ -14,9 +14,6 @@ // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -240,7 +237,7 @@ lfmt, std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // _WIN32 +#endif // _WIN32 std::locale::global(std::locale::classic()); } @@ -651,8 +648,8 @@ std::chrono::sys_time( 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 - // Use supplied locale (ja_JP). This locale has a different alternate.a -#if defined(__APPLE__) || defined(_AIX) + // Use supplied locale (ja_JP). This locale has a different alternate. +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='00'\t" @@ -673,6 +670,10 @@ "%r='12:00:00 AM'\t" "%X='00時00分00秒'\t" "%EX='00時00分00秒'\t" +# elif defined(_WIN32) + "%r='0:00:00'\t" + "%X='0:00:00'\t" + "%EX='0:00:00'\t" # else "%r='午前12:00:00'\t" "%X='00:00:00'\t" @@ -702,6 +703,10 @@ "%r='11:31:30 PM'\t" "%X='23時31分30秒'\t" "%EX='23時31分30秒'\t" +# elif defined(_WIN32) + "%r='23:31:30'\t" + "%X='23:31:30'\t" + "%EX='23:31:30'\t" # else "%r='午後11:31:30'\t" "%X='23:31:30'\t" @@ -710,7 +715,7 @@ "\n"), lfmt, std::chrono::hh_mm_ss(23h + 31min + 30s + 123ms)); -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) check(loc, SV("%H='00'\t" "%OH='〇'\t" @@ -749,7 +754,7 @@ lfmt, std::chrono::sys_time( 1'234'567'890'123ms)); // 23:31:30 UTC on Friday, 13 February 2009 -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) std::locale::global(std::locale::classic()); } @@ -782,6 +787,8 @@ SV("%c=' 1 janvier 1970 à 00:00:00 UTC'\t%Ec=' 1 janvier 1970 à 00:00:00 UTC'\n"), #elif defined(__APPLE__) SV("%c='Jeu 1 jan 00:00:00 1970'\t%Ec='Jeu 1 jan 00:00:00 1970'\n"), +#elif defined(_WIN32) + SV("%c='01/01/1970 00:00:00'\t%Ec='01/01/1970 00:00:00'\n"), #else SV("%c='jeu. 01 janv. 1970 00:00:00'\t%Ec='jeu. 01 janv. 1970 00:00:00'\n"), #endif @@ -796,6 +803,8 @@ SV("%c='13 février 2009 à 23:31:30 UTC'\t%Ec='13 février 2009 à 23:31:30 UTC'\n"), #elif defined(__APPLE__) SV("%c='Ven 13 fév 23:31:30 2009'\t%Ec='Ven 13 fév 23:31:30 2009'\n"), +#elif defined(_WIN32) + SV("%c='13/02/2009 23:31:30'\t%Ec='13/02/2009 23:31:30'\n"), #else SV("%c='ven. 13 févr. 2009 23:31:30'\t%Ec='ven. 13 févr. 2009 23:31:30'\n"), #endif @@ -821,6 +830,15 @@ SV("%c='2009年02月13日 23:31:30 UTC'\t%Ec='2009年02月13日 23:31:30 UTC'\n"), lfmt, std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 +#elif defined(_WIN32) // __APPLE__ + check(loc, + SV("%c='1970/01/01 0:00:00'\t%Ec='1970/01/01 0:00:00'\n"), + lfmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + check(loc, + SV("%c='2009/02/13 23:31:30'\t%Ec='2009/02/13 23:31:30'\n"), + lfmt, + std::chrono::sys_seconds(1'234'567'890s)); // 23:31:30 UTC on Friday, 13 February 2009 #else // __APPLE__ check(loc, SV("%c='1970年01月01日 00時00分00秒'\t%Ec='昭和45年01月01日 00時00分00秒'\n"), @@ -866,6 +884,22 @@ SV("%z='UTC'\t%Ez='UTC'\t%Oz='UTC'\t%Z='UTC'\n"), lfmt, std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 +# elif defined(_WIN32) // defined(_AIX) + // Non localized output using C-locale + check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + fmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + + // Use the global locale (fr_FR) + check(SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + lfmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 + + // Use supplied locale (ja_JP). This locale has a different alternate.a + check(loc, + SV("%z='-0000'\t%Ez='-0000'\t%Oz='-0000'\t%Z='UTC'\n"), + lfmt, + std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 # else // defined(_AIX) // Non localized output using C-locale check(SV("%z='+0000'\t%Ez='+0000'\t%Oz='+0000'\t%Z='UTC'\n"), @@ -884,7 +918,7 @@ std::chrono::sys_seconds(0s)); // 00:00:00 UTC Thursday, 1 January 1970 # endif // defined(_AIX) std::locale::global(std::locale::classic()); -#endif // !defined(__APPLE__) +#endif // !defined(__APPLE__) } template diff --git a/libcxx/test/std/time/time.syn/formatter.weekday.pass.cpp b/libcxx/test/std/time/time.syn/formatter.weekday.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.weekday.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.weekday.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -142,7 +142,7 @@ // Use supplied locale (ja_JP). This locale has a different alternate. check(loc, SV("%u='8'\t%Ou='8'\t%w='8'\t%Ow='8'\n"), lfmt, std::chrono::weekday(8)); check(loc, SV("%u='255'\t%Ou='255'\t%w='255'\t%Ow='255'\n"), lfmt, std::chrono::weekday(255)); -#elif defined(_AIX) +#elif defined(_AIX) // defined(__APPLE__) // Non localized output using C-locale check(SV("%u='8'\t%Ou='8'\t%w='8'\t%Ow='8'\n"), fmt, std::chrono::weekday(8)); check(SV("%u='5'\t%Ou='5'\t%w='5'\t%Ow='5'\n"), fmt, std::chrono::weekday(255)); @@ -154,7 +154,19 @@ // Use supplied locale (ja_JP). This locale has a different alternate. check(loc, SV("%u='8'\t%Ou='8'\t%w='8'\t%Ow='8'\n"), lfmt, std::chrono::weekday(8)); check(loc, SV("%u='5'\t%Ou='5'\t%w='5'\t%Ow='5'\n"), lfmt, std::chrono::weekday(255)); -#else +#elif defined(_WIN32) // defined(__APPLE__) + // Non localized output using C-locale + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday(8)); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday(255)); + + // Use the global locale (fr_FR) + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday(8)); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday(255)); + + // Use supplied locale (ja_JP). This locale has a different alternate. + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday(8)); + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday(255)); +#else // defined(__APPLE__) // Non localized output using C-locale check(SV("%u='1'\t%Ou='1'\t%w='8'\t%Ow='8'\n"), fmt, std::chrono::weekday(8)); check(SV("%u='3'\t%Ou='3'\t%w='255'\t%Ow='255'\n"), fmt, std::chrono::weekday(255)); @@ -166,8 +178,7 @@ // Use supplied locale (ja_JP). This locale has a different alternate. check(loc, SV("%u='1'\t%Ou='一'\t%w='8'\t%Ow='八'\n"), lfmt, std::chrono::weekday(8)); check(loc, SV("%u='3'\t%Ou='三'\t%w='255'\t%Ow='255'\n"), lfmt, std::chrono::weekday(255)); - -#endif +#endif // defined(__APPLE__) std::locale::global(std::locale::classic()); } diff --git a/libcxx/test/std/time/time.syn/formatter.weekday_index.pass.cpp b/libcxx/test/std/time/time.syn/formatter.weekday_index.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.weekday_index.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.weekday_index.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -284,6 +284,24 @@ SV("%u='255'\t%Ou='255'\t%w='255'\t%Ow='255'\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 1}); +#elif defined(_WIN32) // defined(__APPLE__) + // Non localized output using C-locale + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 0}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 1}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 0}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 1}); + + // Use the global locale (fr_FR) + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 0}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 1}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 0}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 1}); + + // Use supplied locale (ja_JP). This locale has a different alternate. + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 0}); + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 1}); + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 0}); + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_indexed{std::chrono::weekday(255), 1}); #elif defined(_AIX) // defined(__APPLE__) // Non localized output using C-locale check(SV("%u='8'\t%Ou='8'\t%w='8'\t%Ow='8'\n"), fmt, std::chrono::weekday_indexed{std::chrono::weekday(8), 0}); diff --git a/libcxx/test/std/time/time.syn/formatter.weekday_last.pass.cpp b/libcxx/test/std/time/time.syn/formatter.weekday_last.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.weekday_last.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.weekday_last.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -248,6 +248,18 @@ SV("%u='255'\t%Ou='255'\t%w='255'\t%Ow='255'\n"), lfmt, std::chrono::weekday_last{std::chrono::weekday(255)}); +#elif defined(_WIN32) // defined(__APPLE__) + // Non localized output using C-locale + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_last{std::chrono::weekday(8)}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), fmt, std::chrono::weekday_last{std::chrono::weekday(255)}); + + // Use the global locale (fr_FR) + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_last{std::chrono::weekday(8)}); + check(SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_last{std::chrono::weekday(255)}); + + // Use supplied locale (ja_JP). This locale has a different alternate. + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_last{std::chrono::weekday(8)}); + check(loc, SV("%u=''\t%Ou=''\t%w=''\t%Ow=''\n"), lfmt, std::chrono::weekday_last{std::chrono::weekday(255)}); #elif defined(_AIX) // defined(__APPLE__) // Non localized output using C-locale check(SV("%u='8'\t%Ou='8'\t%w='8'\t%Ow='8'\n"), fmt, std::chrono::weekday_last{std::chrono::weekday(8)}); diff --git a/libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp b/libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp --- a/libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp +++ b/libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp @@ -11,12 +11,12 @@ // UNSUPPORTED: no-localization // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// TODO FMT Investigate Windows issues. -// UNSUPPORTED: msvc, target={{.+}}-windows-gnu - // TODO FMT This test should not require std::to_chars(floating-point) // XFAIL: availability-fp_to_chars-missing +// TODO FMT Investigate Windows issues. +// XFAIL: msvc + // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ja_JP.UTF-8 @@ -64,6 +64,17 @@ std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{2}, std::chrono::day{31}}); // Valid year, invalid month, valid day +#ifdef _WIN32 + check(SV(" is not a valid date"), + SV("{}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{31}}); + check(SV("****** is not a valid date******"), + SV("{:*^32}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{31}}); + check(SV("*********** is not a valid date"), + SV("{:*>31}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{31}}); +#else // _WIN32 check(SV("1970-00-31 is not a valid date"), SV("{}"), std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{31}}); @@ -73,8 +84,20 @@ check(SV("*1970-00-31 is not a valid date"), SV("{:*>31}"), std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{31}}); +#endif // _WIN32 // Valid year, invalid month, invalid day +#ifdef _WIN32 + check(SV(" is not a valid date"), + SV("{}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{32}}); + check(SV("****** is not a valid date******"), + SV("{:*^32}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{32}}); + check(SV("*********** is not a valid date"), + SV("{:*>31}"), + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{32}}); +#else // _WIN32 check(SV("1970-00-32 is not a valid date"), SV("{}"), std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{32}}); @@ -84,6 +107,7 @@ check(SV("*1970-00-32 is not a valid date"), SV("{:*>31}"), std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::month{0}, std::chrono::day{32}}); +#endif // _WIN32 // Invalid year, valid month, valid day check(SV("-32768-01-31 is not a valid date"), @@ -397,9 +421,15 @@ std::locale::global(std::locale(LOCALE_fr_FR_UTF_8)); // Non localized output using C-locale +#ifdef _WIN32 + check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{0}}); +#else check(SV("%b='Jan'\t%B='January'\t%h='Jan'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{0}}); +#endif check(SV("%b='Feb'\t%B='February'\t%h='Feb'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::February, std::chrono::day{1}}); @@ -421,27 +451,42 @@ check(SV("%b='Aug'\t%B='August'\t%h='Aug'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::August, std::chrono::day{31}}); +#ifdef _WIN32 + check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::September, std::chrono::day{32}}); + check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::October, std::chrono::day{99}}); + check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); + check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + fmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); +#else // _WIN32 check(SV("%b='Sep'\t%B='September'\t%h='Sep'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::September, std::chrono::day{32}}); check(SV("%b='Oct'\t%B='October'\t%h='Oct'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::October, std::chrono::day{99}}); -#if defined(_AIX) +# if defined(_AIX) check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); -#else // defined(_AIX) +# else // defined(_AIX) check(SV("%b='Nov'\t%B='November'\t%h='Nov'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); check(SV("%b='Dec'\t%B='December'\t%h='Dec'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), fmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); -#endif // defined(_AIX) +# endif // defined(_AIX) +#endif // _WIN32 // Use the global locale (fr_FR) #if defined(__APPLE__) @@ -481,10 +526,16 @@ check(SV("%b='déc'\t%B='décembre'\t%h='déc'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); -#else // defined(__APPLE__) +#else // defined(__APPLE__) +# ifdef _WIN32 + check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{0}}); +# else check(SV("%b='janv.'\t%B='janvier'\t%h='janv.'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{0}}); +# endif check(SV("%b='févr.'\t%B='février'\t%h='févr.'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::February, std::chrono::day{1}}); @@ -511,77 +562,92 @@ check(SV("%b='août'\t%B='août'\t%h='août'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::August, std::chrono::day{31}}); +# ifdef _WIN32 + check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::September, std::chrono::day{32}}); + check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::October, std::chrono::day{99}}); + check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); + check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), + lfmt, + std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); +# else // _WIN32 check(SV("%b='sept.'\t%B='septembre'\t%h='sept.'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='32'\t%Oe='32'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::September, std::chrono::day{32}}); check(SV("%b='oct.'\t%B='octobre'\t%h='oct.'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='99'\t%Oe='99'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::October, std::chrono::day{99}}); -# if defined(_AIX) +# if defined(_AIX) check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='00'\t%e=' 0'\t%Od='00'\t%Oe=' 0'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='55'\t%e='55'\t%Od='55'\t%Oe='55'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); -# else // defined(_AIX) +# else // defined(_AIX) check(SV("%b='nov.'\t%B='novembre'\t%h='nov.'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); check(SV("%b='déc.'\t%B='décembre'\t%h='déc.'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); -# endif // defined(_AIX) -#endif // defined(__APPLE__) +# endif // defined(_AIX) +# endif // _WIN32 +#endif // defined(__APPLE__) // Use supplied locale (ja_JP) #if defined(_WIN32) check(loc, - SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\t%d='00'\t%e=' 0'\t%Od='〇'\t%Oe='〇'\n"), + SV("%b='1'\t%B='1月'\t%h='1'\t%m='01'\t%Om='01'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{0}}); check(loc, - SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='一'\t%Oe='一'\n"), + SV("%b='2'\t%B='2月'\t%h='2'\t%m='02'\t%Om='02'\t%d='01'\t%e=' 1'\t%Od='01'\t%Oe=' 1'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::February, std::chrono::day{1}}); check(loc, - SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='九'\t%Oe='九'\n"), + SV("%b='3'\t%B='3月'\t%h='3'\t%m='03'\t%Om='03'\t%d='09'\t%e=' 9'\t%Od='09'\t%Oe=' 9'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::March, std::chrono::day{9}}); check(loc, - SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='十'\t%Oe='十'\n"), + SV("%b='4'\t%B='4月'\t%h='4'\t%m='04'\t%Om='04'\t%d='10'\t%e='10'\t%Od='10'\t%Oe='10'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::April, std::chrono::day{10}}); check(loc, - SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='二十八'\t%Oe='二十八'\n"), + SV("%b='5'\t%B='5月'\t%h='5'\t%m='05'\t%Om='05'\t%d='28'\t%e='28'\t%Od='28'\t%Oe='28'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::May, std::chrono::day{28}}); check(loc, - SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='二十九'\t%Oe='二十九'\n"), + SV("%b='6'\t%B='6月'\t%h='6'\t%m='06'\t%Om='06'\t%d='29'\t%e='29'\t%Od='29'\t%Oe='29'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::June, std::chrono::day{29}}); check(loc, - SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='三十'\t%Oe='三十'\n"), + SV("%b='7'\t%B='7月'\t%h='7'\t%m='07'\t%Om='07'\t%d='30'\t%e='30'\t%Od='30'\t%Oe='30'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::July, std::chrono::day{30}}); check(loc, - SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='三十一'\t%Oe='三十一'\n"), + SV("%b='8'\t%B='8月'\t%h='8'\t%m='08'\t%Om='08'\t%d='31'\t%e='31'\t%Od='31'\t%Oe='31'\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::August, std::chrono::day{31}}); check(loc, - SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\t%d='32'\t%e='32'\t%Od='三十二'\t%Oe='三十二'\n"), + SV("%b='9'\t%B='9月'\t%h='9'\t%m='09'\t%Om='09'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::September, std::chrono::day{32}}); check(loc, - SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d='99'\t%e='99'\t%Od='九十九'\t%Oe='九十九'\n"), + SV("%b='10'\t%B='10月'\t%h='10'\t%m='10'\t%Om='10'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::October, std::chrono::day{99}}); check(loc, - SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d='100'\t%e='100'\t%Od='100'\t%Oe='100'\n"), + SV("%b='11'\t%B='11月'\t%h='11'\t%m='11'\t%Om='11'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::November, std::chrono::day{100}}); check(loc, - SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d='255'\t%e='255'\t%Od='255'\t%Oe='255'\n"), + SV("%b='12'\t%B='12月'\t%h='12'\t%m='12'\t%Om='12'\t%d=''\t%e=''\t%Od=''\t%Oe=''\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::December, std::chrono::day{255}}); #elif defined(_AIX) // defined(_WIN32) @@ -945,14 +1011,14 @@ "%V='01'\t" "%w='4'\t" "%W='00'\t" -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%x='1970/01/01'\t" -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%x='1970年01月01日'\t" -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%y='70'\t" "%Y='1970'\t" -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%Ex='1970/01/01'\t" "%EC='19'\t" "%Ey='70'\t" @@ -963,7 +1029,7 @@ "%Ow='4'\t" "%OW='00'\t" "%Oy='70'\t" -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%Ex='昭和45年01月01日'\t" "%EC='昭和'\t" "%Ey='45'\t" @@ -974,7 +1040,7 @@ "%Ow='四'\t" "%OW='〇'\t" "%Oy='七十'\t" -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "\n"), lfmt, std::chrono::year_month_day{std::chrono::year{1970}, std::chrono::January, std::chrono::day{1}}); @@ -992,14 +1058,14 @@ "%V='22'\t" "%w='6'\t" "%W='21'\t" -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%x='2004/05/29'\t" -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%x='2004年05月29日'\t" -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%y='04'\t" "%Y='2004'\t" -#if defined(__APPLE__) || defined(_AIX) +#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%Ex='2004/05/29'\t" "%EC='20'\t" "%Ey='04'\t" @@ -1010,7 +1076,7 @@ "%Ow='6'\t" "%OW='21'\t" "%Oy='04'\t" -#else // defined(__APPLE__) || defined(_AIX) +#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "%Ex='平成16年05月29日'\t" "%EC='平成'\t" "%Ey='16'\t" @@ -1021,7 +1087,7 @@ "%Ow='六'\t" "%OW='二十一'\t" "%Oy='四'\t" -#endif // defined(__APPLE__) || defined(_AIX) +#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32) "\n"), lfmt, std::chrono::year_month_day{std::chrono::year{2004}, std::chrono::May, std::chrono::day{29}}); diff --git a/libcxx/test/std/time/time.syn/formatter_tests.h b/libcxx/test/std/time/time.syn/formatter_tests.h --- a/libcxx/test/std/time/time.syn/formatter_tests.h +++ b/libcxx/test/std/time/time.syn/formatter_tests.h @@ -8,6 +8,8 @@ #ifndef TEST_STD_TIME_TIME_SYN_FORMATTER_TESTS_H #define TEST_STD_TIME_TIME_SYN_FORMATTER_TESTS_H +#include "assert_macros.h" +#include "concat_macros.h" #include "make_string.h" #include "string_literal.h" #include "test_format_string.h" @@ -34,11 +36,9 @@ template void check(std::basic_string_view expected, test_format_string fmt, Args&&... args) { std::basic_string out = std::format(fmt, std::forward(args)...); - if constexpr (std::same_as) - if (out != expected) - std::cerr << "\nFormat string " << fmt.get() << "\nExpected output " << expected << "\nActual output " << out - << '\n'; - assert(out == expected); + TEST_REQUIRE(out == expected, + TEST_WRITE_CONCATENATED( + "\nFormat string ", fmt.get(), "\nExpected output ", expected, "\nActual output ", out, '\n')); } template @@ -47,38 +47,24 @@ test_format_string fmt, Args&&... args) { std::basic_string out = std::format(loc, fmt, std::forward(args)...); - if constexpr (std::same_as) - if (out != expected) - std::cerr << "\nFormat string " << fmt.get() << "\nExpected output " << expected << "\nActual output " << out - << '\n'; - assert(out == expected); + TEST_REQUIRE(out == expected, + TEST_WRITE_CONCATENATED( + "\nFormat string ", fmt.get(), "\nExpected output ", expected, "\nActual output ", out, '\n')); } template void check_exception([[maybe_unused]] std::string_view what, [[maybe_unused]] std::basic_string_view fmt, [[maybe_unused]] const Args&... args) { -#ifndef TEST_HAS_NO_EXCEPTIONS - try { - TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args>(args...)); - if constexpr (std::same_as) - std::cerr << "\nFormat string " << fmt << "\nDidn't throw an exception.\n"; - assert(false); - } catch (const std::format_error& e) { -# if defined(_LIBCPP_VERSION) - if constexpr (std::same_as) - if (e.what() != what) - std::cerr << "\nFormat string " << fmt << "\nExpected exception " << what << "\nActual exception " - << e.what() << '\n'; - assert(e.what() == what); -# else - (void)what; - (void)e; -# endif - return; - } - assert(false); -#endif + TEST_VALIDATE_EXCEPTION( + std::format_error, + [&]([[maybe_unused]] const std::format_error& e) { + TEST_LIBCPP_REQUIRE( + e.what() == what, + TEST_WRITE_CONCATENATED( + "\nFormat string ", fmt, "\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); + }, + TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args>(args...))); } template diff --git a/libcxx/test/support/concat_macros.h b/libcxx/test/support/concat_macros.h --- a/libcxx/test/support/concat_macros.h +++ b/libcxx/test/support/concat_macros.h @@ -16,15 +16,153 @@ #include "test_macros.h" #ifndef TEST_HAS_NO_LOCALIZATION +# include +# include # include #endif #if TEST_STD_VER > 17 # ifndef TEST_HAS_NO_LOCALIZATION + +[[nodiscard]] constexpr bool test_is_high_surrogate(char32_t value) { return value >= 0xd800 && value <= 0xdbff; } + +[[nodiscard]] constexpr bool test_is_low_surrogate(char32_t value) { return value >= 0xdc00 && value <= 0xdfff; } + +[[nodiscard]] constexpr bool test_is_surrogate(char32_t value) { return value >= 0xd800 && value <= 0xdfff; } + +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool test_is_code_point(char32_t value) { return value <= 0x10ffff; } + +[[nodiscard]] constexpr bool test_is_scalar_value(char32_t value) { + return test_is_code_point(value) && !test_is_surrogate(value); +} + +inline constexpr char32_t test_replacement_character = U'\ufffd'; + +template +OutIt test_transcode() = delete; + +template + requires(std::output_iterator && std::same_as, char8_t>) +OutIt test_transcode(InIt first, InIt last, OutIt out_it) { + return std::copy(first, last, out_it); +} + +template + requires std::output_iterator +void test_encode(OutIt& out_it, char16_t value) { + if (value < 0x80) + *out_it++ = value; + else if (value < 0x800) { + *out_it++ = 0b1100'0000 | (value >> 6); + *out_it++ = 0b1000'0000 | (value & 0b0011'1111); + } else { + *out_it++ = 0b1110'0000 | (value >> 12); + *out_it++ = 0b1000'0000 | ((value) >> 6 & 0b0011'1111); + *out_it++ = 0b1000'0000 | (value & 0b0011'1111); + } +} + +template + requires std::output_iterator +void test_encode(OutIt& out_it, char32_t value) { + if ((value & 0xffff0000) == 0) + test_encode(out_it, static_cast(value)); + else { + *out_it++ = 0b1110'0000 | (value >> 18); + *out_it++ = 0b1000'0000 | ((value) >> 12 & 0b0011'1111); + *out_it++ = 0b1000'0000 | ((value) >> 6 & 0b0011'1111); + *out_it++ = 0b1000'0000 | (value & 0b0011'1111); + } +} + +template + requires(std::output_iterator && + (std::same_as, char16_t> +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + || (std::same_as, wchar_t> && sizeof(wchar_t) == 2)) +# endif + ) +OutIt test_transcode(InIt first, InIt last, OutIt out_it) { + while (first != last) { + char32_t value = *first++; + + if (test_is_low_surrogate(value)) [[unlikely]] { + test_encode(out_it, static_cast(test_replacement_character)); + continue; + } + + if (!test_is_high_surrogate(value)) { + test_encode(out_it, static_cast(value)); + continue; + } + + if (first == last || !test_is_low_surrogate(static_cast(*first))) [[unlikely]] { + test_encode(out_it, static_cast(test_replacement_character)); + continue; + } + + value -= 0xd800; + value <<= 10; + value += static_cast(*first++) - 0xdc00; + value += 0x10000; + + if (test_is_code_point(value)) [[likely]] + test_encode(out_it, value); + else + test_encode(out_it, static_cast(test_replacement_character)); + } + + return out_it; +} + +template + requires(std::output_iterator && + (std::same_as, char32_t> || +# ifndef TEST_HAS_NO_WIDE_CHARACTERS + (std::same_as, wchar_t> && sizeof(wchar_t) == 4)) +# endif + ) +OutIt test_transcode(InIt first, InIt last, OutIt out_it) { + while (first != last) { + char32_t value = *first++; + if (test_is_code_point(value)) [[likely]] + test_encode(out_it, value); + else + test_encode(out_it, static_cast(test_replacement_character)); + } + return out_it; +} + template -concept test_char_streamable = requires(T&& value) { std::stringstream{} << std::forward(value); }; -# endif +concept test_streamable = requires(std::stringstream& stream, T&& value) { stream << value; }; + +template +concept test_convertable = (!test_streamable && requires(T&& value) { + std::basic_string_view{std::begin(value), std::end(value)}; +}); + +template +concept test_can_concat = test_streamable || test_convertable; + +template +std::ostream& test_concat(std::ostream& stream, T&& value) { + return stream << value; +} + +template +std::ostream& test_concat(std::ostream& stream, T&& value) { + auto b = std::begin(value); + auto e = std::end(value); + if (b != e) { + // When T is an array it's string-literal, remove the NUL terminator. + if constexpr (std::is_array_v>) + --e; + test_transcode(b, e, std::ostream_iterator{stream}); + } + return stream; +} +# endif // TEST_HAS_NO_LOCALIZATION // If possible concatenates message for the assertion function, else returns a // default message. Not being able to stream is not considered and error. For @@ -37,12 +175,12 @@ template std::string test_concat_message([[maybe_unused]] Args&&... args) { # ifndef TEST_HAS_NO_LOCALIZATION - if constexpr ((test_char_streamable && ...)) { + if constexpr ((test_can_concat && ...)) { std::stringstream sstr; - ((sstr << std::forward(args)), ...); + ((test_concat(sstr, std::forward(args))), ...); return sstr.str(); } else -# endif +# endif // TEST_HAS_NO_LOCALIZATION return "Message discarded since it can't be streamed to std::cerr.\n"; } @@ -50,5 +188,4 @@ # define TEST_WRITE_CONCATENATED(...) [&] { ::test_eprintf("%s", ::test_concat_message(__VA_ARGS__).c_str()); } #endif // TEST_STD_VER > 17 - #endif // TEST_SUPPORT_CONCAT_MACROS_H