aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-06-13 13:16:35 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-06-13 12:12:57 +0000
commitb9924e2b4b3544ea494925576a421cd9a5fce94f (patch)
treea6643a977a5d990c773071aeb1299c0b46f7dbb5
parent66dc83139821a978cf889ffb3a33a3f0fb11e6b0 (diff)
Fix perfresourcecounter test
If qrand() generates a 0, the obtain() is ignored as that is the invalid ID. Change-Id: I608f2687a6ca9a40d905c665a3585bffc1ea5695 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp
index 87d905c880..f242725c35 100644
--- a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp
+++ b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp
@@ -140,9 +140,10 @@ void PerfResourceCounterTest::testUnitSized()
QList<int> ids;
for (int i = 0; i < 10000; ++i) {
counter.request(1);
- int id = qrand();
+ const int id = qrand();
counter.obtain(id);
- ids.append(id);
+ if (id != 0) // Otherwise it's the invalid ID and that means the allocation "failed".
+ ids.append(id);
QCOMPARE(counter.currentTotal(), ids.length());
}
QCOMPARE(sum(container), counter.currentTotal());