fox32-hw/simulation/tester.hpp

42 lines
1.1 KiB
C++
Raw Normal View History

#ifndef tester_hpp_INCLUDED
#define tester_hpp_INCLUDED
class Tester {
public:
Tester(std::string test_name);
Tester(Tester* tester_parent, std::string test_name);
2024-01-17 12:25:06 +01:00
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;
2024-01-17 12:25:06 +01:00
bool detailed;
int depth();
2024-01-17 12:25:06 +01:00
bool shown();
std::string full_name();
std::string prefix();
2024-01-17 14:38:14 +01:00
std::chrono::time_point<std::chrono::steady_clock> started;
};
#endif // tester_hpp_INCLUDED