From f6b311798ac97cbb35dda632c64fa263d1dff3fe Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 16 Jun 2026 01:49:36 -0400 Subject: [PATCH] And also a little macro for the test sets. --- include/fuc2/testing.hpp | 8 +++++--- tests/main.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/fuc2/testing.hpp b/include/fuc2/testing.hpp index af01db2..dcd2edc 100644 --- a/include/fuc2/testing.hpp +++ b/include/fuc2/testing.hpp @@ -4,9 +4,13 @@ #include #include -namespace fuc2 { +// macro to help adding tests #define TEST(N) {#N, N} +// macro to help with the main.cpp +#define TEST_SET(N) namespace N { extern fuc2::Set TESTS; } + +namespace fuc2 { using Func = std::function; using Case = std::pair; @@ -52,6 +56,4 @@ namespace fuc2 { void BLOWS_UP(std::function cb, const std::string &message, const std::source_location location = std::source_location::current()); - - int run(const Set& test_set); } diff --git a/tests/main.cpp b/tests/main.cpp index 7ea24c8..346dcc6 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -2,13 +2,16 @@ // you can also place these into a .hpp you include if // they're too numerous to manage + +// this is how you do it directly namespace sample1 { extern fuc2::Set TESTS; } -namespace sample_failing { - extern fuc2::Set TESTS; -} +// this macro jsut does the above for you +TEST_SET(sample_failing); + +using namespace fuc2; int main(int argc, char* argv[]) { run(sample1::TESTS);