diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-10 17:21:29 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-10 17:21:29 +0200 |
commit | 6c8e3d1786a5de4ae562c03693b8dad9dd0ab26e (patch) | |
tree | 18275240cfb8ff30e1d383ea351a277e894e988f /src/test/suite.h | |
parent | b670001ca80dbc0e1a51b4a08776eb41dabc2a9e (diff) |
tests,c++: Intermediate commit preparing testing and json
Diffstat (limited to 'src/test/suite.h')
-rw-r--r-- | src/test/suite.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/suite.h b/src/test/suite.h new file mode 100644 index 0000000..34f29bf --- /dev/null +++ b/src/test/suite.h @@ -0,0 +1,43 @@ +#pragma once + +#include <string> +#include <memory> +#include <stdexcept> +#include <type_traits> + +#include <forstio/core/common.h> + +namespace saw { +namespace test { +class test_runner; +class test_case { +private: + std::string file; + uint line; + std::string description; + bool matched_filter; + test_case* next; + test_case** prev; + + friend class test_runner; +public: + test_case(const std::string& file_, uint line_, const std::string& description_); + ~test_case(); + + virtual void run() = 0; +}; +} +} +#define SAW_TEST(description) \ + class SAW_UNIQUE_NAME(test_case) : public ::saw::test::test_case { \ + public: \ + SAW_UNIQUE_NAME(test_case)(): ::saw::test::test_case(__FILE__,__LINE__,description) {} \ + void run() override; \ + }SAW_UNIQUE_NAME(test_case_); \ + void SAW_UNIQUE_NAME(test_case)::run() + +#define SAW_EXPECT(expr, msg_split) \ + if( ! (expr) ){ \ + auto msg = msg_split; \ + throw std::runtime_error{std::string{msg}};\ + } |