static void assertEquals( const AType& expected, const AType& result, const char* file="", int line=0 ) { if(expected != result) { TestsListener::theInstance().errorsLog() << file << ", line: " << line << "\n" << errmsgTag_expected() << " " << expected << " " << errmsgTag_butWas() << " " << result << "\n"; TestsListener::theInstance().testHasFailed(); } }
void Assert::assertEqualsEpsilon( const double& expected, const double& result, const double& epsilon, const char* file, int linia ) { if (isNaN(expected) && isNaN(result) ) return; if (!isNaN(expected) && !isNaN(result) && fuzzyEquals(expected, result, epsilon) ) return; TestsListener::theInstance().errorsLog() << errmsgTag_testFailedIn() << file << errmsgTag_inLine() << linia << "\n" << errmsgTag_expected() << bold() << expected << normal() << " " << errmsgTag_butWas() << bold() << result << normal() << "\n"; TestsListener::theInstance().testHasFailed(); }
/** * we overload the assert with string doing colored diffs * * MS Visual6 doesn't allow string by reference :-( */ void Assert::assertEquals( const std::string expected, const std::string result, const char* file, int line ) { if(expected == result) return; int indexDiferent = notEqualIndex(expected, result); TestsListener::theInstance().errorsLog() << file << ", line: " << line << "\n" << errmsgTag_expected() << "\n\033[36;1m" << expected.substr(0,indexDiferent) << "\033[32;1m" << expected.substr(indexDiferent) << "\033[0m\n" << errmsgTag_butWas() << "\033[36;1m \n" << result.substr(0,indexDiferent) << "\033[31;1m" << result.substr(indexDiferent) << "\033[0m\n"; TestsListener::theInstance().testHasFailed(); }
/** * we overload the assert with string doing colored diffs * * MS Visual6 doesn't allow string by reference :-( */ void Assert::assertEquals( const std::string expected, const std::string result, const char* file, int linia ) { if(expected == result) return; int indexDiferent = notEqualIndex(expected, result); TestsListener::theInstance().errorsLog() << file << ", linia: " << linia << "\n" << errmsgTag_expected() << "\n" << blue() << expected.substr(0,indexDiferent) << green() << expected.substr(indexDiferent) << normal() << "\n" << errmsgTag_butWas() << blue() << "\n" << result.substr(0,indexDiferent) << red() << result.substr(indexDiferent) << normal() << std::endl; TestsListener::theInstance().testHasFailed(); }