Am Do., 12. Juni 2025 um 16:40 Uhr schrieb Tomasz Kamiński < tkami...@redhat.com>:
> libstdc++-v3/ChangeLog: > > * testsuite/std/time/format/whitespace.cc: New test. > --- > Testing on x86_64-linux. OK for trunk when test passes. > > .../testsuite/std/time/format/whitespace.cc | 54 +++++++++++++++++++ > 1 file changed, 54 insertions(+) > create mode 100644 libstdc++-v3/testsuite/std/time/format/whitespace.cc > > diff --git a/libstdc++-v3/testsuite/std/time/format/whitespace.cc > b/libstdc++-v3/testsuite/std/time/format/whitespace.cc > new file mode 100644 > index 00000000000..e211bd51dc1 > --- /dev/null > +++ b/libstdc++-v3/testsuite/std/time/format/whitespace.cc > @@ -0,0 +1,54 @@ > +// { dg-do run { target c++20 } } > + > +#include <chrono> > +#include <testsuite_hooks.h> > + > +using namespace std::chrono; > + > +#define WIDEN_(C, S) ::std::__format::_Widen<C>(S, L##S) > +#define WIDEN(S) WIDEN_(_CharT, S) > > I don't think that you really need to use the uglified _CharT here... > +template<typename _CharT, typename ChronoType> > .. and here. It is only needed within the standard library headers, right? > +void > +test(const ChronoType& ct) > +{ > + std::basic_string<_CharT> res; > + > + res = std::format(WIDEN("{:%% %t %n more text}"), ct); > + VERIFY( res == WIDEN("% \t \n more text") ); > + > + res = std::format(WIDEN("{:7%% %t %n}"), ct); > + VERIFY( res == WIDEN("% \t \n ") ); > + > + res = std::format(WIDEN("{:>6%% %t %n}"), ct); > + VERIFY( res == WIDEN(" % \t \n") ); > + > + res = std::format(WIDEN("{:+>7%% %t %n}"), ct); > + VERIFY( res == WIDEN("++% \t \n") ); > + > + res = std::format(WIDEN("{:=^7%% %t %n}"), ct); > + VERIFY( res == WIDEN("=% \t \n=") ); > +} > + > +template<typename CharT> > +void > +test_all() > +{ > + test<CharT>(20s); > + test<CharT>(10d); > + test<CharT>(Monday); > + test<CharT>(2020y/January/8); > + test<CharT>(local_days(2020y/January/8)); > + test<CharT>(sys_days(2020y/January/8) + 13h + 10min + 5s); > + test<CharT>(sys_info()); > + test<CharT>(local_info()); > +} > + > +int main() > +{ > + test_all<char>(); > + > +#ifdef _GLIBCXX_USE_WCHAR_T > + test_all<wchar_t>(); > +#endif // _GLIBCXX_USE_WCHAR_T > +} > -- > 2.49.0 > - Daniel