diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-12-30 15:51:05 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-03 02:57:12 +0100 |
commit | fda36df6babf20bcfd04a54a1336a9c26e72a8ef (patch) | |
tree | 0c09018e6db15ea40e156b38854e224e62e9130f /tests/auto/corelib | |
parent | 39f3ee8a5dd499cf86f95e7fc9200eb3226b16be (diff) |
Use true and false in preference to TRUE and FALSE in tests.
Use the C++ boolean constants true and false instead of the C macros
TRUE and FALSE (which are actually integers), and use QVERIFY instead of
QCOMPARE for verifying simple boolean expressions.
Change-Id: Ie76dfcab6722df6b93b3fa62b0f3437901482932
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp | 74 | ||||
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 24 | ||||
-rw-r--r-- | tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 156 | ||||
-rw-r--r-- | tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp | 16 |
5 files changed, 136 insertions, 136 deletions
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index 9e7e93255d..6e91780ecc 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -873,7 +873,7 @@ static void QBitArrayData(QBitArray *b, int index) for (int i = 0; i < filler.length(); ++i) { if (filler.at(i) == '1') - b->setBit(i, TRUE); + b->setBit(i, true); } } @@ -1313,83 +1313,83 @@ void tst_QDataStream::readQDateTime(QDataStream *s) static QFont qFontData(int index) { switch (index) { - case 0: return QFont("Courier", 20, QFont::Bold, TRUE); - case 1: return QFont("Courier", 18, QFont::Bold, FALSE); - case 2: return QFont("Courier", 16, QFont::Light, TRUE); - case 3: return QFont("Courier", 14, QFont::Normal, FALSE); - case 4: return QFont("Courier", 12, QFont::DemiBold, TRUE); - case 5: return QFont("Courier", 10, QFont::Black, FALSE); + case 0: return QFont("Courier", 20, QFont::Bold, true); + case 1: return QFont("Courier", 18, QFont::Bold, false); + case 2: return QFont("Courier", 16, QFont::Light, true); + case 3: return QFont("Courier", 14, QFont::Normal, false); + case 4: return QFont("Courier", 12, QFont::DemiBold, true); + case 5: return QFont("Courier", 10, QFont::Black, false); case 6: { - QFont f("Helvetica", 10, QFont::Normal, FALSE); + QFont f("Helvetica", 10, QFont::Normal, false); f.setPixelSize(2); - f.setUnderline(FALSE); - f.setStrikeOut(FALSE); - f.setFixedPitch(FALSE); + f.setUnderline(false); + f.setStrikeOut(false); + f.setFixedPitch(false); return f; } case 7: { - QFont f("Helvetica", 10, QFont::Bold, FALSE); + QFont f("Helvetica", 10, QFont::Bold, false); f.setPixelSize(4); - f.setUnderline(TRUE); - f.setStrikeOut(FALSE); - f.setFixedPitch(FALSE); + f.setUnderline(true); + f.setStrikeOut(false); + f.setFixedPitch(false); return f; } case 8: { - QFont f("Helvetica", 10, QFont::Light, FALSE); + QFont f("Helvetica", 10, QFont::Light, false); f.setPixelSize(6); - f.setUnderline(FALSE); - f.setStrikeOut(TRUE); - f.setFixedPitch(FALSE); + f.setUnderline(false); + f.setStrikeOut(true); + f.setFixedPitch(false); return f; } case 9: { - QFont f("Helvetica", 10, QFont::DemiBold, FALSE); + QFont f("Helvetica", 10, QFont::DemiBold, false); f.setPixelSize(8); - f.setUnderline(FALSE); - f.setStrikeOut(FALSE); - f.setFixedPitch(TRUE); + f.setUnderline(false); + f.setStrikeOut(false); + f.setFixedPitch(true); return f; } case 10: { - QFont f("Helvetica", 10, QFont::Black, FALSE); + QFont f("Helvetica", 10, QFont::Black, false); f.setPixelSize(10); - f.setUnderline(TRUE); - f.setStrikeOut(TRUE); - f.setFixedPitch(FALSE); + f.setUnderline(true); + f.setStrikeOut(true); + f.setFixedPitch(false); return f; } case 11: { - QFont f("Helvetica", 10, QFont::Normal, TRUE); + QFont f("Helvetica", 10, QFont::Normal, true); f.setPixelSize(12); - f.setUnderline(FALSE); - f.setStrikeOut(TRUE); - f.setFixedPitch(TRUE); + f.setUnderline(false); + f.setStrikeOut(true); + f.setFixedPitch(true); return f; } case 12: { - QFont f("Helvetica", 10, QFont::Bold, TRUE); + QFont f("Helvetica", 10, QFont::Bold, true); f.setPixelSize(14); - f.setUnderline(TRUE); - f.setStrikeOut(TRUE); - f.setFixedPitch(TRUE); + f.setUnderline(true); + f.setStrikeOut(true); + f.setFixedPitch(true); return f; } case 13: { - QFont f("Helvetica", 10, QFont::Bold, TRUE); + QFont f("Helvetica", 10, QFont::Bold, true); f.setStretch(200); return f; } } - return QFont("Courier", 18, QFont::Bold, TRUE); + return QFont("Courier", 18, QFont::Bold, true); } #define MAX_QFONT_DATA 14 diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index cae97f80c4..ccdbc85293 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -404,7 +404,7 @@ void tst_QFile::cleanupTestCase() void tst_QFile::exists() { QFile f( QFINDTESTDATA("testfile.txt") ); - QCOMPARE( f.exists(), (bool)TRUE ); + QVERIFY(f.exists()); QFile file("nobodyhassuchafile"); file.remove(); @@ -443,41 +443,41 @@ void tst_QFile::open_data() #endif QTest::newRow( "exist_readOnly" ) << QString(QFINDTESTDATA("testfile.txt")) << int(QIODevice::ReadOnly) - << (bool)TRUE << QFile::NoError; + << true << QFile::NoError; QTest::newRow( "exist_writeOnly" ) << QString("readonlyfile") << int(QIODevice::WriteOnly) - << (bool)FALSE + << false << QFile::OpenError; QTest::newRow( "exist_append" ) << QString("readonlyfile") << int(QIODevice::Append) - << (bool)FALSE << QFile::OpenError; + << false << QFile::OpenError; QTest::newRow( "nonexist_readOnly" ) << QString("nonExist.txt") << int(QIODevice::ReadOnly) - << (bool)FALSE << QFile::OpenError; + << false << QFile::OpenError; QTest::newRow("emptyfile") << QString("") << int(QIODevice::ReadOnly) - << (bool)FALSE + << false << QFile::OpenError; - QTest::newRow("nullfile") << QString() << int(QIODevice::ReadOnly) << (bool)FALSE + QTest::newRow("nullfile") << QString() << int(QIODevice::ReadOnly) << false << QFile::OpenError; - QTest::newRow("two-dots") << QString(QFINDTESTDATA("two.dots.file")) << int(QIODevice::ReadOnly) << (bool)TRUE + QTest::newRow("two-dots") << QString(QFINDTESTDATA("two.dots.file")) << int(QIODevice::ReadOnly) << true << QFile::NoError; QTest::newRow("readonlyfile") << QString("readonlyfile") << int(QIODevice::WriteOnly) - << (bool)FALSE << QFile::OpenError; + << false << QFile::OpenError; QTest::newRow("noreadfile") << QString("noreadfile") << int(QIODevice::ReadOnly) - << (bool)FALSE << QFile::OpenError; + << false << QFile::OpenError; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly) - << (bool)TRUE << QFile::NoError; + << true << QFile::NoError; QTest::newRow("uncFile") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" << int(QIODevice::ReadOnly) << true << QFile::NoError; #endif @@ -694,7 +694,7 @@ void tst_QFile::atEnd() bool end = f.atEnd(); f.close(); - QCOMPARE( end, (bool)TRUE ); + QVERIFY(end); } void tst_QFile::readLine() diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 58e0b4f5b4..ac2345d002 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -3158,7 +3158,7 @@ void tst_QSettings::consistentRegistryStorage() // Not tested at the moment. void tst_QSettings::oldSubkeyList() { - QVERIFY( TRUE ); + QVERIFY( true ); } */ diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 2c99d1b556..7d54409c23 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -260,10 +260,10 @@ void tst_QObject::disconnect() s->emitSignal3(); s->emitSignal4(); - QCOMPARE( r1->called(1), TRUE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r1->called(3), TRUE ); - QCOMPARE( r1->called(4), TRUE ); + QVERIFY(r1->called(1)); + QVERIFY(r1->called(2)); + QVERIFY(r1->called(3)); + QVERIFY(r1->called(4)); r1->reset(); // usual disconnect with all parameters given @@ -271,12 +271,12 @@ void tst_QObject::disconnect() s->emitSignal1(); - QCOMPARE( r1->called(1), FALSE ); + QVERIFY(!r1->called(1)); r1->reset(); - QCOMPARE( ret, TRUE ); + QVERIFY(ret); ret = QObject::disconnect( s, SIGNAL( signal1() ), r1, SLOT( slot1() ) ); - QCOMPARE( ret, FALSE ); + QVERIFY(!ret); // disconnect all signals from s from all slots from r1 QObject::disconnect( s, 0, r1, 0 ); @@ -285,9 +285,9 @@ void tst_QObject::disconnect() s->emitSignal3(); s->emitSignal4(); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r1->called(3), FALSE ); - QCOMPARE( r1->called(4), FALSE ); + QVERIFY(!r1->called(2)); + QVERIFY(!r1->called(3)); + QVERIFY(!r1->called(4)); r1->reset(); connect( s, SIGNAL( signal1() ), r1, SLOT( slot1() ) ); @@ -301,10 +301,10 @@ void tst_QObject::disconnect() s->emitSignal1(); s->emitSignal2(); - QCOMPARE( r1->called(1), FALSE ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r1->called(3), FALSE ); - QCOMPARE( r1->called(4), TRUE ); + QVERIFY(!r1->called(1)); + QVERIFY(!r1->called(2)); + QVERIFY(!r1->called(3)); + QVERIFY(r1->called(4)); r1->reset(); // make sure all is disconnected again QObject::disconnect( s, 0, r1, 0 ); @@ -322,12 +322,12 @@ void tst_QObject::disconnect() s->emitSignal2(); s->emitSignal3(); - QCOMPARE( r1->called(1), FALSE ); - QCOMPARE( r2->called(1), FALSE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r2->called(2), TRUE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r2->called(2), TRUE ); + QVERIFY(!r1->called(1)); + QVERIFY(!r2->called(1)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); r1->reset(); r2->reset(); @@ -335,10 +335,10 @@ void tst_QObject::disconnect() // disconnect all signals of s from all receivers QObject::disconnect( s, 0, 0, 0 ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r2->called(2), FALSE ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r2->called(2), FALSE ); + QVERIFY(!r1->called(2)); + QVERIFY(!r2->called(2)); + QVERIFY(!r1->called(2)); + QVERIFY(!r2->called(2)); delete r2; delete r1; @@ -979,14 +979,14 @@ void tst_QObject::emitInDefinedOrder() SequenceObject::sequence = sequence = 0; sender2->emitSignal1(); - QCOMPARE(seq1.called(1), TRUE); - QCOMPARE(seq2.called(1), TRUE); - QCOMPARE(seq3->called(1), FALSE); - QCOMPARE(seq4.called(1), TRUE); - QCOMPARE(seq1.called(2), TRUE); - QCOMPARE(seq2.called(2), TRUE); - QCOMPARE(seq3->called(2), FALSE); - QCOMPARE(seq4.called(2), TRUE); + QVERIFY(seq1.called(1)); + QVERIFY(seq2.called(1)); + QVERIFY(!seq3->called(1)); + QVERIFY(seq4.called(1)); + QVERIFY(seq1.called(2)); + QVERIFY(seq2.called(2)); + QVERIFY(!seq3->called(2)); + QVERIFY(seq4.called(2)); QCOMPARE(seq1.sequence_slot1, ++sequence); QCOMPARE(seq2.sequence_slot1, ++sequence); QCOMPARE(seq4.sequence_slot1, ++sequence); @@ -1015,14 +1015,14 @@ void tst_QObject::emitInDefinedOrder() SequenceObject::sequence = sequence = 0; sender2->emitSignal1(); - QCOMPARE(seq1.called(2), TRUE); - QCOMPARE(seq2.called(2), TRUE); - QCOMPARE(seq3->called(2), FALSE); - QCOMPARE(seq4.called(2), TRUE); - QCOMPARE(seq1.called(1), TRUE); - QCOMPARE(seq2.called(1), TRUE); - QCOMPARE(seq3->called(1), FALSE); - QCOMPARE(seq4.called(1), TRUE); + QVERIFY(seq1.called(2)); + QVERIFY(seq2.called(2)); + QVERIFY(!seq3->called(2)); + QVERIFY(seq4.called(2)); + QVERIFY(seq1.called(1)); + QVERIFY(seq2.called(1)); + QVERIFY(!seq3->called(1)); + QVERIFY(seq4.called(1)); QCOMPARE(seq1.sequence_slot2, ++sequence); QCOMPARE(seq2.sequence_slot2, ++sequence); QCOMPARE(seq4.sequence_slot2, ++sequence); @@ -1051,14 +1051,14 @@ void tst_QObject::emitInDefinedOrder() SequenceObject::sequence = sequence = 0; sender2->emitSignal1(); - QCOMPARE(seq1.called(1), TRUE); - QCOMPARE(seq2.called(1), TRUE); - QCOMPARE(seq3->called(1), FALSE); - QCOMPARE(seq4.called(1), TRUE); - QCOMPARE(seq1.called(2), TRUE); - QCOMPARE(seq2.called(2), TRUE); - QCOMPARE(seq3->called(2), FALSE); - QCOMPARE(seq4.called(2), TRUE); + QVERIFY(seq1.called(1)); + QVERIFY(seq2.called(1)); + QVERIFY(!seq3->called(1)); + QVERIFY(seq4.called(1)); + QVERIFY(seq1.called(2)); + QVERIFY(seq2.called(2)); + QVERIFY(!seq3->called(2)); + QVERIFY(seq4.called(2)); QCOMPARE(seq1.sequence_slot1, ++sequence); QCOMPARE(seq2.sequence_slot1, ++sequence); QCOMPARE(seq4.sequence_slot1, ++sequence); @@ -1092,12 +1092,12 @@ void tst_QObject::emitInDefinedOrder() sender2->emitSignal1(); QCOMPARE(static_cast<QObject *>(psender), static_cast<QObject *>(0)); QCOMPARE(static_cast<QObject *>(pseq3), static_cast<QObject *>(0)); - QCOMPARE(seq1.called(1), TRUE); - QCOMPARE(seq2.called(1), TRUE); - QCOMPARE(seq4.called(1), TRUE); - QCOMPARE(seq1.called(2), TRUE); - QCOMPARE(seq2.called(2), TRUE); - QCOMPARE(seq4.called(2), FALSE); + QVERIFY(seq1.called(1)); + QVERIFY(seq2.called(1)); + QVERIFY(seq4.called(1)); + QVERIFY(seq1.called(2)); + QVERIFY(seq2.called(2)); + QVERIFY(!seq4.called(2)); QCOMPARE(seq1.sequence_slot1, ++sequence); QCOMPARE(seq2.sequence_slot1, ++sequence); QCOMPARE(seq4.sequence_slot1, ++sequence); @@ -4209,10 +4209,10 @@ void tst_QObject::pointerDisconnect() s->emitSignal3(); s->emitSignal4(); - QCOMPARE( r1->called(1), TRUE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r1->called(3), TRUE ); - QCOMPARE( r1->called(4), TRUE ); + QVERIFY(r1->called(1)); + QVERIFY(r1->called(2)); + QVERIFY(r1->called(3)); + QVERIFY(r1->called(4)); r1->reset(); // usual disconnect with all parameters given @@ -4220,12 +4220,12 @@ void tst_QObject::pointerDisconnect() s->emitSignal1(); - QCOMPARE( r1->called(1), FALSE ); + QVERIFY(!r1->called(1)); r1->reset(); - QCOMPARE( ret, TRUE ); + QVERIFY(ret); ret = QObject::disconnect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); - QCOMPARE( ret, FALSE ); + QVERIFY(!ret); // disconnect all signals from s from all slots from r1 QObject::disconnect( s, 0, r1, 0 ); @@ -4234,9 +4234,9 @@ void tst_QObject::pointerDisconnect() s->emitSignal3(); s->emitSignal4(); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r1->called(3), FALSE ); - QCOMPARE( r1->called(4), FALSE ); + QVERIFY(!r1->called(2)); + QVERIFY(!r1->called(3)); + QVERIFY(!r1->called(4)); r1->reset(); connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); @@ -4250,10 +4250,10 @@ void tst_QObject::pointerDisconnect() s->emitSignal1(); s->emitSignal2(); - QCOMPARE( r1->called(1), FALSE ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r1->called(3), FALSE ); - QCOMPARE( r1->called(4), TRUE ); + QVERIFY(!r1->called(1)); + QVERIFY(!r1->called(2)); + QVERIFY(!r1->called(3)); + QVERIFY(r1->called(4)); r1->reset(); // make sure all is disconnected again QObject::disconnect( s, 0, r1, 0 ); @@ -4271,12 +4271,12 @@ void tst_QObject::pointerDisconnect() s->emitSignal2(); s->emitSignal3(); - QCOMPARE( r1->called(1), FALSE ); - QCOMPARE( r2->called(1), FALSE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r2->called(2), TRUE ); - QCOMPARE( r1->called(2), TRUE ); - QCOMPARE( r2->called(2), TRUE ); + QVERIFY(!r1->called(1)); + QVERIFY(!r2->called(1)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); r1->reset(); r2->reset(); @@ -4284,10 +4284,10 @@ void tst_QObject::pointerDisconnect() // disconnect all signals of s from all receivers QObject::disconnect( s, 0, 0, 0 ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r2->called(2), FALSE ); - QCOMPARE( r1->called(2), FALSE ); - QCOMPARE( r2->called(2), FALSE ); + QVERIFY(!r1->called(2)); + QVERIFY(!r2->called(2)); + QVERIFY(!r1->called(2)); + QVERIFY(!r2->called(2)); delete r2; delete r1; diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp index 4ffde9fcb8..4237b41e57 100644 --- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -443,7 +443,7 @@ void tst_QWaitCondition::wakeOne() for (x = 0; x < ThreadCount; ++x) { thread[x].mutex = &mutex; thread[x].cond = &cond; - thread_exited[x] = FALSE; + thread_exited[x] = false; thread[x].start(); // wait for thread to start QVERIFY(thread[x].started.wait(&mutex, 1000)); @@ -468,7 +468,7 @@ void tst_QWaitCondition::wakeOne() if (thread_exited[y]) continue; if (thread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = TRUE; + thread_exited[y] = true; ++exited; } } @@ -487,7 +487,7 @@ void tst_QWaitCondition::wakeOne() for (x = 0; x < ThreadCount; ++x) { rwthread[x].readWriteLock = &readWriteLock; rwthread[x].cond = &cond; - thread_exited[x] = FALSE; + thread_exited[x] = false; rwthread[x].start(); // wait for thread to start QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); @@ -512,7 +512,7 @@ void tst_QWaitCondition::wakeOne() if (thread_exited[y]) continue; if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = TRUE; + thread_exited[y] = true; ++exited; } } @@ -537,7 +537,7 @@ void tst_QWaitCondition::wakeOne() for (x = 0; x < ThreadCount; ++x) { thread[x].mutex = &mutex; thread[x].cond = &cond; - thread_exited[x] = FALSE; + thread_exited[x] = false; thread[x].start(); // wait for thread to start QVERIFY(thread[x].started.wait(&mutex, 1000)); @@ -564,7 +564,7 @@ void tst_QWaitCondition::wakeOne() if (thread_exited[y]) continue; if (thread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = TRUE; + thread_exited[y] = true; ++exited; } } @@ -583,7 +583,7 @@ void tst_QWaitCondition::wakeOne() for (x = 0; x < ThreadCount; ++x) { rwthread[x].readWriteLock = &readWriteLock; rwthread[x].cond = &cond; - thread_exited[x] = FALSE; + thread_exited[x] = false; rwthread[x].start(); // wait for thread to start QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); @@ -610,7 +610,7 @@ void tst_QWaitCondition::wakeOne() if (thread_exited[y]) continue; if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = TRUE; + thread_exited[y] = true; ++exited; } } |