summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtconcurrentrun
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-11-11 08:59:53 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-11-11 09:06:39 (GMT)
commit98d51e42c81c0674bc724eccbdf8521d9317998a (patch)
tree75605437441102ca180cfc2771d682b2ab6cab9f /tests/auto/qtconcurrentrun
parente8ddca677db9b0d3ac8ff1b2079c3b000d59d6ec (diff)
downloadQt-98d51e42c81c0674bc724eccbdf8521d9317998a.zip
Qt-98d51e42c81c0674bc724eccbdf8521d9317998a.tar.gz
Qt-98d51e42c81c0674bc724eccbdf8521d9317998a.tar.bz2
Support exception handling in QtConcurrent::run()
Use QFutureInterface::reportException() in the same way that we do in QtConcurrent::map().
Diffstat (limited to 'tests/auto/qtconcurrentrun')
-rw-r--r--tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 8fdc50c..8b10ea4 100644
--- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -61,6 +61,9 @@ private slots:
void implicitConvertibleTypes();
void runWaitLoop();
void recursive();
+#ifndef QT_NO_EXCEPTIONS
+ void exceptions();
+#endif
#if 0
void createFunctor();
#endif
@@ -374,6 +377,41 @@ int fn2(double, int *)
return 1;
}
+
+#ifndef QT_NO_EXCEPTIONS
+void throwFunction()
+{
+ throw QtConcurrent::Exception();
+}
+
+int throwFunctionReturn()
+{
+ throw QtConcurrent::Exception();
+ return 0;
+}
+
+void tst_QtConcurrentRun::exceptions()
+{
+ bool caught = false;
+ try {
+ QtConcurrent::run(throwFunction).waitForFinished();
+ } catch (Exception &e) {
+ caught = true;
+ }
+ if (!caught)
+ QFAIL("did not get exception");
+
+ caught = false;
+ try {
+ QtConcurrent::run(throwFunctionReturn).waitForFinished();
+ } catch (Exception &e) {
+ caught = true;
+ }
+ if (!caught)
+ QFAIL("did not get exception");
+}
+#endif
+
#if 0
void tst_QtConcurrentRun::createFunctor()
{