summaryrefslogtreecommitdiff
path: root/src/keltest/macro.h
diff options
context:
space:
mode:
authorClaudius Holeksa <mail@keldu.de>2023-05-09 17:24:41 +0200
committerClaudius Holeksa <mail@keldu.de>2023-05-09 17:24:41 +0200
commitcac4a8dd2ac6670c5db8d2370cdd12451f9f50cf (patch)
treea616b1b725246d51baa76c71c083258b80bcd679 /src/keltest/macro.h
parent58ded913ccbed1c99447338f87bda72a27e77049 (diff)
downloadmini-test-cac4a8dd2ac6670c5db8d2370cdd12451f9f50cf.tar.gz
Added readme and moved src files
Diffstat (limited to 'src/keltest/macro.h')
-rw-r--r--src/keltest/macro.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/keltest/macro.h b/src/keltest/macro.h
new file mode 100644
index 0000000..0421388
--- /dev/null
+++ b/src/keltest/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}}; \
+ }