From 0e276c49adc1ef38993f1a90b0f87c732331598c Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 9 Mar 2025 18:14:24 +0530 Subject: Add test registry macro to allow managing multiple specs --- spec/TestUtils.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec/TestUtils.h') 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 +#include #include #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> &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; \ + }(); \ + }; -- cgit v1.3.1