diff options
Diffstat (limited to 'tests/benchmarks/corelib/io/qurl')
-rw-r--r-- | tests/benchmarks/corelib/io/qurl/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp (renamed from tests/benchmarks/corelib/io/qurl/main.cpp) | 75 |
2 files changed, 32 insertions, 57 deletions
diff --git a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt index d38c8b18c0..fc8d48450d 100644 --- a/tests/benchmarks/corelib/io/qurl/CMakeLists.txt +++ b/tests/benchmarks/corelib/io/qurl/CMakeLists.txt @@ -1,23 +1,21 @@ -# Generated from qurl.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qurl Binary: ##################################################################### -qt_internal_add_benchmark(tst_qurl +qt_internal_add_benchmark(tst_bench_qurl SOURCES - main.cpp - PUBLIC_LIBRARIES + tst_bench_qurl.cpp + LIBRARIES Qt::Test ) -#### Keys ignored in scope 1:.:.:qurl.pro:<TRUE>: -# TEMPLATE = "app" - ## Scopes: ##################################################################### -qt_internal_extend_target(tst_qurl CONDITION WIN32 +qt_internal_extend_target(tst_bench_qurl CONDITION WIN32 DEFINES _CRT_SECURE_NO_WARNINGS ) diff --git a/tests/benchmarks/corelib/io/qurl/main.cpp b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp index 5ad3c3bd47..87c4f51816 100644 --- a/tests/benchmarks/corelib/io/qurl/main.cpp +++ b/tests/benchmarks/corelib/io/qurl/tst_bench_qurl.cpp @@ -1,35 +1,10 @@ -/**************************************************************************** -** -** 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 <qurl.h> #include <qtest.h> -class tst_qurl: public QObject +class tst_QUrl : public QObject { Q_OBJECT @@ -53,28 +28,28 @@ private: void generateFirstRunData(); }; -void tst_qurl::emptyUrl() +void tst_QUrl::emptyUrl() { QBENCHMARK { QUrl url; } } -void tst_qurl::relativeUrl() +void tst_QUrl::relativeUrl() { QBENCHMARK { QUrl url("pics/avatar.png"); } } -void tst_qurl::absoluteUrl() +void tst_QUrl::absoluteUrl() { QBENCHMARK { QUrl url("/tmp/avatar.png"); } } -void tst_qurl::generateFirstRunData() +void tst_QUrl::generateFirstRunData() { QTest::addColumn<bool>("firstRun"); @@ -82,12 +57,12 @@ void tst_qurl::generateFirstRunData() QTest::newRow("subsequent runs") << false; } -void tst_qurl::isRelative_data() +void tst_QUrl::isRelative_data() { generateFirstRunData(); } -void tst_qurl::isRelative() +void tst_QUrl::isRelative() { QFETCH(bool, firstRun); if (firstRun) { @@ -103,12 +78,12 @@ void tst_qurl::isRelative() } } -void tst_qurl::toLocalFile_data() +void tst_QUrl::toLocalFile_data() { generateFirstRunData(); } -void tst_qurl::toLocalFile() +void tst_QUrl::toLocalFile() { QFETCH(bool, firstRun); if (firstRun) { @@ -124,12 +99,12 @@ void tst_qurl::toLocalFile() } } -void tst_qurl::toString_data() +void tst_QUrl::toString_data() { generateFirstRunData(); } -void tst_qurl::toString() +void tst_QUrl::toString() { QFETCH(bool, firstRun); if(firstRun) { @@ -145,35 +120,37 @@ void tst_qurl::toString() } } -void tst_qurl::resolved_data() +void tst_QUrl::resolved_data() { generateFirstRunData(); } -void tst_qurl::resolved() +void tst_QUrl::resolved() { QFETCH(bool, firstRun); - if(firstRun) { + QUrl expect("/home/user/pics/avatar.png"), actual; + if (firstRun) { QBENCHMARK { QUrl baseUrl("/home/user/"); QUrl url("pics/avatar.png"); - baseUrl.resolved(url); + actual = baseUrl.resolved(url); } } else { QUrl baseUrl("/home/user/"); QUrl url("pics/avatar.png"); QBENCHMARK { - baseUrl.resolved(url); + actual = baseUrl.resolved(url); } } + QCOMPARE(actual, expect); } -void tst_qurl::equality_data() +void tst_QUrl::equality_data() { generateFirstRunData(); } -void tst_qurl::equality() +void tst_QUrl::equality() { QFETCH(bool, firstRun); if(firstRun) { @@ -186,12 +163,12 @@ void tst_qurl::equality() QUrl url("pics/avatar.png"); QUrl url2("pics/avatar2.png"); QBENCHMARK { - url == url2; + [[maybe_unused]] auto r = url == url2; } } } -void tst_qurl::qmlPropertyWriteUseCase() +void tst_QUrl::qmlPropertyWriteUseCase() { QUrl base("file:///home/user/qt/examples/declarative/samegame/SamegameCore/"); QString str("pics/redStar.png"); @@ -203,6 +180,6 @@ void tst_qurl::qmlPropertyWriteUseCase() } } -QTEST_MAIN(tst_qurl) +QTEST_MAIN(tst_QUrl) -#include "main.moc" +#include "tst_bench_qurl.moc" |