sc/qa/unit/data/csv/numberformat.csv | 3 +++ sc/qa/unit/subsequent_filters-test.cxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
New commits: commit b8430f71d37ea5181fc812fc07a20555b07a0b3c Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Aug 13 14:45:59 2012 -0400 Add test for csv filter as well. The content is intentionally identical to the html counterpart. Change-Id: Ie9a91ceafdb56a0c915bc0175d49bb494c38e9af diff --git a/sc/qa/unit/data/csv/numberformat.csv b/sc/qa/unit/data/csv/numberformat.csv new file mode 100644 index 0000000..2111b94 --- /dev/null +++ b/sc/qa/unit/data/csv/numberformat.csv @@ -0,0 +1,3 @@ +Product,Price,Note +Google Nexus 7 (8GB),199.98,"This should be imported as a number, not text." + diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 4f7a23b..32cfb76 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -149,6 +149,7 @@ public: void testControlImport(); void testNumberFormatHTML(); + void testNumberFormatCSV(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testRangeNameXLS); @@ -184,6 +185,7 @@ public: CPPUNIT_TEST(testCondFormat); CPPUNIT_TEST(testNumberFormatHTML); + CPPUNIT_TEST(testNumberFormatCSV); //disable testPassword on MacOSX due to problems with libsqlite3 //also crashes on DragonFly due to problems with nss/nspr headers @@ -1209,6 +1211,34 @@ void ScFiltersTest::testNumberFormatHTML() // B2 should be imported as a value cell. bool bHasValue = pDoc->HasValueData(1, 1, 0); CPPUNIT_ASSERT_MESSAGE("Fail to import number as a value cell.", bHasValue); + CPPUNIT_ASSERT_MESSAGE("Incorrect value.", pDoc->GetValue(1, 1, 0) == 199.98); + + xDocSh->DoClose(); +} + +void ScFiltersTest::testNumberFormatCSV() +{ + OUString aFileNameBase("numberformat."); + OUString aFileExt = OUString::createFromAscii(aFileFormats[CSV].pName); + OUString aFilterName = OUString::createFromAscii(aFileFormats[CSV].pFilterName); + OUString aFilterType = OUString::createFromAscii(aFileFormats[CSV].pTypeName); + + rtl::OUString aFileName; + createFileURL(aFileNameBase, aFileExt, aFileName); + ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[CSV].nFormatType); + CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + + // Check the header just in case. + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(0, 0, 0) == "Product"); + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(1, 0, 0) == "Price"); + CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(2, 0, 0) == "Note"); + + // B2 should be imported as a value cell. + bool bHasValue = pDoc->HasValueData(1, 1, 0); + CPPUNIT_ASSERT_MESSAGE("Fail to import number as a value cell.", bHasValue); + CPPUNIT_ASSERT_MESSAGE("Incorrect value.", pDoc->GetValue(1, 1, 0) == 199.98); xDocSh->DoClose(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits