diff options
Diffstat (limited to 'tests/auto/corelib/text/qstringtokenizer')
3 files changed, 25 insertions, 36 deletions
diff --git a/tests/auto/corelib/text/qstringtokenizer/CMakeLists.txt b/tests/auto/corelib/text/qstringtokenizer/CMakeLists.txt index 67b044e445..35fa2a31fd 100644 --- a/tests/auto/corelib/text/qstringtokenizer/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringtokenizer/CMakeLists.txt @@ -1,9 +1,16 @@ -# Generated from qstringtokenizer.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qstringtokenizer Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qstringtokenizer LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qstringtokenizer SOURCES tst_qstringtokenizer.cpp diff --git a/tests/auto/corelib/text/qstringtokenizer/qstringtokenizer.pro b/tests/auto/corelib/text/qstringtokenizer/qstringtokenizer.pro deleted file mode 100644 index 5ae27c6570..0000000000 --- a/tests/auto/corelib/text/qstringtokenizer/qstringtokenizer.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qstringtokenizer -QT = core testlib -contains(QT_CONFIG, c++14):CONFIG *= c++14 -contains(QT_CONFIG, c++1z):CONFIG *= c++1z -contains(QT_CONFIG, c++2a):CONFIG *= c++2a -SOURCES += tst_qstringtokenizer.cpp diff --git a/tests/auto/corelib/text/qstringtokenizer/tst_qstringtokenizer.cpp b/tests/auto/corelib/text/qstringtokenizer/tst_qstringtokenizer.cpp index 1d2658c38f..0101c74a7b 100644 --- a/tests/auto/corelib/text/qstringtokenizer/tst_qstringtokenizer.cpp +++ b/tests/auto/corelib/text/qstringtokenizer/tst_qstringtokenizer.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QStringTokenizer> #include <QStringBuilder> @@ -34,7 +9,7 @@ #include <string> Q_DECLARE_METATYPE(Qt::SplitBehavior) - +namespace { class tst_QStringTokenizer : public QObject { Q_OBJECT @@ -70,6 +45,7 @@ QStringList toQStringList(const Container &c) r.push_back(toQString(e)); return r; } +} // namespace void tst_QStringTokenizer::constExpr() const { @@ -145,6 +121,19 @@ void tst_QStringTokenizer::toContainer() const auto v = tok.toContainer(); QVERIFY((std::is_same_v<decltype(v), QList<QLatin1String>>)); } + // QLatin1String value_type into QStringList + { + auto tok = qTokenize(QLatin1String{"a,b,c"}, u','); + QStringList result; + tok.toContainer(result); + QCOMPARE(result, QStringList({"a", "b", "c"})); + } + // QLatin1String value_type into QStringList: rvalue overload + { + QStringList result; + qTokenize(QLatin1String{"a,b,c"}, u',').toContainer(result); + QCOMPARE(result, QStringList({"a", "b", "c"})); + } } QTEST_APPLESS_MAIN(tst_QStringTokenizer) |