From 7c8126d9099841fd0ccf643d36b963a75161aab9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Dec 2021 09:06:53 +0100 Subject: [PATCH] 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 --- src/testlib/qtestdata.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/testlib/qtestdata.h b/src/testlib/qtestdata.h index cf10fed8f3..ed81a9de6e 100644 --- a/src/testlib/qtestdata.h +++ b/src/testlib/qtestdata.h @@ -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(value); +} +#endif + #ifdef QT_USE_QSTRINGBUILDER template inline QTestData &operator<<(QTestData &data, const QStringBuilder &value)