/** * 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(); }
/// Asserts that two XML string are equivalent. void checkXmlEqual( std::string expectedXml, std::string actualXml, CPPUNIT_NS::SourceLine sourceLine ) { std::string expected = XmlUniformiser( expectedXml ).stripped(); std::string actual = XmlUniformiser( actualXml ).stripped(); if ( expected == actual ) return; int index = notEqualIndex( expected, actual ); CPPUNIT_NS::OStringStream message; message << "differ at index: " << index << "\n" << "expected: " << expected.substr(index) << "\n" << "but was : " << actual.substr( index ); CPPUNIT_NS::Asserter::failNotEqual( expected, actual, sourceLine, message.str() ); }