From ebae6e2041bcbe5b86fa13f779c952896e9c68d6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 21 Jul 2021 18:38:57 +0200 Subject: Assert some more things we can be sure of in the QMap benchmark Just in case the test isn't testing what we think it is. One of my earlier changes didn't until this told me about it. Change-Id: Idd6f415d543509cabb3a64219736bb43e60a70ef Reviewed-by: Giuseppe D'Angelo Reviewed-by: Andrei Golubev --- tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp b/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp index 48321d9eb2..c8df971e3c 100644 --- a/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp +++ b/tests/benchmarks/corelib/tools/qmap/tst_bench_qmap.cpp @@ -95,6 +95,7 @@ void tst_QMap::insertion_int_int() for (int i = 0; i < huge; ++i) map.insert(i, i); } + QCOMPARE(map.size(), qsizetype(huge)); } void tst_QMap::insertion_int_intx() @@ -106,6 +107,7 @@ void tst_QMap::insertion_int_intx() for (int i = 0; i < huge; ++i) map.insert(i, i); } + QCOMPARE(map.size(), qsizetype(huge)); } void tst_QMap::insertion_int_int_with_hint1() @@ -115,6 +117,7 @@ void tst_QMap::insertion_int_int_with_hint1() for (int i = 0; i < huge; ++i) map.insert(map.constEnd(), i, i); } + QCOMPARE(map.size(), qsizetype(huge)); } void tst_QMap::insertion_int_int2() @@ -124,6 +127,7 @@ void tst_QMap::insertion_int_int2() for (int i = huge; i >= 0; --i) map.insert(i, i); } + QCOMPARE(map.size(), qsizetype(huge) + 1); } void tst_QMap::insertion_int_int_with_hint2() @@ -133,6 +137,7 @@ void tst_QMap::insertion_int_int_with_hint2() for (int i = huge; i >= 0; --i) map.insert(map.constBegin(), i, i); } + QCOMPARE(map.size(), qsizetype(huge) + 1); } void tst_QMap::insertion_int_string() @@ -143,16 +148,19 @@ void tst_QMap::insertion_int_string() for (int i = 0; i < huge; ++i) map.insert(i, str); } + QCOMPARE(map.size(), qsizetype(huge)); } void tst_QMap::insertion_string_int() { QMap map; const QStringList names = helloEachWorld(huge); + QCOMPARE(names.size(), qsizetype(huge)); QBENCHMARK { for (int i = 1; i < huge; ++i) map.insert(names.at(i), i); } + QCOMPARE(map.size() + 1, qsizetype(huge)); } void tst_QMap::lookup_int_int() @@ -160,6 +168,7 @@ void tst_QMap::lookup_int_int() QMap map; for (int i = 0; i < huge; ++i) map.insert(i, i); + QCOMPARE(map.size(), qsizetype(huge)); uint sum = 0, count = 0; QBENCHMARK { @@ -176,6 +185,7 @@ void tst_QMap::lookup_int_string() QString str("Hello World"); for (int i = 0; i < huge; ++i) map.insert(i, str); + QCOMPARE(map.size(), qsizetype(huge)); QBENCHMARK { for (int i = 0; i < huge; ++i) @@ -189,6 +199,7 @@ void tst_QMap::lookup_string_int() const QStringList names = helloEachWorld(huge); for (int i = 1; i < huge; ++i) map.insert(names.at(i), i); + QCOMPARE(map.size() + 1, qsizetype(huge)); uint sum = 0, count = 0; QBENCHMARK { @@ -205,6 +216,7 @@ void tst_QMap::iteration() QMap map; for (int i = 0; i < huge; ++i) map.insert(i, i); + QCOMPARE(map.size(), qsizetype(huge)); uint sum = 0, count = 0; QBENCHMARK { @@ -226,6 +238,7 @@ void tst_QMap::toStdMap() QMap map; for (int i = 0; i < huge; ++i) map.insert(i, i); + QCOMPARE(map.size(), qsizetype(huge)); QBENCHMARK { std::map n = map.toStdMap(); @@ -238,6 +251,7 @@ void tst_QMap::iterator_begin() QMap map; for (int i = 0; i < huge; ++i) map.insert(i, i); + QCOMPARE(map.size(), qsizetype(huge)); QBENCHMARK { for (int i = 0; i < huge; ++i) { @@ -254,6 +268,7 @@ void tst_QMap::ctorStdMap() std::map map; for (int i = 0; i < huge; ++i) map.insert(std::pair(i, i)); + QCOMPARE(map.size(), size_t(huge)); QBENCHMARK { QMap qmap(map); @@ -280,6 +295,7 @@ void tst_QMap::insertion_string_int2() map.insert(str, i); } } + QCOMPARE(map.size() + 1, qsizetype(bigish)); } void tst_QMap::insertion_string_int2_hint() @@ -292,6 +308,7 @@ void tst_QMap::insertion_string_int2_hint() map.insert(map.end(), str, i); } } + QCOMPARE(map.size() + 1, qsizetype(bigish)); } void tst_QMap::insertMap() -- cgit v1.2.3