Skip to content

Commit 1403080

Browse files
committed
[NFC][chrono][test] Fixes some tests on Windows.
This updates the tests to match the actual output on Windows. Note some tests still need more investigation. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D153498
1 parent fd5748c commit 1403080

11 files changed

+421
-126
lines changed

libcxx/test/std/time/time.syn/formatter.day.pass.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
// UNSUPPORTED: no-localization
1212
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1313

14-
// TODO FMT Investigate Windows issues.
15-
// UNSUPPORTED: msvc, target={{.+}}-windows-gnu
16-
1714
// TODO FMT This test should not require std::to_chars(floating-point)
1815
// XFAIL: availability-fp_to_chars-missing
1916

17+
// TODO FMT Investigate Windows issues.
18+
// XFAIL: msvc
19+
2020
// REQUIRES: locale.fr_FR.UTF-8
2121
// REQUIRES: locale.ja_JP.UTF-8
2222

@@ -64,41 +64,59 @@ static void test_valid_values() {
6464
std::locale::global(std::locale(LOCALE_fr_FR_UTF_8));
6565

6666
// Non localized output using C-locale
67+
#if defined(_WIN32)
68+
check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 0d);
69+
#else
6770
check(SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), fmt, 0d);
71+
#endif
6872
check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), fmt, 1d);
6973
check(SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), fmt, 31d);
70-
#if defined(_AIX)
74+
#if defined(_WIN32)
75+
check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 0d);
76+
#elif defined(_AIX)
7177
check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), fmt, 255d);
7278
#else
7379
check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), fmt, 255d);
7480
#endif
7581

7682
// Use the global locale (fr_FR)
83+
#if defined(_WIN32)
84+
check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 0d);
85+
#else
7786
check(SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), lfmt, 0d);
87+
#endif
7888
check(SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), lfmt, 1d);
7989
check(SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), lfmt, 31d);
80-
#if defined(_AIX)
90+
#if defined(_WIN32)
91+
check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 255d);
92+
#elif defined(_AIX)
8193
check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), lfmt, 255d);
8294
#else
8395
check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), lfmt, 255d);
8496
#endif
8597

8698
// Use supplied locale (ja_JP). This locale has a different alternate on some platforms.
87-
#if defined(__APPLE__) || defined(_AIX)
99+
#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
100+
# if defined(_WIN32)
101+
check(loc, SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), lfmt, 0d);
102+
# else
88103
check(loc, SV("%d='00'\t%Od='00'\t%e=' 0'\t%Oe=' 0'\n"), lfmt, 0d);
104+
# endif
89105
check(loc, SV("%d='01'\t%Od='01'\t%e=' 1'\t%Oe=' 1'\n"), lfmt, 1d);
90106
check(loc, SV("%d='31'\t%Od='31'\t%e='31'\t%Oe='31'\n"), lfmt, 31d);
91-
# if defined(_AIX)
107+
# if defined(_WIN32)
108+
check(SV("%d=''\t%Od=''\t%e=''\t%Oe=''\n"), fmt, 255d);
109+
# elif defined(_AIX)
92110
check(SV("%d='55'\t%Od='55'\t%e='55'\t%Oe='55'\n"), fmt, 255d);
93111
# else
94112
check(SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), fmt, 255d);
95113
# endif
96-
#else // defined(__APPLE__) || defined(_AIX)
114+
#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
97115
check(loc, SV("%d='00'\t%Od='〇'\t%e=' 0'\t%Oe='〇'\n"), lfmt, 0d);
98116
check(loc, SV("%d='01'\t%Od='一'\t%e=' 1'\t%Oe='一'\n"), lfmt, 1d);
99117
check(loc, SV("%d='31'\t%Od='三十一'\t%e='31'\t%Oe='三十一'\n"), lfmt, 31d);
100118
check(loc, SV("%d='255'\t%Od='255'\t%e='255'\t%Oe='255'\n"), lfmt, 255d);
101-
#endif // defined(__APPLE__) || defined(_AIX)
119+
#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
102120

103121
std::locale::global(std::locale::classic());
104122
}

libcxx/test/std/time/time.syn/formatter.duration.pass.cpp

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
// UNSUPPORTED: no-localization
1212
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1313

14-
// TODO FMT Investigate Windows issues.
15-
// UNSUPPORTED: msvc, target={{.+}}-windows-gnu
16-
1714
// XFAIL: availability-fp_to_chars-missing
1815

1916
// REQUIRES: locale.fr_FR.UTF-8
@@ -247,7 +244,7 @@ static void test_valid_positive_integral_values() {
247244
"%R='00:00'\t"
248245
"%T='00:00:00'\t"
249246
#ifdef _WIN32
250-
"%r='12:00:00'\t"
247+
"%r='00:00:00'\t"
251248
#elif defined(_AIX)
252249
"%r='12:00:00 AM'\t"
253250
#elif defined(__APPLE__)
@@ -313,7 +310,7 @@ static void test_valid_positive_integral_values() {
313310
"%R='12:00'\t"
314311
"%T='12:00:00'\t"
315312
#ifdef _WIN32
316-
"%r='00:00:00'\t"
313+
"%r='12:00:00'\t"
317314
#elif defined(_AIX)
318315
"%r='12:00:00 PM'\t"
319316
#elif defined(__APPLE__)
@@ -349,6 +346,8 @@ static void test_valid_positive_integral_values() {
349346
"%r='11:59:59 PM'\t"
350347
#elif defined(__APPLE__)
351348
"%r=''\t"
349+
#elif defined(_WIN32)
350+
"%r='23:59:59'\t"
352351
#else
353352
"%r='11:59:59 '\t"
354353
#endif
@@ -377,11 +376,13 @@ static void test_valid_positive_integral_values() {
377376
"%R='00:00'\t"
378377
"%T='00:00:00'\t"
379378
#ifdef _WIN32
380-
"%r='12:00:00'\t"
379+
"%r='00:00:00'\t"
381380
#elif defined(_AIX)
382381
"%r='12:00:00 AM'\t"
383382
#elif defined(__APPLE__)
384383
"%r=''\t"
384+
#elif defined(_WIN32)
385+
"%r='12:00:00'\t"
385386
#else
386387
"%r='12:00:00 '\t"
387388
#endif
@@ -395,7 +396,7 @@ static void test_valid_positive_integral_values() {
395396
std::chrono::duration<int, std::ratio<86400>>(7));
396397

397398
// Use supplied locale (ja_JP). This locale has a different alternate.
398-
#if defined(__APPLE__) || defined(_AIX)
399+
#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
399400
check(loc,
400401
SV("%H='00'\t"
401402
"%OH='00'\t"
@@ -416,6 +417,10 @@ static void test_valid_positive_integral_values() {
416417
"%r='12:00:00 AM'\t"
417418
"%X='00時00分00秒'\t"
418419
"%EX='00時00分00秒'\t"
420+
# elif defined(_WIN32)
421+
"%r='0:00:00'\t"
422+
"%X='0:00:00'\t"
423+
"%EX='0:00:00'\t"
419424
# else
420425
"%r='午前12:00:00'\t"
421426
"%X='00:00:00'\t"
@@ -448,6 +453,10 @@ static void test_valid_positive_integral_values() {
448453
"%r='11:59:59 AM'\t"
449454
"%X='11時59分59秒'\t"
450455
"%EX='11時59分59秒'\t"
456+
# elif defined(_WIN32)
457+
"%r='11:59:59'\t"
458+
"%X='11:59:59'\t"
459+
"%EX='11:59:59'\t"
451460
# else
452461
"%r='午前11:59:59'\t"
453462
"%X='11:59:59'\t"
@@ -481,7 +490,11 @@ static void test_valid_positive_integral_values() {
481490
"%X='12時00分00秒'\t"
482491
"%EX='12時00分00秒'\t"
483492
# else
493+
# ifdef _WIN32
494+
"%r='12:00:00'\t"
495+
# else
484496
"%r='午後12:00:00'\t"
497+
# endif
485498
"%X='12:00:00'\t"
486499
"%EX='12:00:00'\t"
487500
# endif
@@ -513,7 +526,11 @@ static void test_valid_positive_integral_values() {
513526
"%X='23時59分59秒'\t"
514527
"%EX='23時59分59秒'\t"
515528
# else
529+
# ifdef _WIN32
530+
"%r='23:59:59'\t"
531+
# else
516532
"%r='午後11:59:59'\t"
533+
# endif
517534
"%X='23:59:59'\t"
518535
"%EX='23:59:59'\t"
519536
# endif
@@ -544,6 +561,10 @@ static void test_valid_positive_integral_values() {
544561
"%r='12:00:00 AM'\t"
545562
"%X='00時00分00秒'\t"
546563
"%EX='00時00分00秒'\t"
564+
# elif defined(_WIN32)
565+
"%r='0:00:00'\t"
566+
"%X='0:00:00'\t"
567+
"%EX='0:00:00'\t"
547568
# else
548569
"%r='午前12:00:00'\t"
549570
"%X='00:00:00'\t"
@@ -555,7 +576,7 @@ static void test_valid_positive_integral_values() {
555576
"\n"),
556577
lfmt,
557578
std::chrono::duration<int, std::ratio<86400>>(7));
558-
#else // defined(__APPLE__) || defined(_AIX)
579+
#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
559580
check(loc,
560581
SV("%H='00'\t"
561582
"%OH='〇'\t"
@@ -665,8 +686,8 @@ static void test_valid_positive_integral_values() {
665686
"\n"),
666687
lfmt,
667688
std::chrono::duration<int, std::ratio<86400>>(7));
689+
#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
668690

669-
#endif // defined(__APPLE__) || defined(_AIX)
670691
std::locale::global(std::locale::classic());
671692
}
672693

@@ -767,6 +788,8 @@ static void test_valid_negative_integral_values() {
767788
"%r='11:59:59 PM'\t"
768789
#elif defined(__APPLE__)
769790
"%r=''\t"
791+
#elif defined(_WIN32)
792+
"%r='23:59:59'\t"
770793
#else
771794
"%r='11:59:59 '\t"
772795
#endif
@@ -780,7 +803,7 @@ static void test_valid_negative_integral_values() {
780803
-(23h + 59min + 59s));
781804

782805
// Use supplied locale (ja_JP). This locale has a different alternate.
783-
#if defined(__APPLE__) || defined(_AIX)
806+
#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
784807
check(loc,
785808
SV("-%H='23'\t"
786809
"%OH='23'\t"
@@ -801,6 +824,10 @@ static void test_valid_negative_integral_values() {
801824
"%r='11:59:59 PM'\t"
802825
"%X='23時59分59秒'\t"
803826
"%EX='23時59分59秒'\t"
827+
# elif defined(_WIN32)
828+
"%r='23:59:59'\t"
829+
"%X='23:59:59'\t"
830+
"%EX='23:59:59'\t"
804831
# else
805832
"%r='午後11:59:59'\t"
806833
"%X='23:59:59'\t"
@@ -812,7 +839,7 @@ static void test_valid_negative_integral_values() {
812839
"\n"),
813840
lfmt,
814841
-(23h + 59min + 59s));
815-
#else // defined(__APPLE__) || defined(_AIX)
842+
#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
816843
check(loc,
817844
SV("-%H='23'\t"
818845
"%OH='二十三'\t"
@@ -834,7 +861,7 @@ static void test_valid_negative_integral_values() {
834861
"\n"),
835862
lfmt,
836863
-(23h + 59min + 59s));
837-
#endif // defined(__APPLE__) || defined(_AIX)
864+
#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
838865
std::locale::global(std::locale::classic());
839866
}
840867

@@ -987,7 +1014,7 @@ static void test_valid_fractional_values() {
9871014
check(loc, SV("00.011"), SV("{:L%S}"), std::chrono::duration<double, std::milli>(11.123456789));
9881015
check(loc, SV("01"), SV("{:L%S}"), std::chrono::duration<long double>(61.123456789));
9891016

990-
#if defined(__APPLE__) || defined(_AIX)
1017+
#if defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
9911018
check(SV("00.000000001"), SV("{:%OS}"), 1ns);
9921019
check(SV("00.000000501"), SV("{:%OS}"), 501ns);
9931020
check(SV("00.000001000"), SV("{:%OS}"), 1000ns);
@@ -1003,7 +1030,7 @@ static void test_valid_fractional_values() {
10031030
check(SV("00.001"), SV("{:%OS}"), std::chrono::duration<float, std::milli>(1.123456789));
10041031
check(SV("00.011"), SV("{:%OS}"), std::chrono::duration<double, std::milli>(11.123456789));
10051032
check(SV("01"), SV("{:%OS}"), std::chrono::duration<long double>(61.123456789));
1006-
#else // defined(__APPLE__) || defined(_AIX)
1033+
#else // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
10071034
check(loc, SV("〇.000000001"), SV("{:L%OS}"), 1ns);
10081035
check(loc, SV("〇.000000501"), SV("{:L%OS}"), 501ns);
10091036
check(loc, SV("〇.000001000"), SV("{:L%OS}"), 1000ns);
@@ -1019,7 +1046,7 @@ static void test_valid_fractional_values() {
10191046
check(loc, SV("〇.001"), SV("{:L%OS}"), std::chrono::duration<float, std::milli>(1.123456789));
10201047
check(loc, SV("〇.011"), SV("{:L%OS}"), std::chrono::duration<double, std::milli>(11.123456789));
10211048
check(loc, SV(""), SV("{:L%OS}"), std::chrono::duration<long double>(61.123456789));
1022-
#endif // defined(__APPLE__) || defined(_AIX)
1049+
#endif // defined(__APPLE__) || defined(_AIX) || defined(_WIN32)
10231050

10241051
check(loc, SV("01:05:06.000000001"), SV("{:L%T}"), 1h + 5min + 6s + 1ns);
10251052
check(loc, SV("01:05:06.000000501"), SV("{:L%T}"), 1h + 5min + 6s + 501ns);

0 commit comments

Comments
 (0)