]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Adjust expected locale-dependent date formats in tests
authorJonathan Wakely <jwakely@redhat.com>
Wed, 10 Apr 2024 12:24:51 +0000 (13:24 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 10 Apr 2024 15:14:25 +0000 (16:14 +0100)
The std/time/year_month_day/io.cc test assumes that %x in the fr_FR
locale is %d/%m/%Y but on FreeBSD it is %d.%m.%Y instead. Make the test
PASS for either format.

Similarly, 27_io/manipulators/extended/get_time/char/2.cc expects that
%a in the de_DE locale is "Di" but on FreeBSD it's "Di." with a trailing
period. Adjust the input string to be "1971 Di." instead of "Di 1971"
and that way if %a doesn't expect the trailing '.' it simply won't
extract it from the stream.

This fixes:
FAIL: std/time/year_month_day/io.cc  -std=gnu++20 execution test
FAIL: 27_io/manipulators/extended/get_time/char/2.cc  -std=gnu++17 execution test

libstdc++-v3/ChangeLog:

* testsuite/27_io/manipulators/extended/get_time/char/2.cc:
Adjust input string so that it matches %a with or without a
trailing period.
* testsuite/std/time/year_month_day/io.cc: Adjust expected
format for %x in the fr_FR locale.

libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
libstdc++-v3/testsuite/std/time/year_month_day/io.cc

index 6104349d2548c53e26e6215aad16cf271e067cc1..b582967fddc0a73762e570cfc7af300576eb3824 100644 (file)
@@ -35,9 +35,9 @@ void test01()
   VERIFY( loc_de != loc_c );
   istringstream iss;
   iss.imbue(loc_de);
-  iss.str("Di 1971");
-  tm time1;
-  iss >> get_time(&time1, "%a %Y");
+  iss.str("1971 Di."); // %a is "Di" on some targets, "Di." on others.
+  tm time1{};
+  iss >> get_time(&time1, "%Y %a");
   VERIFY(time1.tm_wday == 2);
   VERIFY(time1.tm_year == 71);
 }
index cb82ef3b6125cfe5718f32ea0a04853fa79d6ce6..632b7a0fc2dabac61da9ee062b6de7a65ec9b3a3 100644 (file)
@@ -84,7 +84,7 @@ test_format()
   s = std::format(loc_fr, "{:%x}", 2022y/December/19);
   VERIFY( s == "12/19/22" );
   s = std::format(loc_fr, "{:L%x}", 2022y/December/19);
-  VERIFY( s == "19/12/2022" );
+  VERIFY( s == "19/12/2022" || s == "19.12.2022" ); // depends on locale defs
   s = std::format(loc_fr, "{}", 2022y/December/19);
   VERIFY( s == "2022-12-19" );
   s = std::format(loc_fr, "{:L%F}", 2022y/December/19);