12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "Test.h"
- Test::Test(const char* name) : tests(0), successTests(0), name(name) {
- }
- void Test::finalize() {
- if(successTests == tests) {
- LOG_DEBUG(StringBuffer<256>(name)
- .append(" Tests: ")
- .append(successTests)
- .append(" / ")
- .append(tests)
- .append(" succeeded"));
- } else {
- LOG_ERROR(StringBuffer<256>(name)
- .append(" Tests: ")
- .append(successTests)
- .append(" / ")
- .append(tests)
- .append(" succeeded"));
- }
- 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++;
- LOG_ERROR(StringBuffer<256>(name)
- .append(" Test ")
- .append(tests)
- .append(": ")
- .append(text)
- .append(" - expected '")
- .append(wanted)
- .append("' got '")
- .append(actual)
- .append("'"));
- }
- }
- void Test::checkTrue(bool actual, const char* text) {
- checkEqual(true, actual, text);
- }
- void Test::checkFalse(bool actual, const char* text) {
- checkEqual(false, actual, text);
- }
- void Test::checkUnsigned8(uint8 wanted, uint8 actual, const char* text) {
- checkEqual(wanted, actual, text);
- }
- void Test::checkUnsigned16(uint16 wanted, uint16 actual, const char* text) {
- checkEqual(wanted, actual, text);
- }
- void Test::checkSigned8(int8 wanted, int8 actual, const char* text) {
- checkEqual(wanted, actual, text);
- }
- void Test::checkSigned16(int16 wanted, int16 actual, const char* text) {
- checkEqual(wanted, actual, text);
- }
|