diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2012-01-03 15:16:14 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-04 06:01:33 +0100 |
commit | 0afe9907149b94d8cc4600f1a2b23b99067d030f (patch) | |
tree | 5ba6a857b9676310e43cda641bad68c07be7982e /tests | |
parent | 20f0196a2cddf6927c34d8e3a93ea7ca074c7a53 (diff) |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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() |