diff options
-rw-r--r-- | sc/qa/extras/regression-test.cxx | 34 | ||||
-rw-r--r-- | test/inc/test/xmldiff.hxx | 6 | ||||
-rw-r--r-- | test/source/diff/diff.cxx | 6 |
3 files changed, 17 insertions, 29 deletions
diff --git a/sc/qa/extras/regression-test.cxx b/sc/qa/extras/regression-test.cxx index 812e218be648..98ef5412393b 100644 --- a/sc/qa/extras/regression-test.cxx +++ b/sc/qa/extras/regression-test.cxx @@ -51,6 +51,8 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/qa/XDumper.hpp> +#include <test/xmldiff.hxx> + #include <basic/sbxdef.hxx> #include "docsh.hxx" @@ -66,37 +68,13 @@ namespace { bool checkDumpAgainstFile( const rtl::OUString& rDump, const rtl::OUString aFilePath ) { rtl::OString aOFile = rtl::OUStringToOString(aFilePath, RTL_TEXTENCODING_UTF8); - std::ifstream aFile(aOFile.getStr()); - CPPUNIT_ASSERT_MESSAGE("file not open", aFile.is_open()); CPPUNIT_ASSERT_MESSAGE("dump is empty", !rDump.isEmpty()); - sal_Int32 nLine = 1; - sal_Int32 nIndex = 0; - while(!aFile.eof()) - { - std::string aLineFile; - - std::getline(aFile, aLineFile); - sal_Int32 nNewIndex = rDump.indexOf('\n', nIndex); - //CPPUNIT_ASSERT( nNewIndex != -1 ); - if (nNewIndex == -1) - nNewIndex = rDump.getLength(); - rtl::OUString aLineDump = rDump.copy(nIndex, nNewIndex-nIndex); - nIndex = nNewIndex+1; - rtl::OString aOLineDump = rtl::OUStringToOString(aLineDump, RTL_TEXTENCODING_UTF8); - - if( aLineFile.compare(aOLineDump.getStr()) ) - { - rtl::OStringBuffer aErrorMessage("Mismatch between reference file and dump in line "); - std::cout << rtl::OUStringToOString(rDump, RTL_TEXTENCODING_UTF8).getStr(); - aErrorMessage.append(nLine).append(".\nExpected: "); - aErrorMessage.append(aLineFile.c_str()).append("\nFound : ").append(aOLineDump); - CPPUNIT_ASSERT_MESSAGE(aErrorMessage.getStr(), false); - } - nLine++; - } - return true; + rtl::OString aDump = rtl::OUStringToOString(rDump, RTL_TEXTENCODING_UTF8); + XMLDiff aDiff(aOFile.getStr(), aDump.getStr(),static_cast<int>(rDump.getLength())); + + return aDiff.compare(); } } diff --git a/test/inc/test/xmldiff.hxx b/test/inc/test/xmldiff.hxx index beaea19a7f53..a787132347d4 100644 --- a/test/inc/test/xmldiff.hxx +++ b/test/inc/test/xmldiff.hxx @@ -31,6 +31,9 @@ #include <libxml/xmlmemory.h> #include <string> #include <set> +#include <test/testdllapi.hxx> + +#define USE_CPPUNIT 1 struct tolerance { @@ -70,11 +73,12 @@ struct tolerance } }; -class XMLDiff +class OOO_DLLPUBLIC_TEST XMLDiff { public: XMLDiff(const std::string& file1, const std::string& file2, const std::string& toleranceFile); XMLDiff(const std::string& file1, const std::string& file2); + XMLDiff(const char* pFileName, const char* pContent, int size); ~XMLDiff(); bool compare(); diff --git a/test/source/diff/diff.cxx b/test/source/diff/diff.cxx index 2d57a4aec2ab..6b97f298b3b1 100644 --- a/test/source/diff/diff.cxx +++ b/test/source/diff/diff.cxx @@ -55,6 +55,12 @@ XMLDiff::XMLDiff(const std::string& file1, const std::string& file2) xmlFile2 = xmlParseFile(file2.c_str()); } +XMLDiff::XMLDiff( const char* pFileName, const char* pContent, int size) +{ + xmlFile1 = xmlParseFile(pFileName); + xmlFile2 = xmlParseMemory(pContent, size); +} + XMLDiff::~XMLDiff() { xmlFreeDoc(xmlFile1); |