diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-29 19:42:02 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-29 19:46:34 +0200 |
commit | 332451bea5ebe08136de2d51e0e29cac88f89e8c (patch) | |
tree | ca34a2a4cb92e8d998e88830a2e5d81a100f43c5 /sc | |
parent | move ScProgress construction out of ScTable::Sort (diff) | |
download | core-332451bea5ebe08136de2d51e0e29cac88f89e8c.tar.gz core-332451bea5ebe08136de2d51e0e29cac88f89e8c.zip |
add unit test for basic sorting with cell note
Change-Id: I997f96e0a9f6aa4c2ed7f2d3811a84fdfda05683
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 63b3b00bc9a2..a6d51157228c 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -224,6 +224,7 @@ public: void testFindAreaPosRowDown(); void testFindAreaPosColRight(); + void testSort(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testCollator); @@ -271,6 +272,7 @@ public: CPPUNIT_TEST(testCopyPasteFormulasExternalDoc); CPPUNIT_TEST(testFindAreaPosRowDown); CPPUNIT_TEST(testFindAreaPosColRight); + CPPUNIT_TEST(testSort); CPPUNIT_TEST_SUITE_END(); private: @@ -4881,6 +4883,49 @@ void Test::testFindAreaPosColRight() pDoc->DeleteTab(0); } +void Test::testSort() +{ + ScDocument* pDoc = m_xDocShRef->GetDocument(); + rtl::OUString aTabName1("test1"); + pDoc->InsertTab(0, aTabName1); + + const char* aData[][2] = { + { "2", "4" }, + { "4", "1" }, + { "1", "2" } + }; + + clearRange( pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0)); + ScAddress aPos(0,0,0); + ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData)); + CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos); + + rtl::OUString aHello("Hello"); + rtl::OUString aJimBob("Jim Bob"); + ScAddress rAddr(1, 1, 0); + ScPostIt* pNote = m_pDoc->GetNotes(rAddr.Tab())->GetOrCreateNote(rAddr); + pNote->SetText(rAddr, aHello); + pNote->SetAuthor(aJimBob); + + ScSortParam aSortData; + aSortData.nCol1 = 1; + aSortData.nCol2 = 1; + aSortData.nRow1 = 0; + aSortData.nRow2 = 2; + aSortData.maKeyState[0].bDoSort = true; + aSortData.maKeyState[0].nField = 1; + + pDoc->Sort(0, aSortData, false, NULL); + double nVal = pDoc->GetValue(1,0,0); + CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, 1.0, 1e-8); + + // check that note is also moved + pNote = m_pDoc->GetNotes(0)->findByAddress( 1, 0 ); + CPPUNIT_ASSERT(pNote); + + pDoc->DeleteTab(0); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |