123456789101112131415161718192021222324 |
- #include "Test.h"
- Test::Test(const char* name) : tests(0), successTests(0), name(name) {
- }
- void Test::finalize() {
- std::cout << ((successTests == tests) ? GREEN : RED);
- std::cout << name << " Tests: " << successTests << " / " << tests << " succeeded\n" << RESET;
- tests = 0;
- successTests = 0;
- }
- void Test::checkFloat(float wanted, float actual, float error, const char* text) {
- float diff = wanted - actual;
- diff = diff < 0.0f ? -diff : diff;
- if(diff < error) {
- tests++;
- successTests++;
- } else {
- tests++;
- std::cout << RED << name << " Test " << tests << ": " << text << " - " << RESET;
- std::cout << RED << "expected '" << wanted << "' got '" << actual << "'\n" << RESET;
- }
- }
|