#include "test/Test.h" Core::Test::Test(const char* name_) : tests(0), successTests(0), name(name_) { } void Core::Test::finalize() { if(successTests == tests) { CORE_LOG_DEBUG("# Tests: # / # succeeded", name, successTests, tests); } else { CORE_LOG_ERROR("# Tests: # / # succeeded", name, successTests, tests); } tests = 0; successTests = 0; } void Core::Test::checkEqual(float wanted, float actual, const char* text) { checkFloat(wanted, actual, 0.0000001f, text); } void Core::Test::checkFloat(float wanted, float actual, float error, const char* text) { tests++; float diff = wanted - actual; diff = diff < 0.0f ? -diff : diff; if(diff < error) { successTests++; } else { (void)text; CORE_LOG_ERROR("# Test #: # - expected '#' got '#'", name, tests, text, wanted, actual) } } void Core::Test::checkTrue(bool actual, const char* text) { checkEqual(true, actual, text); } void Core::Test::checkFalse(bool actual, const char* text) { checkEqual(false, actual, text); }