[Libreoffice-commits] .: sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Tue Oct 4 10:48:41 PDT 2011
sc/qa/unit/helper/csv_handler.hxx | 42 ++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
New commits:
commit 976f08098ee99499cea6a61787e7da834cfc50bb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Oct 4 19:21:45 2011 +0200
improve error message for csv_handler
diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index dce26e6..c3e9313 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -52,6 +52,40 @@ rtl::OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW nRo
return rtl::OUString(aString);
}
+rtl::OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab)
+{
+ rtl::OStringBuffer aString("Error in Table: ");
+ aString.append(nTab);
+ aString.append(" Column: ");
+ aString.append(nCol);
+ aString.append(" Row: ");
+ aString.append(nRow);
+ return aString.makeStringAndClear();
+}
+
+rtl::OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, const rtl::OUString& rExpectedString, const rtl::OUString& rString)
+{
+ rtl::OStringBuffer aString(createErrorMessage(nCol, nRow, nTab));
+ aString.append("; Expected: '");
+ aString.append(rtl::OUStringToOString(rExpectedString, RTL_TEXTENCODING_UTF8));
+ aString.append("' Found: '");
+ aString.append(rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8));
+ aString.append("'");
+ return aString.makeStringAndClear();
+}
+
+rtl::OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, double aExpected, double aValue)
+{
+ rtl::OStringBuffer aString(createErrorMessage(nCol, nRow, nTab));
+ aString.append("; Expected: '");
+ aString.append(aExpected);
+ aString.append("' Found: '");
+ aString.append(aValue);
+ aString.append("'");
+ return aString.makeStringAndClear();
+
+}
+
}
enum StringType { PureString, FormulaValue, StringValue };
@@ -97,7 +131,7 @@ public:
std::cout << "result: " << (int)(aCSVString == aString) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_MESSAGE("content is not correct in cell", aString == aCSVString);
+ CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString == aCSVString);
}
else
{
@@ -125,7 +159,7 @@ public:
std::cout << "result: " << (int)(aCSVString == aString) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_MESSAGE("content is not correct in cell", aString == aCSVString);
+ CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString == aCSVString);
}
else
{
@@ -136,7 +170,7 @@ public:
std::cout << "CSVValue: " << nValue << std::endl;
std::cout << "result: " << (int)(aValue == nValue) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_MESSAGE("content is not correct in cell", aValue == nValue);
+ CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, nValue, aValue).getStr(), aValue == nValue);
}
}
++mnCol;
@@ -185,7 +219,7 @@ public:
std::cout << "CSVString: " << rtl::OUStringToOString(aCSVString, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
std::cout << "result: " << (int)(aCSVString == aString) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_MESSAGE("", aString == aCSVString );
+ CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString == aCSVString );
++mnCol;
}
More information about the Libreoffice-commits
mailing list