blob: 34f29bf20abbac36b2990640d914da82a62a0dab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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}};\
}
|