From d72ff6ffd0e6f04dcd614b020f9abbe129615f8c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 16 Oct 2020 10:44:59 +0200 Subject: [PATCH] Fix some compiler warnings from tests For iterators that return a value, don't use reference in ranged for, and cast numeric literal to correct size type for QCOMPARE. Change-Id: Idfd09dbc2ef3ab1bf025c7859ea6e2e9572bc9a1 Reviewed-by: Lars Knoll --- .../auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp | 2 +- tests/auto/corelib/text/qstringview/tst_qstringview.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 13bf66022d1..e3be6d3fabc 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -790,7 +790,7 @@ void tst_QCborValue::arrayInitializerList() // range for int i = 0; - for (const QCborValue &v : qAsConst(a)) { + for (const QCborValue v : qAsConst(a)) { QVERIFY(!v.isInvalid()); QCOMPARE(v.isUndefined(), i == 5); // 6th element is Undefined ++i; diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index b08d9ce8d94..c2a69c2a984 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -426,9 +426,9 @@ void tst_QStringView::literals() const } // these are different results - QCOMPARE(size_t(QStringView(withnull).size()), 1); + QCOMPARE(size_t(QStringView(withnull).size()), size_t(1)); QCOMPARE(size_t(QStringView::fromArray(withnull).size()), sizeof(withnull)/sizeof(withnull[0])); - QCOMPARE(QStringView(withnull + 0).size(), 1); + QCOMPARE(QStringView(withnull + 0).size(), qsizetype(1)); } void tst_QStringView::fromArray() const