summaryrefslogtreecommitdiff
path: root/asl/testing/testing.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-10-23 00:20:05 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commite1f9d9ca1ef3c69da3b887b0af298be0aea4a5f9 (patch)
tree3da091d697177d178841fae7b2980b6c152e25c1 /asl/testing/testing.hpp
parent8c95db33be58a545dd2e030428bded0bd958c4b6 (diff)
More work on testing framework
Diffstat (limited to 'asl/testing/testing.hpp')
-rw-r--r--asl/testing/testing.hpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/asl/testing/testing.hpp b/asl/testing/testing.hpp
index a489d61..db2a64a 100644
--- a/asl/testing/testing.hpp
+++ b/asl/testing/testing.hpp
@@ -1,15 +1,38 @@
#pragma once
+#include <asl/utility.hpp>
+
namespace asl::testing
{
+struct Test;
+
+void register_test(Test*);
+
+void report_failure(const char* msg, const char* file, int line);
+
using TestFunction = void();
-int register_test(const char* suite_name, const char* case_name, TestFunction* fn);
+
+struct Test
+{
+ const char* m_case_name;
+ TestFunction* m_fn;
+ Test* m_next{};
+ Test* m_prev{};
+
+ constexpr explicit Test(const char* case_name, TestFunction* fn)
+ : m_case_name{case_name}
+ , m_fn{fn}
+ {
+ register_test(this);
+ }
+};
} // namespace asl::testing
-#define ASL_TEST(SUITE, CASE) \
- static void asl_test_fn_##SUITE##_##CASE(); \
- static const int asl_test_##SUITE##_##CASE = ::asl::testing::register_test( \
- #SUITE, #CASE, asl_test_fn_##SUITE##_##CASE); \
- void asl_test_fn_##SUITE##_##CASE()
+#define ASL_TEST(CASE) \
+ static void asl_test_fn_##CASE(); \
+ static ::asl::testing::Test asl_test_##CASE( \
+ #CASE, \
+ asl_test_fn_##CASE); \
+ void asl_test_fn_##CASE()