From 0afe9907149b94d8cc4600f1a2b23b99067d030f Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 3 Jan 2012 15:16:14 +1000 Subject: 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 --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index ac2345d002..f16dcd1ccc 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -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() -- cgit v1.2.3