[Libreoffice-commits] .: sc/qa
Fridrich Strba
fridrich at kemper.freedesktop.org
Fri Jun 15 06:25:06 PDT 2012
sc/qa/unit/data/ods/database.ods |binary
sc/qa/unit/data/xls/database.xls |binary
sc/qa/unit/data/xlsx/database.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 71 ++++++++++++++++++++++++++-------
4 files changed, 58 insertions(+), 13 deletions(-)
New commits:
commit 47e4a33a6405eb1b5186027f55bd9cb99b0c1fe7
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Mon Jun 11 02:42:30 2012 -0500
Extend current database range unit test to also check xls and xlsx
Since Excel doesn't support named database ranges, I also added tests for
unnamed database ranges for ods, xls, and xlsx.
Change-Id: I491324883c95cf2edb13c0561e975a13d13ba7d7
diff --git a/sc/qa/unit/data/ods/database.ods b/sc/qa/unit/data/ods/database.ods
index c8039f9..612919f 100644
Binary files a/sc/qa/unit/data/ods/database.ods and b/sc/qa/unit/data/ods/database.ods differ
diff --git a/sc/qa/unit/data/xls/database.xls b/sc/qa/unit/data/xls/database.xls
new file mode 100644
index 0000000..04f473c
Binary files /dev/null and b/sc/qa/unit/data/xls/database.xls differ
diff --git a/sc/qa/unit/data/xlsx/database.xlsx b/sc/qa/unit/data/xlsx/database.xlsx
new file mode 100644
index 0000000..646b79d
Binary files /dev/null and b/sc/qa/unit/data/xlsx/database.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 68b5bf0..d293bd5 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -101,6 +101,8 @@ public:
void testRangeNameXLSX();
void testFunctionsODS();
void testDatabaseRangesODS();
+ void testDatabaseRangesXLS();
+ void testDatabaseRangesXLSX();
void testFormatsODS();
void testFormatsXLS();
void testFormatsXLSX();
@@ -127,6 +129,8 @@ public:
CPPUNIT_TEST(testRangeNameXLSX);
CPPUNIT_TEST(testFunctionsODS);
CPPUNIT_TEST(testDatabaseRangesODS);
+ CPPUNIT_TEST(testDatabaseRangesXLS);
+ CPPUNIT_TEST(testDatabaseRangesXLSX);
CPPUNIT_TEST(testFormatsODS);
CPPUNIT_TEST(testFormatsXLS);
CPPUNIT_TEST(testFormatsXLSX);
@@ -318,13 +322,10 @@ void ScFiltersTest::testFunctionsODS()
xDocSh->DoClose();
}
-void ScFiltersTest::testDatabaseRangesODS()
-{
- const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
- ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0);
- xDocSh->DoHardRecalc(true);
+namespace {
- ScDocument* pDoc = xDocSh->GetDocument();
+void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat)
+{
ScDBCollection* pDBCollection = pDoc->GetDBCollection();
CPPUNIT_ASSERT_MESSAGE("no database collection", pDBCollection);
@@ -343,15 +344,59 @@ void ScFiltersTest::testDatabaseRangesODS()
CPPUNIT_ASSERT_MESSAGE("Sheet1: row 4-5 should be hidden", bHidden && nRow1 == 4 && nRow2 == 5);
bHidden = pDoc->RowHidden(6, 0, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("Sheet1: row 6-end should be visible", !bHidden && nRow1 == 6 && nRow2 == MAXROW);
+ if(nFormat == ODS) //excel doesn't support named db ranges
+ {
+ double aValue;
+ pDoc->GetValue(0,10,1, aValue);
+ rtl::OUString aString;
+ CPPUNIT_ASSERT_MESSAGE("Sheet2: A11: formula result is incorrect", aValue == 4);
+ pDoc->GetValue(1, 10, 1, aValue);
+ CPPUNIT_ASSERT_MESSAGE("Sheet2: B11: formula result is incorrect", aValue == 2);
+ }
double aValue;
- pDoc->GetValue(0,10,1, aValue);
+ pDoc->GetValue(3,10,1, aValue);
rtl::OUString aString;
- pDoc->GetFormula(0,10,1,aString);
- rtl::OString aOString;
- aOString = rtl::OUStringToOString(aString, RTL_TEXTENCODING_UTF8);
- CPPUNIT_ASSERT_MESSAGE("Sheet2: A11: formula result is incorrect", aValue == 4);
- pDoc->GetValue(1, 10, 1, aValue);
- CPPUNIT_ASSERT_MESSAGE("Sheet2: B11: formula result is incorrect", aValue == 2);
+ CPPUNIT_ASSERT_MESSAGE("Sheet2: D11: formula result is incorrect", aValue == 4);
+ pDoc->GetValue(4, 10, 1, aValue);
+ CPPUNIT_ASSERT_MESSAGE("Sheet2: E11: formula result is incorrect", aValue == 2);
+
+}
+
+}
+
+void ScFiltersTest::testDatabaseRangesODS()
+{
+ const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
+ ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0);
+ xDocSh->DoHardRecalc(true);
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ testDBRanges_Impl(pDoc, ODS);
+ xDocSh->DoClose();
+}
+
+void ScFiltersTest::testDatabaseRangesXLS()
+{
+ const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
+ ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1);
+ xDocSh->DoHardRecalc(true);
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ testDBRanges_Impl(pDoc, XLS);
+ xDocSh->DoClose();
+}
+
+void ScFiltersTest::testDatabaseRangesXLSX()
+{
+ const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
+ ScDocShellRef xDocSh = loadDoc(aFileNameBase, 2);
+ xDocSh->DoHardRecalc(true);
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+
+ testDBRanges_Impl(pDoc, XLSX);
xDocSh->DoClose();
}
More information about the Libreoffice-commits
mailing list