From 9ca040d383d7cfb81f4a9de25056844f121aec65 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 16 Jun 2026 01:39:41 -0400 Subject: [PATCH] Make a little macro that helps add tests by the function name. --- include/fuc2/testing.hpp | 2 ++ src/testing.cpp | 1 + tests/sample1.cpp | 6 +++--- tests/sample_failing.cpp | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/fuc2/testing.hpp b/include/fuc2/testing.hpp index f51de03..af01db2 100644 --- a/include/fuc2/testing.hpp +++ b/include/fuc2/testing.hpp @@ -5,6 +5,8 @@ #include namespace fuc2 { +#define TEST(N) {#N, N} + using Func = std::function; using Case = std::pair; diff --git a/src/testing.cpp b/src/testing.cpp index 3111ce8..64f4230 100644 --- a/src/testing.cpp +++ b/src/testing.cpp @@ -4,6 +4,7 @@ #include "fuc2/testing.hpp" namespace fuc2 { + std::string craft_error( const std::string& type, const std::string& test, diff --git a/tests/sample1.cpp b/tests/sample1.cpp index 855a87e..f5b0eb9 100644 --- a/tests/sample1.cpp +++ b/tests/sample1.cpp @@ -59,9 +59,9 @@ namespace sample1 { .name="std::deque basic operations", .options={ .fail_fast=false }, .tests={ - {"test_push_pop_back", test_push_pop_back}, - {"test_push_pop_front", test_push_pop_front}, - {"test_push_blows_up", test_push_blows_up}, + TEST(test_push_pop_back), + TEST(test_push_pop_front), + TEST(test_push_blows_up), } }; } diff --git a/tests/sample_failing.cpp b/tests/sample_failing.cpp index 7a134f8..c1c82d8 100644 --- a/tests/sample_failing.cpp +++ b/tests/sample_failing.cpp @@ -39,8 +39,8 @@ namespace sample_failing { .name="std::deque failing ops", .options={ .fail_fast=false }, .tests={ - {"fail_push_pop_back", fail_push_pop_back}, - {"fail_blows_up", fail_blows_up}, + TEST(fail_push_pop_back), + TEST(fail_blows_up), } }; }