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>
This commit is contained in:
Ulf Hermann
2019-06-13 13:16:35 +02:00
parent 66dc831398
commit b9924e2b4b

View File

@@ -140,8 +140,9 @@ 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);
if (id != 0) // Otherwise it's the invalid ID and that means the allocation "failed".
ids.append(id);
QCOMPARE(counter.currentTotal(), ids.length());
}