From 6fbf50248db858cf47dddd8b917685f757b83a97 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 24 May 2019 11:43:29 +0200 Subject: Brush up tst_QUrl Fix clang-tidy warnings: - Use range-based for and streamline some code - Use nullptr Change-Id: Iad43490d0e968baa76d54d3bf81558a48b19cdbd Reviewed-by: Kari Oikarinen --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index daaa5516cd..3123c42326 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2192,10 +2192,12 @@ void tst_QUrl::schemeValidator_data() QTest::newRow("percent-encoded") << "%68%74%%74%70://example.com" << false << "%68%74%%74%70"; static const char controls[] = "!\"$&'()*,;<=>[\\]^_`{|}~"; - for (size_t i = 0; i < sizeof(controls) - 1; ++i) - QTest::newRow(("with-" + QByteArray(1, controls[i])).constData()) - << QString("pre%1post://example.com/").arg(QLatin1Char(controls[i])) - << false << QString("pre%1post").arg(QLatin1Char(controls[i])); + for (char control : controls) { + const QString scheme = QLatin1String("pre") + QLatin1Char(control) + QLatin1String("post"); + QTest::newRow((QByteArrayLiteral("with-") + control).constData()) + << (scheme + QLatin1String("://example.com/")) + << false << scheme; + } } void tst_QUrl::schemeValidator() @@ -4074,13 +4076,12 @@ public: QVector m_urls; }; -static const UrlStorage * s_urlStorage = 0; +static const UrlStorage * s_urlStorage = nullptr; void tst_QUrl::testThreadingHelper() { const UrlStorage* storage = s_urlStorage; - for (int i = 0 ; i < storage->m_urls.size(); ++i ) { - const QUrl& u = storage->m_urls.at(i); + for (const auto &u : storage->m_urls) { // QVERIFY/QCOMPARE trigger race conditions in helgrind if (!u.isValid()) qFatal("invalid url"); -- cgit v1.2.3