diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-11-16 16:11:18 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-11-16 17:20:00 +0000 |
commit | 23725aa53bd264941c4fb228227736be4da59761 (patch) | |
tree | 8ead9cd479754c2defde5c456e99423e9d006494 /libstdc++-v3/testsuite/19_diagnostics | |
parent | 8ed7120eaaf49c00c20ccf82ed4ff6aa24a00076 (diff) | |
download | gcc-23725aa53bd264941c4fb228227736be4da59761.zip gcc-23725aa53bd264941c4fb228227736be4da59761.tar.gz gcc-23725aa53bd264941c4fb228227736be4da59761.tar.bz2 |
libstdc++: Fix aligned formatting of stacktrace_entry and thread::id [PR112564]
The formatter for std::thread::id should default to right-align, and the
formatter for std::stacktrace_entry should not just ignore the
fill-and-align and width from the format-spec!
libstdc++-v3/ChangeLog:
PR libstdc++/112564
* include/std/stacktrace (formatter::format): Format according
to format-spec.
* include/std/thread (formatter::format): Use _Align_right as
default.
* testsuite/19_diagnostics/stacktrace/output.cc: Check
fill-and-align handling. Change compile test to run.
* testsuite/30_threads/thread/id/output.cc: Check fill-and-align
handling.
Diffstat (limited to 'libstdc++-v3/testsuite/19_diagnostics')
-rw-r--r-- | libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc index 4960ccb..67f1e0c 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc @@ -1,4 +1,5 @@ -// { dg-do compile { target c++23 } } +// { dg-options "-lstdc++exp" } +// { dg-do run { target c++23 } } // { dg-require-effective-target stacktrace } // { dg-add-options no_pch } @@ -17,7 +18,8 @@ test_to_string() { auto trace = std::stacktrace::current(); std::string s1 = std::to_string(trace.at(0)); - VERIFY( s1.contains("test_to_string():15") ); + VERIFY( s1.contains("test_to_string()") ); + VERIFY( s1.contains("output.cc:19") ); std::string s2 = std::to_string(trace); VERIFY( s2.contains(s1) ); } @@ -47,7 +49,17 @@ test_format() std::stacktrace_entry entry = trace.at(0); std::string str = std::to_string(entry); VERIFY( std::format("{}", entry) == str ); - VERIFY( std::format("{0:!<{1}}", entry, str.size() + 3) == (str + "!!!") ); + auto len = str.size(); + // with width + VERIFY( std::format("{0:{1}}", entry, len + 1) == (str + " ") ); + // with align + width + VERIFY( std::format("{0:<{1}}", entry, len + 2) == (str + " ") ); + VERIFY( std::format("{0:^{1}}", entry, len + 3) == (" " + str + " ") ); + VERIFY( std::format("{0:>{1}}", entry, len + 4) == (" " + str) ); + // with fill-and-align + width + VERIFY( std::format("{0:!<{1}}", entry, len + 2) == (str + "!!") ); + VERIFY( std::format("{0:!^{1}}", entry, len + 3) == ("!" + str + "!!") ); + VERIFY( std::format("{0:!>{1}}", entry, len + 4) == ("!!!!" + str) ); } int main() |