blob: 52ef71d1fe68e57c5d95cd49bfc1d2834f4d4ebe (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <string>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <sstream>
#include "../common.hpp"
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}};\
}
#define SAW_EOV_EXPECT(eov_expr, msg_split) \
if( (eov_expr.is_error()) ){ \
auto& err = eov_expr.get_error(); \
std::stringstream sstr; \
sstr<<msg_split<<" [Category] "<<err.get_category(); \
auto err_msg = err.get_message(); \
if(err_msg.size() > 0u){ \
sstr<<" [Message] "<<err_msg; \
} \
throw std::runtime_error{sstr.str()}; \
}
|