fox32-hw/simulation/tester.hpp

38 lines
956 B
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);
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;
int depth();
std::string full_name();
std::string prefix();
};
#endif // tester_hpp_INCLUDED