[Libreoffice-commits] .: 2 commits - sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu Oct 20 12:27:30 PDT 2011
sc/qa/unit/filters-test.cxx | 23 +++++
sc/qa/unit/helper/debughelper.hxx | 170 ++++++++++++++++++++++++++++++++++++++
sc/qa/unit/ucalc.cxx | 124 ---------------------------
3 files changed, 195 insertions(+), 122 deletions(-)
New commits:
commit d9604fa1b4123da145fc9b52901b42888d25ca3b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 20 20:23:15 2011 +0200
add more debug output to see why windows has problems with sc's filters-test
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 8292c38..71a4339 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -43,7 +43,10 @@
#include <editeng/justifyitem.hxx>
#include <basic/sbxdef.hxx>
+#define CALC_DEBUG_OUTPUT 1
+
#include "helper/csv_handler.hxx"
+#include "helper/debughelper.hxx"
#include "orcus/csv_parser.hpp"
#include <fstream>
#include <string>
@@ -465,6 +468,26 @@ void ScFiltersTest::testFormats()
CPPUNIT_ASSERT_MESSAGE("Failed to load formats.*", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
+ SheetPrinter StringPrinter( 8, 3);
+ SheetPrinter ValuePrinter( 8, 3);
+ for (SCROW nRow = 0; nRow < 8; ++nRow)
+ {
+ for (SCCOL nCol = 0; nCol < 3; ++nCol)
+ {
+ String aString;
+ double aVal;
+ pDoc->GetValue(nCol, nRow, 0, aVal);
+ pDoc->GetString(nCol, nRow, 0, aString);
+ ValuePrinter.set(nRow, nCol, rtl::OUString::valueOf(aVal));
+ StringPrinter.set(nRow, nCol, aString);
+ }
+ }
+ ValuePrinter.print("Data sheet content: Value");
+ ValuePrinter.clear();
+ StringPrinter.print("Data sheet content: String");
+ StringPrinter.clear();
+
+
//output this just for debugging, should make it easier to see which local the numberformatter really used
//it helps to understand why some windows build fails in this test
LanguageType aLang, aCjkLang, aCtlLang;
diff --git a/sc/qa/unit/helper/debughelper.hxx b/sc/qa/unit/helper/debughelper.hxx
index ac3e31a..65dc3c2 100644
--- a/sc/qa/unit/helper/debughelper.hxx
+++ b/sc/qa/unit/helper/debughelper.hxx
@@ -77,7 +77,7 @@ public:
maMatrix.set_string(row, col, new OUString(aStr));
}
-#if UCALC_DEBUG_OUTPUT
+#if CALC_DEBUG_OUTPUT
void print(const char* header) const
{
if (header)
@@ -138,7 +138,7 @@ public:
*/
void printArray() const
{
-#if UCALC_DEBUG_OUTPUT
+#if CALC_DEBUG_OUTPUT
MatrixType::size_pair_type ns = maMatrix.size();
for (size_t row = 0; row < ns.first; ++row)
{
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9abe9f7..a251360 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -71,7 +71,7 @@
#include <iostream>
#include <vector>
-#define UCALC_DEBUG_OUTPUT 0
+#define CALC_DEBUG_OUTPUT 0
#include "helper/debughelper.hxx"
commit cda653d7d9038fdcab72cfcae37d3d20463693d5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 20 20:05:33 2011 +0200
extract helper methods for debuging calc tests
diff --git a/sc/qa/unit/helper/debughelper.hxx b/sc/qa/unit/helper/debughelper.hxx
new file mode 100644
index 0000000..ac3e31a
--- /dev/null
+++ b/sc/qa/unit/helper/debughelper.hxx
@@ -0,0 +1,170 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+/**
+ * Print nicely formatted sheet content to stdout. Indispensable when
+ * debugging the unit test code involving testing of sheet contents.
+ */
+
+#include <rtl/strbuf.hxx>
+#include <rtl/ustring.hxx>
+#include "document.hxx"
+
+#ifdef WNT
+#define NOMINMAX
+#include <prewin.h>
+#include <postwin.h>
+#undef NOMINMAX
+#endif
+
+#define MDDS_HASH_CONTAINER_BOOST 1
+#include <mdds/mixed_type_matrix.hpp>
+
+#include <iostream>
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::std::cout;
+using ::std::cerr;
+using ::std::endl;
+using ::std::vector;
+
+
+
+namespace {
+
+::std::ostream& operator<< (::std::ostream& os, const rtl::OUString& str)
+{
+ return os << ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
+}
+
+}
+
+class SheetPrinter
+{
+ typedef ::mdds::mixed_type_matrix<OUString, bool> MatrixType;
+public:
+ SheetPrinter(size_t rows, size_t cols) :
+ maMatrix(rows, cols, ::mdds::matrix_density_sparse_empty) {}
+
+ void set(size_t row, size_t col, const OUString& aStr)
+ {
+ maMatrix.set_string(row, col, new OUString(aStr));
+ }
+
+#if UCALC_DEBUG_OUTPUT
+ void print(const char* header) const
+ {
+ if (header)
+ cout << header << endl;
+
+ MatrixType::size_pair_type ns = maMatrix.size();
+ vector<sal_Int32> aColWidths(ns.second, 0);
+
+ // Calculate column widths first.
+ for (size_t row = 0; row < ns.first; ++row)
+ {
+ for (size_t col = 0; col < ns.second; ++col)
+ {
+ const OUString* p = maMatrix.get_string(row, col);
+ if (aColWidths[col] < p->getLength())
+ aColWidths[col] = p->getLength();
+ }
+ }
+
+ // Make the row separator string.
+ OUStringBuffer aBuf;
+ aBuf.appendAscii("+");
+ for (size_t col = 0; col < ns.second; ++col)
+ {
+ aBuf.appendAscii("-");
+ for (sal_Int32 i = 0; i < aColWidths[col]; ++i)
+ aBuf.append(sal_Unicode('-'));
+ aBuf.appendAscii("-+");
+ }
+
+ OUString aSep = aBuf.makeStringAndClear();
+
+ // Now print to stdout.
+ cout << aSep << endl;
+ for (size_t row = 0; row < ns.first; ++row)
+ {
+ cout << "| ";
+ for (size_t col = 0; col < ns.second; ++col)
+ {
+ const OUString* p = maMatrix.get_string(row, col);
+ size_t nPadding = aColWidths[col] - p->getLength();
+ aBuf.append(*p);
+ for (size_t i = 0; i < nPadding; ++i)
+ aBuf.append(sal_Unicode(' '));
+ cout << aBuf.makeStringAndClear() << " | ";
+ }
+ cout << endl;
+ cout << aSep << endl;
+ }
+ }
+#else
+ void print(const char*) const {}
+#endif
+
+ /**
+ * Print nested string array which can be copy-n-pasted into the test code
+ * for content verification.
+ */
+ void printArray() const
+ {
+#if UCALC_DEBUG_OUTPUT
+ MatrixType::size_pair_type ns = maMatrix.size();
+ for (size_t row = 0; row < ns.first; ++row)
+ {
+ cout << " { ";
+ for (size_t col = 0; col < ns.second; ++col)
+ {
+ const OUString* p = maMatrix.get_string(row, col);
+ if (p->getLength())
+ cout << "\"" << *p << "\"";
+ else
+ cout << "0";
+ if (col < ns.second - 1)
+ cout << ", ";
+ }
+ cout << " }";
+ if (row < ns.first - 1)
+ cout << ",";
+ cout << endl;
+ }
+#endif
+ }
+
+ void clear() { maMatrix.clear(); }
+ void resize(size_t rows, size_t cols) { maMatrix.resize(rows, cols); }
+
+private:
+ MatrixType maMatrix;
+};
+
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 232a62e..9abe9f7 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -71,18 +71,10 @@
#include <iostream>
#include <vector>
-#ifdef WNT
-#define NOMINMAX
-#include <prewin.h>
-#include <postwin.h>
-#undef NOMINMAX
-#endif
-
-#define MDDS_HASH_CONTAINER_BOOST 1
-#include <mdds/mixed_type_matrix.hpp>
-
#define UCALC_DEBUG_OUTPUT 0
+#include "helper/debughelper.hxx"
+
const int indeterminate = 2;
using namespace ::com::sun::star;
@@ -95,118 +87,6 @@ using ::std::vector;
namespace {
-::std::ostream& operator<< (::std::ostream& os, const OUString& str)
-{
- return os << ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
-}
-
-/**
- * Print nicely formatted sheet content to stdout. Indispensable when
- * debugging the unit test code involving testing of sheet contents.
- */
-class SheetPrinter
-{
- typedef ::mdds::mixed_type_matrix<OUString, bool> MatrixType;
-public:
- SheetPrinter(size_t rows, size_t cols) :
- maMatrix(rows, cols, ::mdds::matrix_density_sparse_empty) {}
-
- void set(size_t row, size_t col, const OUString& aStr)
- {
- maMatrix.set_string(row, col, new OUString(aStr));
- }
-
-#if UCALC_DEBUG_OUTPUT
- void print(const char* header) const
- {
- if (header)
- cout << header << endl;
-
- MatrixType::size_pair_type ns = maMatrix.size();
- vector<sal_Int32> aColWidths(ns.second, 0);
-
- // Calculate column widths first.
- for (size_t row = 0; row < ns.first; ++row)
- {
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- if (aColWidths[col] < p->getLength())
- aColWidths[col] = p->getLength();
- }
- }
-
- // Make the row separator string.
- OUStringBuffer aBuf;
- aBuf.appendAscii("+");
- for (size_t col = 0; col < ns.second; ++col)
- {
- aBuf.appendAscii("-");
- for (sal_Int32 i = 0; i < aColWidths[col]; ++i)
- aBuf.append(sal_Unicode('-'));
- aBuf.appendAscii("-+");
- }
-
- OUString aSep = aBuf.makeStringAndClear();
-
- // Now print to stdout.
- cout << aSep << endl;
- for (size_t row = 0; row < ns.first; ++row)
- {
- cout << "| ";
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- size_t nPadding = aColWidths[col] - p->getLength();
- aBuf.append(*p);
- for (size_t i = 0; i < nPadding; ++i)
- aBuf.append(sal_Unicode(' '));
- cout << aBuf.makeStringAndClear() << " | ";
- }
- cout << endl;
- cout << aSep << endl;
- }
- }
-#else
- void print(const char*) const {}
-#endif
-
- /**
- * Print nested string array which can be copy-n-pasted into the test code
- * for content verification.
- */
- void printArray() const
- {
-#if UCALC_DEBUG_OUTPUT
- MatrixType::size_pair_type ns = maMatrix.size();
- for (size_t row = 0; row < ns.first; ++row)
- {
- cout << " { ";
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- if (p->getLength())
- cout << "\"" << *p << "\"";
- else
- cout << "0";
- if (col < ns.second - 1)
- cout << ", ";
- }
- cout << " }";
- if (row < ns.first - 1)
- cout << ",";
- cout << endl;
- }
-#endif
- }
-
- void clear() { maMatrix.clear(); }
- void resize(size_t rows, size_t cols) { maMatrix.resize(rows, cols); }
-
-private:
- MatrixType maMatrix;
-};
-
class Test : public test::BootstrapFixture {
public:
Test();
More information about the Libreoffice-commits
mailing list