diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-09 18:14:24 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-09 18:14:24 +0530 |
| commit | 0e276c49adc1ef38993f1a90b0f87c732331598c (patch) | |
| tree | 85d9fc7521c6f4d85e89596fbd2333f45087fb3a /spec/TestUtils.cpp | |
| parent | 571ce3472d8d1277b0028dfd8118c6c8619afc34 (diff) | |
| download | null-browser-0e276c49adc1ef38993f1a90b0f87c732331598c.tar.gz null-browser-0e276c49adc1ef38993f1a90b0f87c732331598c.zip | |
Add test registry macro to allow managing multiple specs
Diffstat (limited to '')
| -rw-r--r-- | spec/TestUtils.cpp | 20 |
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; +} |
