From: <vac...@us...> - 2010-03-09 17:08:02
|
Revision: 171 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=171&view=rev Author: vaclavslavik Date: 2010-03-09 17:07:55 +0000 (Tue, 09 Mar 2010) Log Message: ----------- Better reporting of XML output test failures. Show content of both expected and actual XML file output, to make it possible to see what went wrong. Modified Paths: -------------- trunk/tests/test.h Modified: trunk/tests/test.h =================================================================== --- trunk/tests/test.h 2010-02-17 16:15:08 UTC (rev 170) +++ trunk/tests/test.h 2010-03-09 17:07:55 UTC (rev 171) @@ -45,6 +45,8 @@ #include <sstream> #include <cstring> +typedef boost::test_tools::predicate_result predicate_result; + // path to source directory, where test data files are located extern std::string srcdir; @@ -69,25 +71,34 @@ return read_file_into_string(f); } -inline bool is_same_as_file(const std::string& data, const std::string& filename) +inline predicate_result is_same_as_file(const std::string& data, const std::string& filename) { - return data == read_file_into_string(filename); + const std::string filedata = read_file_into_string(filename); + if ( data == filedata ) + return true; + + predicate_result res(false); + res.message() << "Expected output:\n"; + res.message() << filedata; + res.message() << "\nActual output:\n"; + res.message() << data; + return res; } -inline bool is_same_as_file(const std::ostringstream& stream, const std::string& filename) +inline predicate_result is_same_as_file(const std::ostringstream& stream, const std::string& filename) { return is_same_as_file(stream.str(), filename); } -inline bool is_same_as_file(const xml::document& doc, const std::string& filename) +inline predicate_result is_same_as_file(const xml::document& doc, const std::string& filename) { std::string xml; doc.save_to_string(xml); return is_same_as_file(xml, filename); } -inline bool is_same_as_file(const xml::node& node, const std::string& filename) +inline predicate_result is_same_as_file(const xml::node& node, const std::string& filename) { std::ostringstream ostr; ostr << node; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |