aboutsummaryrefslogtreecommitdiff
path: root/spec/testUtils.h
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-09 19:47:50 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-09 19:47:50 +0530
commit61f99089288138989cf244d174882aa5088b738b (patch)
treeea1202b098b92e85b16e670d1c3ea1b86fcaef58 /spec/testUtils.h
parent1e2302be2b47fbeb340db7482ed8476c829a7f66 (diff)
downloadnull-browser-61f99089288138989cf244d174882aa5088b738b.tar.gz
null-browser-61f99089288138989cf244d174882aa5088b738b.zip
Refactor directory structure
Diffstat (limited to 'spec/testUtils.h')
-rw-r--r--spec/testUtils.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/testUtils.h b/spec/testUtils.h
new file mode 100644
index 0000000..20b3ba8
--- /dev/null
+++ b/spec/testUtils.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <QtTest/QtTest>
+#include <QtTest/qtestcase.h>
+#include <cstdio>
+
+#define ANSI_BOLD "\x1b[1m"
+#define COLOR_CONTEXT "\x1b[32m" ANSI_BOLD
+#define COLOR_IT "\x1b[36m" ANSI_BOLD
+#define COLOR_SKIP "\x1b[33m" ANSI_BOLD
+#define ANSI_RESET "\x1b[0m"
+
+#define context(msg) printf("⚪" COLOR_CONTEXT "%s" ANSI_RESET "\n", msg);
+
+#define it(msg) \
+ printf(" ⚪" ANSI_BOLD COLOR_IT "it " ANSI_RESET COLOR_IT "%s" ANSI_RESET \
+ "\n", \
+ msg); \
+ if (1)
+
+#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; \
+ }(); \
+ };