aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-05-08 21:04:03 +0100
committerSergio Martins <smartins@kde.org>2019-05-08 21:04:03 +0100
commit23c0a5122a6e6a7b87cb9c6513f1745c511e230e (patch)
tree67f3a6e3812fe30959d53c140082f4634c7217df
parent68daa24912ef0d0791826eec4a2ea93cde840fa0 (diff)
range-loop: unit-tests++
-rw-r--r--tests/range-loop/main.cpp3
-rw-r--r--tests/range-loop/main.cpp.expected1
-rw-r--r--tests/range-loop/main.cpp.fixed.expected5
3 files changed, 8 insertions, 1 deletions
diff --git a/tests/range-loop/main.cpp b/tests/range-loop/main.cpp
index b5980b3f..64060756 100644
--- a/tests/range-loop/main.cpp
+++ b/tests/range-loop/main.cpp
@@ -242,5 +242,8 @@ void test_add_qasconst_fixits()
void test_json_array()
{
QJsonArray array;
+ const QJsonArray const_array;
for (const auto a : array) {} // OK
+ for (const QJsonValue a : const_array) {} // Warn
+ for (const QJsonValue &a : const_array) {} // OK
}
diff --git a/tests/range-loop/main.cpp.expected b/tests/range-loop/main.cpp.expected
index 94e1959b..59f12f48 100644
--- a/tests/range-loop/main.cpp.expected
+++ b/tests/range-loop/main.cpp.expected
@@ -12,3 +12,4 @@ range-loop/main.cpp:228:5: warning: c++11 range-loop might detach Qt container (
range-loop/main.cpp:231:5: warning: c++11 range-loop might detach Qt container (QStringList) [-Wclazy-range-loop]
range-loop/main.cpp:236:5: warning: c++11 range-loop might detach Qt container (QList) [-Wclazy-range-loop]
range-loop/main.cpp:238:5: warning: c++11 range-loop might detach Qt container (QStringList) [-Wclazy-range-loop]
+range-loop/main.cpp:247:10: warning: Missing reference in range-for with non trivial type (QJsonValue) [-Wclazy-range-loop]
diff --git a/tests/range-loop/main.cpp.fixed.expected b/tests/range-loop/main.cpp.fixed.expected
index b8bc3682..b1a8a662 100644
--- a/tests/range-loop/main.cpp.fixed.expected
+++ b/tests/range-loop/main.cpp.fixed.expected
@@ -242,5 +242,8 @@ void test_add_qasconst_fixits()
void test_json_array()
{
QJsonArray array;
- for (const auto a : array) {}
+ const QJsonArray const_array;
+ for (const auto a : array) {} // OK
+ for (const QJsonValue &a : const_array) {} // Warn
+ for (const QJsonValue &a : const_array) {} // OK
}