]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add additional tests for std::format with wide strings
authorJonathan Wakely <jwakely@redhat.com>
Tue, 15 Aug 2023 15:35:22 +0000 (16:35 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 8 Jan 2024 15:29:11 +0000 (15:29 +0000)
Backport the extra tests from r14-3300-g023a62b77f999b.

libstdc++-v3/ChangeLog:

* testsuite/std/format/functions/format.cc: Add more checks for
wstring formatting of arithmetic types.

libstdc++-v3/testsuite/std/format/functions/format.cc

index 8ce4ea725976512fe1d51fde4e1f484b6c30d81f..e9827d0b7357483ddb179c34d94e5c341285a240 100644 (file)
@@ -319,6 +319,16 @@ test_wchar()
   VERIFY( s == L"0.0625" );
   s = std::format(L"{}", 0.25);
   VERIFY( s == L"0.25" );
+  s = std::format(L"{:+a} {:A}", 0x1.23p45, -0x1.abcdefp-15);
+  VERIFY( s == L"+1.23p+45 -1.ABCDEFP-15" );
+
+  double inf = std::numeric_limits<double>::infinity();
+  double nan = std::numeric_limits<double>::quiet_NaN();
+  s = std::format(L"{0} {0:F} {1} {1:E}", -inf, -nan);
+  VERIFY( s == L"-inf -INF -nan -NAN" );
+
+  s = std::format(L"{0:#b} {0:#B} {0:#x} {0:#X}", 99);
+  VERIFY( s == L"0b1100011 0B1100011 0x63 0X63" );
 
   // P2909R4 Fix formatting of code units as integers (Dude, where’s my char?)
   s = std::format(L"{:d} {:d}", wchar_t(-1), char(-1));