summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests/cmptest
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-21 10:55:17 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-07-22 19:32:39 +0000
commit5f5db1c38b288441d02a68f1a095850b42585e04 (patch)
tree98d6b9522ef3d9a7d11ea6940cac6119737d258b /tests/auto/testlib/selftests/cmptest
parentc05f2d04f2ac359f486d2be4f0814e0f5b1d0b8f (diff)
QTestLib: Add macros QTRY_VERIFY2_WITH_TIMEOUT(), QTRY_VERIFY2().
Add QTRY_VERIFY2_WITH_TIMEOUT() similar to QTRY_VERIFY_WITH_TIMEOUT() except that QTRY_VERIFY2() is used below the loop and QTRY_VERIFY2() based on it. Add tests to cmptest. [ChangeLog][QtTest] Added macros QTRY_VERIFY2_WITH_TIMEOUT(), QTRY_VERIFY2() making it possible to output a message after the timeout has expired. Change-Id: I587e24f3aeb73542dbf3ccb936a16f2e0806555f Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/testlib/selftests/cmptest')
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 1ee78960ab..6446fec510 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -140,6 +140,10 @@ private slots:
void compareQImages();
void compareQImages_data();
#endif
+ void verify();
+ void verify2();
+ void tryVerify();
+ void tryVerify2();
};
enum MyUnregisteredEnum { MyUnregisteredEnumValue1, MyUnregisteredEnumValue2 };
@@ -387,7 +391,36 @@ void tst_Cmptest::compareQImages()
QCOMPARE(opA, opB);
}
-#endif
+#endif // QT_GUI_LIB
+
+static int opaqueFunc()
+{
+ return 42;
+}
+
+void tst_Cmptest::verify()
+{
+ QVERIFY(opaqueFunc() > 2);
+ QVERIFY(opaqueFunc() < 2);
+}
+
+void tst_Cmptest::verify2()
+{
+ QVERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData());
+ QVERIFY2(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData());
+}
+
+void tst_Cmptest::tryVerify()
+{
+ QTRY_VERIFY(opaqueFunc() > 2);
+ QTRY_VERIFY_WITH_TIMEOUT(opaqueFunc() < 2, 1);
+}
+
+void tst_Cmptest::tryVerify2()
+{
+ QTRY_VERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData());
+ QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1);
+}
QTEST_MAIN(tst_Cmptest)
#include "tst_cmptest.moc"