From 1c1406d02d333a3317fdbb67921af4ba31bd9bcd Mon Sep 17 00:00:00 2001 From: Claudius Holeksa Date: Tue, 9 May 2023 16:56:27 +0200 Subject: First version of the mini testing framework --- src/macro.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/macro.h (limited to 'src/macro.h') diff --git a/src/macro.h b/src/macro.h new file mode 100644 index 0000000..0421388 --- /dev/null +++ b/src/macro.h @@ -0,0 +1,20 @@ +#pragma once + +#define KEL_CONCAT_(x, y) x##y +#define KEL_CONCAT(x, y) KEL_CONCAT_(x, y) + +#define KEL_UNIQUE_NAME(prefix) KEL_CONCAT(prefix, __LINE__) + +#define KEL_TEST(description) \ + class KEL_UNIQUE_NAME(test_case) : public ::keltest::test_case { \ + public: \ + KEL_UNIQUE_NAME(test_case)(): ::keltest::test_case(__FILE__,__LINE__,description) {} \ + void run() override; \ + } KEL_UNIQUE_NAME(test_case_); \ + void KEL_UNIQUE_NAME(test_case)::run() + +#define KEL_EXPECT(expr, msg_split) \ + if( ! (expr) ){ \ + auto msg = msg_split; \ + throw std::runtime_error{std::string{msg}}; \ + } -- cgit v1.2.3