From b9924e2b4b3544ea494925576a421cd9a5fce94f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 13 Jun 2019 13:16:35 +0200 Subject: 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 --- src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp | 5 +++-- 1 file 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 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()); -- cgit v1.2.3