From 42899582314181641d59dcc5f78358d0631b3677 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 19 Apr 2012 01:18:01 +0200 Subject: enable the chart2 dumper test --- sc/qa/extras/regression-test.cxx | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'sc/qa') diff --git a/sc/qa/extras/regression-test.cxx b/sc/qa/extras/regression-test.cxx index 4041fd45876c..812e218be648 100644 --- a/sc/qa/extras/regression-test.cxx +++ b/sc/qa/extras/regression-test.cxx @@ -61,6 +61,46 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +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; +} + +} + class ScChartRegressionTest : public test::BootstrapFixture, public unotest::MacrosTest { public: @@ -129,7 +169,8 @@ void ScChartRegressionTest::test() CPPUNIT_ASSERT(xDumper.is()); rtl::OUString aDump = xDumper->dump(); - std::cout << aDump << std::endl; + bool bCompare = checkDumpAgainstFile( aDump, getPathFromSrc("/chart2/qa/unit/data/reference/testChart.xml") ); + CPPUNIT_ASSERT(bCompare); } ScChartRegressionTest::ScChartRegressionTest() -- cgit