[gcc r13-8199] libstdc++: Add additional tests for std::format with wide strings

Jonathan Wakely redi@gcc.gnu.org
Mon Jan 8 17:18:05 GMT 2024


https://gcc.gnu.org/g:bf025a0ee76bf63c1b5c8c8be662086904ad3935

commit r13-8199-gbf025a0ee76bf63c1b5c8c8be662086904ad3935
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 15 16:35:22 2023 +0100

    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:
---
 libstdc++-v3/testsuite/std/format/functions/format.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 8ce4ea72597..e9827d0b735 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<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));


More information about the Libstdc++-cvs mailing list