diff options
Diffstat (limited to 'tests/auto/testlib/selftests/badxml')
4 files changed, 22 insertions, 75 deletions
diff --git a/tests/auto/testlib/selftests/badxml/.prev_CMakeLists.txt b/tests/auto/testlib/selftests/badxml/.prev_CMakeLists.txt deleted file mode 100644 index a085cd97e4..0000000000 --- a/tests/auto/testlib/selftests/badxml/.prev_CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Generated from badxml.pro. - -##################################################################### -## badxml Binary: -##################################################################### - -qt_internal_add_executable(badxml - SOURCES - tst_badxml.cpp - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::Test -) - -## Scopes: -##################################################################### diff --git a/tests/auto/testlib/selftests/badxml/CMakeLists.txt b/tests/auto/testlib/selftests/badxml/CMakeLists.txt index 733d826f97..21544707d7 100644 --- a/tests/auto/testlib/selftests/badxml/CMakeLists.txt +++ b/tests/auto/testlib/selftests/badxml/CMakeLists.txt @@ -1,15 +1,17 @@ -# Generated from badxml.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## badxml Binary: ##################################################################### qt_internal_add_executable(badxml - NO_INSTALL # special case - OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case + NO_INSTALL + EXCEPTIONS + OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} SOURCES tst_badxml.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::Test ) @@ -17,6 +19,4 @@ qt_internal_add_executable(badxml ## Scopes: ##################################################################### -# special case begin qt_internal_apply_testlib_coverage_options(badxml) -# special case end diff --git a/tests/auto/testlib/selftests/badxml/badxml.pro b/tests/auto/testlib/selftests/badxml/badxml.pro deleted file mode 100644 index 4e15886504..0000000000 --- a/tests/auto/testlib/selftests/badxml/badxml.pro +++ /dev/null @@ -1,9 +0,0 @@ -SOURCES += tst_badxml.cpp -QT = core-private testlib - -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - -TARGET = badxml - -include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp index e3f650bd85..a928a24d8a 100644 --- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp @@ -1,35 +1,9 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore/QCoreApplication> #include <QtCore/QStringList> -#include <QtTest/QtTest> +#include <QTest> #include <private/qmetaobjectbuilder_p.h> /* @@ -105,9 +79,9 @@ void tst_BadXml::badDataTag_data() const { QTest::addColumn<bool>("shouldFail"); - foreach (char const* str, badStrings()) { - QTest::newRow(qPrintable(QString("fail %1").arg(str))) << true; - QTest::newRow(qPrintable(QString("pass %1").arg(str))) << false; + for (const QByteArray &ba: badStrings()) { + QTest::addRow("fail %s", ba.constData()) << true; + QTest::addRow("pass %s", ba.constData()) << false; } } @@ -148,9 +122,8 @@ void tst_BadXml::badMessage_data() const QTest::addColumn<QByteArray>("message"); int i = 0; - foreach (QByteArray const& str, badStrings()) { + for (const QByteArray &str : badStrings()) QTest::newRow(qPrintable(QString::fromLatin1("string %1").arg(i++))) << str; - } } /* @@ -158,13 +131,12 @@ void tst_BadXml::badMessage_data() const */ QList<QByteArray> const& tst_BadXml::badStrings() { - static QList<QByteArray> out; - if (out.isEmpty()) { - out << "end cdata ]]> text ]]> more text"; - out << "quotes \" text\" more text"; - out << "xml close > open < tags < text"; - out << "all > \" mixed ]]> up > \" in < the ]]> hopes < of triggering \"< ]]> bugs"; - } + static const QList<QByteArray> out = { + "end cdata ]]> text ]]> more text", + "quotes \" text\" more text", + "xml close > open < tags < text", + "all > \" mixed ]]> up > \" in < the ]]> hopes < of triggering \"< ]]> bugs", + }; return out; } @@ -205,16 +177,16 @@ int main(int argc, char** argv) if (badstring == -1) { tst_BadXml test; - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } QList<QByteArray> badstrings = tst_BadXml::badStrings(); - if (badstring >= badstrings.count()) + if (badstring >= badstrings.size()) qFatal("`-badstring %d' is out of range", badstring); tst_BadXmlSub test; test.className = badstrings[badstring].constData(); - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } #include "tst_badxml.moc" |