diff options
Diffstat (limited to 'tests/auto/corelib/text/qstringbuilder')
15 files changed, 352 insertions, 230 deletions
diff --git a/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt index 20c980f0ad..2ac5d1a73e 100644 --- a/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qstringbuilder.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qstringbuilder1) add_subdirectory(qstringbuilder2) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder.pro b/tests/auto/corelib/text/qstringbuilder/qstringbuilder.pro deleted file mode 100644 index d73d541502..0000000000 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE=subdirs -SUBDIRS= \ - qstringbuilder1 \ - qstringbuilder2 \ - qstringbuilder3 \ - qstringbuilder4 diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt index 2c897ddcd3..069b7573ba 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt @@ -1,10 +1,17 @@ -# Generated from qstringbuilder1.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qstringbuilder1 Test: ##################################################################### -qt_add_test(tst_qstringbuilder1 +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringbuilder1 LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_qstringbuilder1 SOURCES tst_qstringbuilder1.cpp ) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/qstringbuilder1.pro b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/qstringbuilder1.pro deleted file mode 100644 index d9cdad1bf5..0000000000 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/qstringbuilder1.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qstringbuilder1 -QT = core testlib -SOURCES = tst_qstringbuilder1.cpp diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 5903c7066b..59362d010a 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -1,33 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Do not include anything in this file. We are being #included with -// a bunch of defines that may break other legitimate code. +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +// Do not include anything in this file. We are being #included in the unnamed namespace +// with a bunch of defines that may break other legitimate code. #define LITERAL "some literal" #define LITERAL_LEN (sizeof(LITERAL)-1) @@ -38,12 +13,10 @@ #define UTF8_LITERAL_LEN (sizeof(UTF8_LITERAL)-1) #define UTF8_LITERAL_EXTRA "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" "EXTRA" -#ifdef Q_COMPILER_UNICODE_STRINGS // "some literal", but replacing all vocals by their umlauted UTF-8 string :) #define UNICODE_LITERAL u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" #define UNICODE_LITERAL_LEN ((sizeof(UNICODE_LITERAL) - 1) / 2) #define UNICODE_LITERAL_EXTRA u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" "EXTRA" -#endif #ifndef P # error You need to define P @@ -59,57 +32,246 @@ template <typename T> QString toQString(const T &t); template <> QString toQString(const QString &s) { return s; } -template <> QString toQString(const QStringRef &r) { return r.toString(); } template <> QString toQString(const QStringView &v) { return v.toString(); } template <> QString toQString(const QLatin1String &l) { return l; } template <> QString toQString(const QLatin1Char &l) { return QChar(l); } template <> QString toQString(const QChar &c) { return c; } template <> QString toQString(const QChar::SpecialCharacter &c) { return QChar(c); } -#ifdef Q_COMPILER_UNICODE_STRINGS template <> QString toQString(char16_t * const &p) { return QStringView(p).toString(); } template <size_t N> QString toQString(const char16_t (&a)[N]) { return QStringView(a).toString(); } template <> QString toQString(const char16_t &c) { return QChar(c); } -#endif template <typename T> QByteArray toQByteArray(const T &t); template <> QByteArray toQByteArray(const QByteArray &b) { return b; } +template <> QByteArray toQByteArray(const QByteArrayView &bav) { return bav.toByteArray(); } template <> QByteArray toQByteArray(char * const &p) { return p; } template <size_t N> QByteArray toQByteArray(const char (&a)[N]) { return a; } template <> QByteArray toQByteArray(const char &c) { return QByteArray(&c, 1); } +template <typename String, typename Separator> +void checkItWorksWithFreeSpaceAtBegin(const String &chunk, const Separator &separator) +{ + // GIVEN: a String with freeSpaceAtBegin() and less than chunk.size() freeSpaceAtEnd() + String str; + + int prepends = 0; + const int max_prepends = 10; + while (str.data_ptr().freeSpaceAtBegin() < chunk.size() && prepends++ < max_prepends) + str.prepend(chunk); + QVERIFY(prepends < max_prepends); + + int appends = 0; + const int max_appends = 100; + while (str.data_ptr().freeSpaceAtEnd() >= chunk.size() && appends++ < max_appends) + str.append(chunk); + QVERIFY(appends < max_appends); + + QVERIFY(str.capacity() - str.size() >= chunk.size()); + QVERIFY(str.data_ptr().freeSpaceAtEnd() < chunk.size()); + + // WHEN: adding a QStringBuilder expression which exceeds freeSpaceAtEnd() + str += separator P chunk; + + // THEN: it doesn't crash (QTBUG-99330) + const String expected = chunk.repeated(prepends + appends) + separator + chunk; + QCOMPARE(str, expected); +} + +template <typename String> +void checkNullVsEmpty(const String &empty) +{ + String a; + String b; + QVERIFY(a.isNull()); + QVERIFY(b.isNull()); + String result = a P b; + QVERIFY(result.isNull()); + + String d = empty; + QVERIFY(d.isEmpty()); + QVERIFY(!d.isNull()); + result = a P d; + QVERIFY(result.isEmpty()); + QVERIFY(!result.isNull()); + + result = a P a P a; + QVERIFY(result.isNull()); +} + +namespace CheckAuto { +// T is cvref-qualified, using universal reference deduction rules. +template <typename T> struct Helper; + +// These specializations forward to the non-const ones, and add const on top. +template <typename T> struct Helper<const T> +{ + static const T create() { return Helper<T>::create(); } + static const T createNull() { return Helper<T>::createNull(); } +}; +template <typename T> struct Helper<const T &> +{ + static const T &create() { return Helper<T &>::create(); } + static const T &createNull() { return Helper<T &>::createNull(); } +}; + +template <> struct Helper<QString> +{ + static QString create() { return QString::fromUtf8("QString rvalue"); } + static QString createNull() { return QString(); } +}; + +template <> struct Helper<QString &> +{ + static QString &create() { static QString s = QString::fromUtf8("QString lvalue"); return s; } + static QString &createNull() { static QString s; return s; } +}; + +template <> struct Helper<QStringView> +{ + static QStringView create() { return QStringView(u"QStringView rvalue"); } + static QStringView createNull() { return QStringView(); } +}; + +template <> struct Helper<QStringView &> +{ + static QStringView &create() { static QStringView s = u"QStringView lvalue"; return s; } + static QStringView &createNull() { static QStringView s; return s; } +}; + +template <> struct Helper<QByteArray> +{ + static QByteArray create() { return QByteArray("QByteArray rvalue"); } + static QByteArray createNull() { return QByteArray(); } +}; + +template <> struct Helper<QByteArray &> +{ + static QByteArray &create() { static QByteArray ba = QByteArray("QByteArray lvalue"); return ba; } + static QByteArray &createNull() { static QByteArray ba; return ba; } +}; + +template <> struct Helper<QByteArrayView> +{ + static QByteArrayView create() { return QByteArrayView("QByteArrayView rvalue"); } + static QByteArrayView createNull() { return QByteArrayView(); } +}; + +template <> struct Helper<QByteArrayView &> +{ + static QByteArrayView &create() { static QByteArrayView ba = "QByteArrayView lvalue"; return ba; } + static QByteArrayView &createNull() { static QByteArrayView ba; return ba; } +}; + +template <> struct Helper<const char *> +{ + static const char *create() { return "const char * rvalue"; } + static const char *createNull() { return ""; } +}; + +template <> struct Helper<const char *&> +{ + static const char *&create() { static const char *s = "const char * lvalue"; return s; } + static const char *&createNull() { static const char *s = ""; return s; } +}; + +template <typename String1, typename String2, typename Result> +void checkAutoImpl3() +{ + { + auto result = Helper<String1>::create() P Helper<String2>::create(); + Result expected = result; + QCOMPARE(result, expected); + } + { + auto result = Helper<String2>::create() P Helper<String1>::create(); + Result expected = result; + QCOMPARE(result, expected); + } + { + auto result = Helper<String1>::create() P Helper<String2>::create() P Helper<String1>::create(); + Result expected = result; + QCOMPARE(result, expected); + } + { + auto result = Helper<String2>::create() P Helper<String1>::create() P Helper<String2>::create(); + Result expected = result; + QCOMPARE(result, expected); + } + { + auto result = Helper<String1>::createNull() P Helper<String2>::create(); + Result expected = result; + QCOMPARE(result, expected); + } + { + auto result = Helper<String1>::createNull() P Helper<String2>::createNull(); + Result expected = result; + QCOMPARE(result, expected); + } +} + +template <typename String1, typename String2, typename Result> +void checkAutoImpl2() +{ + checkAutoImpl3<String1 , String2 , Result>(); + checkAutoImpl3<String1 &, String2 , Result>(); + checkAutoImpl3<String1 , String2 &, Result>(); + checkAutoImpl3<String1 &, String2 &, Result>(); +} + +template <typename String1, typename String2, typename Result> +void checkAutoImpl() +{ + checkAutoImpl2< String1, String2, Result>(); + checkAutoImpl2<const String1, String2, Result>(); + checkAutoImpl2< String1, const String2, Result>(); + checkAutoImpl2<const String1, const String2, Result>(); +} + +} // namespace CheckAuto + +void checkAuto() +{ + CheckAuto::checkAutoImpl<QString, QString, QString>(); + CheckAuto::checkAutoImpl<QString, QStringView, QString>(); + + CheckAuto::checkAutoImpl<QByteArray, QByteArray, QByteArray>(); + CheckAuto::checkAutoImpl<QByteArray, const char *, QByteArray>(); + CheckAuto::checkAutoImpl<QByteArray, QByteArrayView, QByteArray>(); + +#ifndef QT_NO_CAST_FROM_ASCII + CheckAuto::checkAutoImpl<QString, const char *, QString>(); + CheckAuto::checkAutoImpl<QString, QByteArray, QString>(); +#endif +} + void runScenario() { // this code is latin1. TODO: replace it with the utf8 block below, once // strings default to utf8. QLatin1String l1string(LITERAL); QString string(l1string); - QStringRef stringref(&string, 2, 10); - QStringView stringview(stringref); + QStringView stringview = QStringView{ string }.mid(2, 10); QLatin1Char lchar('c'); QChar qchar(lchar); QChar::SpecialCharacter special(QChar::Nbsp); -#ifdef Q_COMPILER_UNICODE_STRINGS char16_t u16char = UNICODE_LITERAL[0]; char16_t u16chararray[] = { u's', 0xF6, u'm', 0xEB, u' ', u'l', 0xEF, u't', 0xEB, u'r', 0xE4, u'l', 0x00 }; QCOMPARE(QStringView(u16chararray), QStringView(UNICODE_LITERAL)); char16_t *u16charstar = u16chararray; -#endif #define CHECK(QorP, a1, a2) \ do { \ - DO(QorP, a1, a2); \ - DO(QorP, a2, a1); \ + QCOMPARE(QString(a1 QorP a2), toQString(a1).append(toQString(a2))); \ + QCOMPARE(QString(a2 QorP a1), toQString(a2).append(toQString(a1))); \ } while (0) -#define DO(QorP, a1, a2) \ - QCOMPARE(QString(a1 QorP a2), \ - toQString(a1).append(toQString(a2))) \ - /* end */ - CHECK(P, l1string, l1string); CHECK(P, l1string, string); - CHECK(P, l1string, stringref); + CHECK(P, l1string, QString(string)); + CHECK(Q, l1string, string); + CHECK(Q, l1string, QString(string)); + CHECK(Q, l1string, stringview); CHECK(P, l1string, lchar); CHECK(P, l1string, qchar); @@ -120,31 +282,48 @@ void runScenario() CHECK(Q, l1string, u16charstar); CHECK(P, string, string); - CHECK(P, string, stringref); + CHECK(P, string, QString(string)); + CHECK(P, QString(string), QString(string)); + CHECK(Q, string, string); + CHECK(Q, string, QString(string)); + CHECK(Q, QString(string), QString(string)); + + CHECK(P, string, stringview); + CHECK(P, QString(string), stringview); CHECK(Q, string, stringview); + CHECK(Q, QString(string), stringview); + CHECK(P, string, lchar); + CHECK(P, QString(string), lchar); + CHECK(Q, string, lchar); + CHECK(Q, QString(string), lchar); + CHECK(P, string, qchar); + CHECK(P, QString(string), qchar); CHECK(P, string, special); + CHECK(P, QString(string), special); CHECK(P, string, QStringLiteral(LITERAL)); + CHECK(P, QString(string), QStringLiteral(LITERAL)); + CHECK(Q, string, qchar); + CHECK(Q, QString(string), qchar); + CHECK(Q, string, special); + CHECK(Q, QString(string), special); + CHECK(Q, string, QStringLiteral(LITERAL)); + CHECK(Q, QString(string), QStringLiteral(LITERAL)); + CHECK(Q, string, u16char); + CHECK(Q, QString(string), u16char); CHECK(Q, string, u16chararray); + CHECK(Q, QString(string), u16chararray); CHECK(Q, string, u16charstar); - - CHECK(P, stringref, stringref); - CHECK(Q, stringref, stringview); - CHECK(P, stringref, lchar); - CHECK(P, stringref, qchar); - CHECK(P, stringref, special); - CHECK(P, stringref, QStringLiteral(LITERAL)); - CHECK(Q, stringref, u16char); - CHECK(Q, stringref, u16chararray); - CHECK(Q, stringref, u16charstar); + CHECK(Q, QString(string), u16charstar); CHECK(Q, stringview, stringview); CHECK(Q, stringview, lchar); CHECK(Q, stringview, qchar); CHECK(Q, stringview, special); CHECK(P, stringview, QStringLiteral(LITERAL)); + CHECK(Q, stringview, QStringLiteral(LITERAL)); CHECK(Q, stringview, u16char); CHECK(Q, stringview, u16chararray); CHECK(Q, stringview, u16charstar); @@ -184,21 +363,34 @@ void runScenario() // CHECK(Q, u16charstar, u16charstar); // BUILTIN <-> BUILTIN cat't be overloaded -#undef DO +#undef CHECK -#define DO(QorP, a1, a2) \ - QCOMPARE(QByteArray(a1 QorP a2), \ - toQByteArray(a1).append(toQByteArray(a2))) \ - /* end */ +#define CHECK(QorP, a1, a2) \ + do { \ + QCOMPARE(QByteArray(a1 QorP a2), toQByteArray(a1).append(toQByteArray(a2))); \ + QCOMPARE(QByteArray(a2 QorP a1), toQByteArray(a2).append(toQByteArray(a1))); \ + } while (0) - QByteArray bytearray = stringref.toUtf8(); + QByteArray bytearray = stringview.toUtf8(); + QByteArrayView baview = QByteArrayView(bytearray).mid(0, bytearray.size() - 2); char *charstar = bytearray.data(); char chararray[3] = { 'H', 'i', '\0' }; const char constchararray[3] = { 'H', 'i', '\0' }; char achar = 'a'; CHECK(P, bytearray, bytearray); + CHECK(P, QByteArray(bytearray), bytearray); + CHECK(P, QByteArray(bytearray), QByteArray(bytearray)); + CHECK(P, bytearray, baview); + CHECK(P, QByteArray(bytearray), baview); CHECK(P, bytearray, charstar); + CHECK(Q, bytearray, bytearray); + CHECK(Q, QByteArray(bytearray), bytearray); + CHECK(Q, QByteArray(bytearray), QByteArray(bytearray)); + CHECK(Q, bytearray, baview); + CHECK(Q, QByteArray(bytearray), baview); + CHECK(Q, bytearray, charstar); + #ifndef Q_CC_MSVC // see QTBUG-65359 CHECK(P, bytearray, chararray); #else @@ -206,6 +398,8 @@ void runScenario() #endif CHECK(P, bytearray, constchararray); CHECK(P, bytearray, achar); + CHECK(Q, bytearray, constchararray); + CHECK(Q, bytearray, achar); //CHECK(Q, charstar, charstar); // BUILTIN <-> BUILTIN cat't be overloaded //CHECK(Q, charstar, chararray); @@ -216,7 +410,6 @@ void runScenario() //CHECK(Q, achar, achar); // BUILTIN <-> BUILTIN cat't be overloaded -#undef DO #undef CHECK QString r2(QLatin1String(LITERAL LITERAL)); @@ -224,15 +417,13 @@ void runScenario() QString r; // self-assignment: - r = stringref.toString(); + r = stringview.toString(); r = lchar + r; - QCOMPARE(r, QString(lchar P stringref)); + QCOMPARE(r, QString(lchar P stringview)); -#ifdef Q_COMPILER_UNICODE_STRINGS r = QStringLiteral(UNICODE_LITERAL); r = r Q QStringLiteral(UNICODE_LITERAL); QCOMPARE(r, r3); -#endif #ifndef QT_NO_CAST_FROM_ASCII r = string P LITERAL; @@ -283,7 +474,7 @@ void runScenario() r = string P ba; QCOMPARE(r, string); - const char *zero = 0; + const char *zero = nullptr; r = string P zero; QCOMPARE(r, string); r = zero P string; @@ -322,11 +513,15 @@ void runScenario() r2 = QByteArray("hello\0") P UTF8_LITERAL; QCOMPARE(r, r2); - const char *zero = 0; + const char *zero = nullptr; r = ba P zero; QCOMPARE(r, ba); r = zero P ba; QCOMPARE(r, ba); + + QByteArrayView qbav = LITERAL; + superba = qbav P qbav P LITERAL; + QCOMPARE(superba, QByteArray(LITERAL LITERAL LITERAL)); } //operator QString += @@ -347,6 +542,16 @@ void runScenario() QCOMPARE(str2, str2_e); } + checkItWorksWithFreeSpaceAtBegin(QString::fromUtf8(UTF8_LITERAL), + #ifdef QT_NO_CAST_FROM_ASCII + QLatin1String("1234") + #else + "1234" + #endif + ); + if (QTest::currentTestFailed()) + return; + //operator QByteArray += { QByteArray ba = UTF8_LITERAL; @@ -360,4 +565,14 @@ void runScenario() QCOMPARE(ba2, QByteArray(withZero + withZero + withZero)); } + // null vs. empty + checkNullVsEmpty(QStringLiteral("")); + checkNullVsEmpty(QByteArrayLiteral("")); + + // auto + checkAuto(); + + checkItWorksWithFreeSpaceAtBegin(QByteArray(UTF8_LITERAL), "1234"); + if (QTest::currentTestFailed()) + return; } diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp index 1437717201..394372c398 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/qglobal.h> @@ -42,7 +17,11 @@ #define LITERAL "some literal" -void runScenario(); // Defined in stringbuilder.cpp #included below. +namespace { +#define P % +#include "stringbuilder.cpp" +#undef P +} // namespace class tst_QStringBuilder1 : public QObject { @@ -52,10 +31,6 @@ private slots: void scenario() { runScenario(); } }; -#define P % -#include "stringbuilder.cpp" -#undef P - #include "tst_qstringbuilder1.moc" QTEST_APPLESS_MAIN(tst_QStringBuilder1) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt index 7b5b96aef3..8db076581a 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt @@ -1,10 +1,17 @@ -# Generated from qstringbuilder2.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qstringbuilder2 Test: ##################################################################### -qt_add_test(tst_qstringbuilder2 +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringbuilder2 LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_qstringbuilder2 SOURCES tst_qstringbuilder2.cpp ) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/qstringbuilder2.pro b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/qstringbuilder2.pro deleted file mode 100644 index e134c5d934..0000000000 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/qstringbuilder2.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qstringbuilder2 -QT = core testlib -SOURCES = tst_qstringbuilder2.cpp diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp index 8b6350a65d..dc590304f5 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/qglobal.h> @@ -43,7 +18,11 @@ #define LITERAL "some literal" -void runScenario(); // Defined in stringbuilder.cpp #included below. +namespace { +#define P + +#include "../qstringbuilder1/stringbuilder.cpp" +#undef P +} // namespace class tst_QStringBuilder2 : public QObject { @@ -53,10 +32,6 @@ private slots: void scenario() { runScenario(); } }; -#define P + -#include "../qstringbuilder1/stringbuilder.cpp" -#undef P - #include "tst_qstringbuilder2.moc" QTEST_APPLESS_MAIN(tst_QStringBuilder2) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt index 3293f26e5c..177b41bf2f 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt @@ -1,10 +1,17 @@ -# Generated from qstringbuilder3.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qstringbuilder3 Test: ##################################################################### -qt_add_test(tst_qstringbuilder3 +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringbuilder3 LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_qstringbuilder3 SOURCES tst_qstringbuilder3.cpp ) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/qstringbuilder3.pro b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/qstringbuilder3.pro deleted file mode 100644 index 29607551c3..0000000000 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/qstringbuilder3.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qstringbuilder3 -QT = core testlib -SOURCES = tst_qstringbuilder3.cpp diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp index 6c5994f7b3..3222b52713 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/qglobal.h> @@ -42,7 +17,11 @@ #define LITERAL "some literal" -void runScenario(); // Defined in stringbuilder.cpp #included below. +namespace { +#define P % +#include "../qstringbuilder1/stringbuilder.cpp" +#undef P +} // namespace class tst_QStringBuilder3 : public QObject { @@ -52,10 +31,6 @@ private slots: void scenario() { runScenario(); } }; -#define P % -#include "../qstringbuilder1/stringbuilder.cpp" -#undef P - #include "tst_qstringbuilder3.moc" QTEST_APPLESS_MAIN(tst_QStringBuilder3) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt index 55c4400acf..94883b498a 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt @@ -1,10 +1,17 @@ -# Generated from qstringbuilder4.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qstringbuilder4 Test: ##################################################################### -qt_add_test(tst_qstringbuilder4 +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringbuilder4 LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_qstringbuilder4 SOURCES tst_qstringbuilder4.cpp ) diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/qstringbuilder4.pro b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/qstringbuilder4.pro deleted file mode 100644 index e55848e4bd..0000000000 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/qstringbuilder4.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qstringbuilder4 -QT = core testlib -SOURCES = tst_qstringbuilder4.cpp diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp index 2aecdcfff6..442c5275d2 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/qglobal.h> @@ -43,7 +18,11 @@ #define LITERAL "some literal" -void runScenario(); // Defined in stringbuilder.cpp #included below. +namespace { +#define P + +#include "../qstringbuilder1/stringbuilder.cpp" +#undef P +} // namespace class tst_QStringBuilder4 : public QObject { @@ -53,10 +32,6 @@ private slots: void scenario() { runScenario(); } }; -#define P + -#include "../qstringbuilder1/stringbuilder.cpp" -#undef P - #include "tst_qstringbuilder4.moc" QTEST_APPLESS_MAIN(tst_QStringBuilder4) |