42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#ifndef tester_hpp_INCLUDED
|
|
#define tester_hpp_INCLUDED
|
|
|
|
class Tester {
|
|
|
|
public:
|
|
Tester(std::string test_name);
|
|
|
|
Tester(Tester* tester_parent, std::string test_name);
|
|
Tester(Tester* tester_parent, std::string test_name, bool show_details);
|
|
|
|
template<typename T, typename U>
|
|
void assert_eq(std::string test_name, T got, U expected) {
|
|
char got_s[10], expected_s[10];
|
|
snprintf(got_s, sizeof got_s, "%08x", got);
|
|
snprintf(expected_s, sizeof expected_s, "%08x", expected);
|
|
|
|
assert_eq_str(test_name, got == expected, got_s, expected_s);
|
|
}
|
|
void assert_eq_str(std::string test_name, bool correct, std::string got_s, std::string expected_s);
|
|
|
|
|
|
~Tester();
|
|
|
|
void intro();
|
|
void finish();
|
|
|
|
private:
|
|
std::optional<Tester*> parent;
|
|
std::string name;
|
|
int succeeded, failed;
|
|
bool detailed;
|
|
|
|
int depth();
|
|
bool shown();
|
|
std::string full_name();
|
|
std::string prefix();
|
|
std::chrono::time_point<std::chrono::steady_clock> started;
|
|
};
|
|
|
|
#endif // tester_hpp_INCLUDED
|