And also a little macro for the test sets.

master
Zed A. Shaw 1 month ago
parent 9ca040d383
commit f6b311798a
  1. 8
      include/fuc2/testing.hpp
  2. 9
      tests/main.cpp

@ -4,9 +4,13 @@
#include <fmt/core.h>
#include <functional>
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<void()>;
using Case = std::pair<std::string, Func>;
@ -52,6 +56,4 @@ namespace fuc2 {
void BLOWS_UP(std::function<void()> cb, const std::string &message,
const std::source_location location = std::source_location::current());
int run(const Set& test_set);
}

@ -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);

Loading…
Cancel
Save