diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-13 14:45:59 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-13 14:45:59 -0400 |
commit | b8430f71d37ea5181fc812fc07a20555b07a0b3c (patch) | |
tree | d7989fae1d03a08fb3a31de363e303a7229b5591 /sc/qa | |
parent | 51f1fc69aa539dec8035195b98e0b128026388e9 (diff) |
Add test for csv filter as well.
The content is intentionally identical to the html counterpart.
Change-Id: Ie9a91ceafdb56a0c915bc0175d49bb494c38e9af
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/csv/numberformat.csv | 3 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 30 |
2 files changed, 33 insertions, 0 deletions
diff --git a/sc/qa/unit/data/csv/numberformat.csv b/sc/qa/unit/data/csv/numberformat.csv new file mode 100644 index 000000000000..2111b944b281 --- /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 4f7a23beccc4..32cfb76406c1 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(); } |