aboutsummaryrefslogtreecommitdiff
path: root/spec/TestUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'spec/TestUtils.cpp')
-rw-r--r--spec/TestUtils.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/TestUtils.cpp b/spec/TestUtils.cpp
new file mode 100644
index 0000000..e496a9b
--- /dev/null
+++ b/spec/TestUtils.cpp
@@ -0,0 +1,20 @@
+#include <QtTest/QtTest>
+#include <QtTest/qtestcase.h>
+#include <cstdio>
+
+std::vector<std::function<QObject *()>> &getQTestRegistry() {
+ static std::vector<std::function<QObject *()>> registry;
+ return registry;
+}
+
+int runAllTests() {
+ int exitCode = 0;
+ for (const auto &runTest : getQTestRegistry()) {
+ auto test = runTest();
+ // printf(":::: %s\n", test->objectName().toStdString().c_str());
+ exitCode |= QTest::qExec(test);
+ delete test;
+ }
+ getQTestRegistry().clear();
+ return exitCode;
+}