From 57368c7037c6d2a6c8cc18d9d41399bf740abe5c Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 20 Sep 2011 13:13:34 +1000 Subject: [PATCH] Improve globaldata testlib selftest. Make the test use qDebug instead of printf, so that the reference test output is the same regardless of whether the log goes to the console or a file. Also rename the test class, as it was evidently cut-n-pasted from the subtest selftest without being renamed. Change-Id: I8df1f0989f2e8c33c1f829ba8110fd740ff70f63 Reviewed-on: http://codereview.qt-project.org/5184 Reviewed-by: Rohan McGovern --- .../selftests/expected_globaldata.lightxml | 128 ++++++++++++++++- .../testlib/selftests/expected_globaldata.txt | 88 ++++++------ .../testlib/selftests/expected_globaldata.xml | 130 +++++++++++++++++- .../selftests/expected_globaldata.xunitxml | 73 +++++++++- .../selftests/globaldata/tst_globaldata.cpp | 59 ++++---- 5 files changed, 394 insertions(+), 84 deletions(-) diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml index c4db4bc90c..df9394edbe 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.lightxml +++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml @@ -3,30 +3,152 @@ @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_globaldata.txt b/tests/auto/testlib/selftests/expected_globaldata.txt index 983376b261..75ceb2c0ce 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.txt +++ b/tests/auto/testlib/selftests/expected_globaldata.txt @@ -1,45 +1,45 @@ -********* Start testing of tst_Subtest ********* -Config: Using QTest library 4.3.0, Qt 4.3.0 -initTestCase initTestCase (null) -PASS : tst_Subtest::initTestCase() -init testGlobal local 1 -global: 0 -local: 0 -cleanup testGlobal local 1 -init testGlobal local 2 -global: 0 -local: 1 -cleanup testGlobal local 2 -init testGlobal local 1 -global: 1 -local: 0 -cleanup testGlobal local 1 -init testGlobal local 2 -global: 1 -local: 1 -cleanup testGlobal local 2 -PASS : tst_Subtest::testGlobal() -SKIP : tst_Subtest::skip(1) skipping - Loc: [/home/fenglich/dev/qt-4.3/tests/auto/selftests/globaldata/tst_globaldata.cpp(95)] -init skipLocal local 1 -SKIP : tst_Subtest::skipLocal(1:local 1) skipping - Loc: [/home/fenglich/dev/qt-4.3/tests/auto/selftests/globaldata/tst_globaldata.cpp(115)] -cleanup skipLocal local 1 -init skipSingle local 1 -global: 0, local 0 -cleanup skipSingle local 1 -init skipSingle local 2 -global: 0, local 1 -cleanup skipSingle local 2 -init skipSingle local 1 -SKIP : tst_Subtest::skipSingle(2:local 1) skipping - Loc: [/home/fenglich/dev/qt-4.3/tests/auto/selftests/globaldata/tst_globaldata.cpp(109)] -cleanup skipSingle local 1 -init skipSingle local 2 -global: 1, local 1 -cleanup skipSingle local 2 -PASS : tst_Subtest::skipSingle() -cleanupTestCase cleanupTestCase (null) -PASS : tst_Subtest::cleanupTestCase() +********* Start testing of tst_globaldata ********* +Config: Using QTest library 5.0.0, Qt 5.0.0 +QDEBUG : tst_globaldata::initTestCase() initTestCase initTestCase (null) +PASS : tst_globaldata::initTestCase() +QDEBUG : tst_globaldata::testGlobal(1:local 1) init testGlobal local 1 +QDEBUG : tst_globaldata::testGlobal(1:local 1) global: false +QDEBUG : tst_globaldata::testGlobal(1:local 1) local: false +QDEBUG : tst_globaldata::testGlobal(1:local 1) cleanup testGlobal local 1 +QDEBUG : tst_globaldata::testGlobal(1:local 2) init testGlobal local 2 +QDEBUG : tst_globaldata::testGlobal(1:local 2) global: false +QDEBUG : tst_globaldata::testGlobal(1:local 2) local: true +QDEBUG : tst_globaldata::testGlobal(1:local 2) cleanup testGlobal local 2 +QDEBUG : tst_globaldata::testGlobal(2:local 1) init testGlobal local 1 +QDEBUG : tst_globaldata::testGlobal(2:local 1) global: true +QDEBUG : tst_globaldata::testGlobal(2:local 1) local: false +QDEBUG : tst_globaldata::testGlobal(2:local 1) cleanup testGlobal local 1 +QDEBUG : tst_globaldata::testGlobal(2:local 2) init testGlobal local 2 +QDEBUG : tst_globaldata::testGlobal(2:local 2) global: true +QDEBUG : tst_globaldata::testGlobal(2:local 2) local: true +QDEBUG : tst_globaldata::testGlobal(2:local 2) cleanup testGlobal local 2 +PASS : tst_globaldata::testGlobal() +SKIP : tst_globaldata::skip(1) skipping + Loc: [/home/dev/qt5/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(129)] +QDEBUG : tst_globaldata::skipLocal(1:local 1) init skipLocal local 1 +SKIP : tst_globaldata::skipLocal(1:local 1) skipping + Loc: [/home/dev/qt5/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(149)] +QDEBUG : tst_globaldata::skipLocal(1:local 1) cleanup skipLocal local 1 +QDEBUG : tst_globaldata::skipSingle(1:local 1) init skipSingle local 1 +QDEBUG : tst_globaldata::skipSingle(1:local 1) global: false local: false +QDEBUG : tst_globaldata::skipSingle(1:local 1) cleanup skipSingle local 1 +QDEBUG : tst_globaldata::skipSingle(1:local 2) init skipSingle local 2 +QDEBUG : tst_globaldata::skipSingle(1:local 2) global: false local: true +QDEBUG : tst_globaldata::skipSingle(1:local 2) cleanup skipSingle local 2 +QDEBUG : tst_globaldata::skipSingle(2:local 1) init skipSingle local 1 +SKIP : tst_globaldata::skipSingle(2:local 1) skipping + Loc: [/home/dev/qt5/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp(143)] +QDEBUG : tst_globaldata::skipSingle(2:local 1) cleanup skipSingle local 1 +QDEBUG : tst_globaldata::skipSingle(2:local 2) init skipSingle local 2 +QDEBUG : tst_globaldata::skipSingle(2:local 2) global: true local: true +QDEBUG : tst_globaldata::skipSingle(2:local 2) cleanup skipSingle local 2 +PASS : tst_globaldata::skipSingle() +QDEBUG : tst_globaldata::cleanupTestCase() cleanupTestCase cleanupTestCase (null) +PASS : tst_globaldata::cleanupTestCase() Totals: 4 passed, 0 failed, 3 skipped -********* Finished testing of tst_Subtest ********* +********* Finished testing of tst_globaldata ********* diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml index ea4beb1886..7a3d9d4ded 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xml +++ b/tests/auto/testlib/selftests/expected_globaldata.xml @@ -1,35 +1,157 @@ - + @INSERT_QT_VERSION_HERE@ @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml index d88fdbffa6..eade59734f 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml +++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml @@ -1,24 +1,89 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp index 296f4d674a..18b91ccfe5 100644 --- a/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp +++ b/tests/auto/testlib/selftests/globaldata/tst_globaldata.cpp @@ -42,8 +42,9 @@ #include #include +#include -class tst_Subtest: public QObject +class tst_globaldata: public QObject { Q_OBJECT public slots: @@ -69,57 +70,57 @@ private slots: }; -void tst_Subtest::initTestCase() +void tst_globaldata::initTestCase() { - printf("initTestCase %s %s\n", - QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)", - QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); + qDebug() << "initTestCase" + << (QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)") + << (QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); } -void tst_Subtest::initTestCase_data() +void tst_globaldata::initTestCase_data() { QTest::addColumn("booli"); QTest::newRow("1") << false; QTest::newRow("2") << true; } -void tst_Subtest::cleanupTestCase() +void tst_globaldata::cleanupTestCase() { - printf("cleanupTestCase %s %s\n", - QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)", - QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); + qDebug() << "cleanupTestCase" + << (QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)") + << (QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); } -void tst_Subtest::init() +void tst_globaldata::init() { - printf("init %s %s\n", - QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)", - QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); + qDebug() << "init" + << (QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)") + << (QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); } -void tst_Subtest::cleanup() +void tst_globaldata::cleanup() { - printf("cleanup %s %s\n", - QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)", - QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); + qDebug() << "cleanup" + << (QTest::currentTestFunction() ? QTest::currentTestFunction() : "(null)") + << (QTest::currentDataTag() ? QTest::currentDataTag() : "(null)"); } -void tst_Subtest::testGlobal_data() +void tst_globaldata::testGlobal_data() { QTest::addColumn("booll"); QTest::newRow("local 1") << false; QTest::newRow("local 2") << true; } -void tst_Subtest::testGlobal() +void tst_globaldata::testGlobal() { QFETCH_GLOBAL(bool, booli); - printf("global: %d\n", booli); + qDebug() << "global:" << booli; QFETCH(bool, booll); - printf("local: %d\n", booll); + qDebug() << "local:" << booll; } -void tst_Subtest::skip_data() +void tst_globaldata::skip_data() { QTest::addColumn("booll"); QTest::newRow("local 1") << false; @@ -128,26 +129,26 @@ void tst_Subtest::skip_data() QSKIP("skipping", SkipAll); } -void tst_Subtest::skip() +void tst_globaldata::skip() { - printf("this line should never be reached\n"); + qDebug() << "this line should never be reached"; } -void tst_Subtest::skipSingle() +void tst_globaldata::skipSingle() { QFETCH_GLOBAL(bool, booli); QFETCH(bool, booll); if (booli && !booll) QSKIP("skipping", SkipSingle); - printf("global: %d, local %d\n", booli, booll); + qDebug() << "global:" << booli << "local:" << booll; } -void tst_Subtest::skipLocal() +void tst_globaldata::skipLocal() { QSKIP("skipping", SkipAll); } -QTEST_MAIN(tst_Subtest) +QTEST_MAIN(tst_globaldata) #include "tst_globaldata.moc"