QTestData: fix streaming of u8 string literals in C++20 mode

...fixing tst_QLocale:

  QDEBUG : tst_QLocale::formatDate() expected data of type 'QString', got 'char8_t [64]' for element 1 of data with tag 'unicode in format string'
  QFATAL : tst_QLocale::formatDate() ASSERT: false in file /home/marc/Qt/qtbase/src/testlib/qtestdata.cpp, line 105

In C++20, the type of u8 string literals changed from const char[] to
const char8_t[].

[ChangeLog][QtTest][QTestData] Fixed streaming of u8 string literals
in C++20 mode.

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-99480
Task-number: QTBUG-99481
Change-Id: I53bd73522a4ebce307f360e225f25590f981d44a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Marc Mutz 2021-12-28 09:06:53 +01:00
parent 591a35d6fd
commit 7c8126d909
1 changed files with 8 additions and 0 deletions

View File

@ -85,6 +85,14 @@ inline QTestData &operator<<(QTestData &data, const char * value)
return data;
}
#ifdef __cpp_char8_t
Q_WEAK_OVERLOAD
inline QTestData &operator<<(QTestData &data, const char8_t *value)
{
return data << reinterpret_cast<const char *>(value);
}
#endif
#ifdef QT_USE_QSTRINGBUILDER
template<typename A, typename B>
inline QTestData &operator<<(QTestData &data, const QStringBuilder<A, B> &value)