aboutsummaryrefslogtreecommitdiff
path: root/spec/TestUtils.h
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-09 18:14:24 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-09 18:14:24 +0530
commit0e276c49adc1ef38993f1a90b0f87c732331598c (patch)
tree85d9fc7521c6f4d85e89596fbd2333f45087fb3a /spec/TestUtils.h
parent571ce3472d8d1277b0028dfd8118c6c8619afc34 (diff)
downloadnull-browser-0e276c49adc1ef38993f1a90b0f87c732331598c.tar.gz
null-browser-0e276c49adc1ef38993f1a90b0f87c732331598c.zip
Add test registry macro to allow managing multiple specs
Diffstat (limited to 'spec/TestUtils.h')
-rw-r--r--spec/TestUtils.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/TestUtils.h b/spec/TestUtils.h
index b2c1cc6..20b3ba8 100644
--- a/spec/TestUtils.h
+++ b/spec/TestUtils.h
@@ -1,4 +1,7 @@
+#pragma once
+
#include <QtTest/QtTest>
+#include <QtTest/qtestcase.h>
#include <cstdio>
#define ANSI_BOLD "\x1b[1m"
@@ -18,3 +21,20 @@
#define xit(msg) \
printf(" ⚪" COLOR_SKIP "SKIPPED it %s" ANSI_RESET "\n", msg); \
if (0)
+
+#define STRINGIFY(x) #x
+
+std::vector<std::function<QObject *()>> &getQTestRegistry();
+int runAllTests();
+
+#define QTEST_REGISTER(klass) \
+ namespace { \
+ const bool registered__##klass = []() { \
+ getQTestRegistry().push_back([]() { \
+ auto t = new klass; \
+ t->setObjectName(#klass); \
+ return t; \
+ }); \
+ return true; \
+ }(); \
+ };