summaryrefslogtreecommitdiffstats
path: root/tests/auto/qglobal
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qglobal')
-rw-r--r--tests/auto/qglobal/qglobal.pro3
-rw-r--r--tests/auto/qglobal/tst_qglobal.cpp72
2 files changed, 72 insertions, 3 deletions
diff --git a/tests/auto/qglobal/qglobal.pro b/tests/auto/qglobal/qglobal.pro
index 373061b..8f1e00a 100644
--- a/tests/auto/qglobal/qglobal.pro
+++ b/tests/auto/qglobal/qglobal.pro
@@ -1,6 +1,3 @@
load(qttest_p4)
-
SOURCES += tst_qglobal.cpp
QT = core
-
-
diff --git a/tests/auto/qglobal/tst_qglobal.cpp b/tests/auto/qglobal/tst_qglobal.cpp
index 62bfd81..28556be 100644
--- a/tests/auto/qglobal/tst_qglobal.cpp
+++ b/tests/auto/qglobal/tst_qglobal.cpp
@@ -50,6 +50,8 @@ private slots:
void qInternalCallbacks();
void for_each();
void qassert();
+ void qtry();
+ void checkptr();
};
void tst_QGlobal::qIsNull()
@@ -190,5 +192,75 @@ void tst_QGlobal::qassert()
QVERIFY(passed);
}
+void tst_QGlobal::qtry()
+{
+ int i = 0;
+ QT_TRY {
+ i = 1;
+ QT_THROW(42);
+ i = 2;
+ } QT_CATCH(int) {
+ QCOMPARE(i, 1);
+ i = 7;
+ }
+#ifdef QT_NO_EXCEPTIONS
+ QCOMPARE(i, 2);
+#else
+ QCOMPARE(i, 7);
+#endif
+
+ // check propper if/else scoping
+ i = 0;
+ if (true)
+ QT_TRY {
+ i = 2;
+ QT_THROW(42);
+ i = 4;
+ } QT_CATCH(int) {
+ QCOMPARE(i, 2);
+ i = 4;
+ }
+ else
+ QCOMPARE(i, 0);
+ QCOMPARE(i, 4);
+
+ i = 0;
+ if (false)
+ QT_TRY {
+ i = 2;
+ QT_THROW(42);
+ i = 4;
+ } QT_CATCH(int) {
+ QCOMPARE(i, 2);
+ i = 2;
+ }
+ else
+ i = 8;
+ QCOMPARE(i, 8);
+
+ i = 0;
+ if (false)
+ i = 42;
+ else
+ QT_TRY {
+ i = 2;
+ QT_THROW(42);
+ i = 4;
+ } QT_CATCH(int) {
+ QCOMPARE(i, 2);
+ i = 4;
+ }
+ QCOMPARE(i, 4);
+}
+
+void tst_QGlobal::checkptr()
+{
+ int i;
+ QCOMPARE(q_check_ptr(&i), &i);
+
+ const char *c = "hello";
+ QCOMPARE(q_check_ptr(c), c);
+}
+
QTEST_MAIN(tst_QGlobal)
#include "tst_qglobal.moc"