From b7e13a82a779845327c055ad283315c7c441f79e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 9 Aug 2024 16:20:53 +0200 Subject: [PATCH] tst_QStringBuilder: add a check for QBA/QL1SV concatenation Rvalue QL1S and (const) lvalue QBA combination is ambiguous in qtlottie tests on the latest qt5.git integration round. It was not caugth by the QStringBuilder tests, because the tests never checked op+() with allowed casts to/from ASCII. Add a new test scenario and hide the failing combination under ifdef (cannot use QEXPECT_FAIL as it's a compile-time error). The ifdef will be removed in a follow-up patch that fixes the issue. Task-number: QTBUG-127904 Task-number: QTBUG-127928 Task-number: QTBUG-127931 Change-Id: I92b582f16e850fb34c34b75714d820e65d411265 Reviewed-by: Volker Hilsheimer --- .../text/qstringbuilder/CMakeLists.txt | 1 + .../qstringbuilder1/stringbuilder.cpp | 12 ++++++ .../qstringbuilder6/CMakeLists.txt | 17 ++++++++ .../qstringbuilder6/tst_qstringbuilder6.cpp | 41 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 tests/auto/corelib/text/qstringbuilder/qstringbuilder6/CMakeLists.txt create mode 100644 tests/auto/corelib/text/qstringbuilder/qstringbuilder6/tst_qstringbuilder6.cpp diff --git a/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt index 2f6cc8beef3..6ce4c5c629b 100644 --- a/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt @@ -6,3 +6,4 @@ add_subdirectory(qstringbuilder2) add_subdirectory(qstringbuilder3) add_subdirectory(qstringbuilder4) add_subdirectory(qstringbuilder5) +add_subdirectory(qstringbuilder6) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp index a845e21138b..d929b5b58dc 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -479,6 +479,18 @@ void runScenario() r = QByteArrayLiteral(LITERAL) P string; QCOMPARE(r, r2); +#ifndef HAS_QTBUG_127928 + r = ba P l1string; + QCOMPARE(r, r2); + r = l1string P ba; + QCOMPARE(r, r2); + + r = ba P QLatin1String(l1string); + QCOMPARE(r, r2); + r = QLatin1String(l1string) P std::as_const(ba); + QCOMPARE(r, r2); +#endif + static const char badata[] = LITERAL_EXTRA; ba = QByteArray::fromRawData(badata, LITERAL_LEN); r = ba P string; diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/CMakeLists.txt new file mode 100644 index 00000000000..6a3230e1c0f --- /dev/null +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_qstringbuilder6 Test: +##################################################################### + +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringbuilder6 LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_qstringbuilder6 + SOURCES + tst_qstringbuilder6.cpp +) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/tst_qstringbuilder6.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/tst_qstringbuilder6.cpp new file mode 100644 index 00000000000..5393ec2b905 --- /dev/null +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder6/tst_qstringbuilder6.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include + +// SCENARIO 6 +// We disable QStringBuilder and compile with normal operator+ to verify +// that all QSB supported operations are still available when QSB is disabled. +// We also allow casts to/from ASCII +#undef QT_USE_QSTRINGBUILDER +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII + +#include +#include +#include +#include + +#include + +#define LITERAL "some literal" + +#define HAS_QTBUG_127928 1 + +namespace { +#define P + +#include "../qstringbuilder1/stringbuilder.cpp" +#undef P +} // namespace + +class tst_QStringBuilder6 : public QObject +{ + Q_OBJECT + +private slots: + void scenario() { runScenario(); } +}; + +#include "tst_qstringbuilder6.moc" + +QTEST_APPLESS_MAIN(tst_QStringBuilder6)