Avoid QCOMPARE outside test function in QSettings test.
QCOMPARE and friends should only be called in a test function. Instead of calling QCOMPARE elsewhere, keep a count of the number of errors and QCOMPARE that count with zero in the test function. Change-Id: I9a264e91169a98c30980fdc04a3e45bfb0ca8063 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
20f0196a2c
commit
0afe990714
@ -1694,6 +1694,7 @@ void tst_QSettings::testUpdateRequestEvent()
|
||||
|
||||
const int NumIterations = 5;
|
||||
const int NumThreads = 4;
|
||||
int numThreadSafetyFailures;
|
||||
|
||||
class SettingsThread : public QThread
|
||||
{
|
||||
@ -1711,7 +1712,10 @@ void SettingsThread::run()
|
||||
QSettings settings("software.org", "KillerAPP");
|
||||
settings.setValue(QString::number((param * NumIterations) + i), param);
|
||||
settings.sync();
|
||||
QCOMPARE((int)settings.status(), (int)QSettings::NoError);
|
||||
if (settings.status() != QSettings::NoError) {
|
||||
QWARN(qPrintable(QString("Unexpected QSettings status %1").arg((int)settings.status())));
|
||||
++numThreadSafetyFailures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1720,6 +1724,8 @@ void tst_QSettings::testThreadSafety()
|
||||
SettingsThread threads[NumThreads];
|
||||
int i, j;
|
||||
|
||||
numThreadSafetyFailures = 0;
|
||||
|
||||
for (i = 0; i < NumThreads; ++i)
|
||||
threads[i].start(i + 1);
|
||||
for (i = 0; i < NumThreads; ++i)
|
||||
@ -1732,6 +1738,8 @@ void tst_QSettings::testThreadSafety()
|
||||
QCOMPARE(settings.value(QString::number((param * NumIterations) + j)).toInt(), param);
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(numThreadSafetyFailures, 0);
|
||||
}
|
||||
|
||||
void tst_QSettings::testNormalizedKey_data()
|
||||
|
Loading…
Reference in New Issue
Block a user