diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-22 23:49:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-22 23:49:52 -0400 |
commit | 198ccdf00ee2d9defa1114c4aba6ddcf83418237 (patch) | |
tree | 4bb55cb6c85a4c2fac3e98caeb5dcd44bb1faec7 /sc | |
parent | 1afd1e5ca8872253c491af76c70397fb9e00f900 (diff) |
New unit test for pivot table's case insensitive string comparison.
Change-Id: I31ddd3eedc5a93103ae7efd7ce8698e4dc247937
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index ea545f6d6e5f..63b3b00bc9a2 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -170,6 +170,12 @@ public: void testPivotTableEmptyRows(); void testPivotTableTextNumber(); + /** + * Test for checking that pivot table treats strings in a case insensitive + * manner. + */ + void testPivotTableCaseInsensitiveStrings(); + void testSheetCopy(); void testSheetMove(); void testExternalRef(); @@ -241,6 +247,7 @@ public: CPPUNIT_TEST(testPivotTableDateGrouping); CPPUNIT_TEST(testPivotTableEmptyRows); CPPUNIT_TEST(testPivotTableTextNumber); + CPPUNIT_TEST(testPivotTableCaseInsensitiveStrings); CPPUNIT_TEST(testSheetCopy); CPPUNIT_TEST(testSheetMove); CPPUNIT_TEST(testExternalRef); @@ -2918,6 +2925,62 @@ void Test::testPivotTableTextNumber() m_pDoc->DeleteTab(0); } +void Test::testPivotTableCaseInsensitiveStrings() +{ + m_pDoc->InsertTab(0, OUString("Data")); + m_pDoc->InsertTab(1, OUString("Table")); + + // Raw data + const char* aData[][2] = { + { "Name", "Value" }, + { "A", "1" }, + { "a", "2" }, + }; + + // Dimension definition + DPFieldDef aFields[] = { + { "Name", sheet::DataPilotFieldOrientation_ROW, 0 }, + { "Value", sheet::DataPilotFieldOrientation_DATA, sheet::GeneralFunction_SUM }, + }; + + ScAddress aPos(1,1,0); + ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData)); + CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos); + + ScDPObject* pDPObj = createDPFromRange( + m_pDoc, aDataRange, aFields, SAL_N_ELEMENTS(aFields), false); + + ScDPCollection* pDPs = m_pDoc->GetDPCollection(); + bool bSuccess = pDPs->InsertNewTable(pDPObj); + + CPPUNIT_ASSERT_MESSAGE("failed to insert a new pivot table object into document.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("there should be only one data pilot table.", + pDPs->GetCount() == 1); + pDPObj->SetName(pDPs->CreateNewName()); + + ScRange aOutRange = refresh(pDPObj); + + { + // Expected output table content. 0 = empty cell + const char* aOutputCheck[][2] = { + { "Name", 0 }, + { "A", "3" }, + { "Total Result", "3" }, + }; + + bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "Case insensitive strings"); + CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); + } + + pDPs->FreeTable(pDPObj); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be no more tables.", pDPs->GetCount(), static_cast<size_t>(0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There shouldn't be any more cache stored.", + pDPs->GetSheetCaches().size(), static_cast<size_t>(0)); + + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + void Test::testSheetCopy() { OUString aTabName("TestTab"); |