From: Jonathan Wakely Date: Tue, 15 Aug 2023 15:35:22 +0000 (+0100) Subject: libstdc++: Add additional tests for std::format with wide strings X-Git-Tag: releases/gcc-13.3.0~582 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf025a0ee76bf63c1b5c8c8be662086904ad3935;p=thirdparty%2Fgcc.git libstdc++: Add additional tests for std::format with wide strings 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. --- diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc index 8ce4ea725976..e9827d0b7357 100644 --- a/libstdc++-v3/testsuite/std/format/functions/format.cc +++ b/libstdc++-v3/testsuite/std/format/functions/format.cc @@ -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::infinity(); + double nan = std::numeric_limits::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));