diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-09-03 20:37:29 +0200 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-09-03 21:10:10 +0200 |
commit | 34580851065fc04af25e9c83a1106d1478f159e0 (patch) | |
tree | f8ab537904f4ce5683dcc727a9559b1b0282e780 | |
parent | 8c18ffbf9bb250fd49c5fc7ae89cc74155c768c6 (diff) |
fdo#81633: Write test for this.
Change-Id: Ifb9c6229573584edc03c504cb94bb4e49a2309d4
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index cd14262180ca..fd11810e47e0 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5519,6 +5519,43 @@ void Test::testSortRefUpdate() if (!checkFormula(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]")) CPPUNIT_FAIL("Wrong formula in C2!"); + // Undo again. + pUndoMgr->Undo(); + + // Formulas in column C should all be "RC[-2]" again. + for (size_t i = 0; i < nCount; ++i) + m_pDoc->SetString(ScAddress(2,1+i,0), "=RC[-2]"); + + // Turn off reference update on sort. + ScInputOptions aInputOption = SC_MOD()->GetInputOptions(); + aInputOption.SetSortRefUpdate(false); + + bSorted = aFunc.Sort(0, aSortData, true, true, true); + CPPUNIT_ASSERT(bSorted); + + // Check the sort result again. + CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(0,0,0))); + for (size_t i = 0; i < nCount; ++i) + { + double fCheck = aSorted[i]; + CPPUNIT_ASSERT_EQUAL(fCheck, m_pDoc->GetValue(ScAddress(0,i+1,0))); + } + + // Formulas in column C should all remain "RC[-2]". + for (size_t i = 0; i < nCount; ++i) + m_pDoc->SetString(ScAddress(2,1+i,0), "=RC[-2]"); + + // The values in column C should now be the same as sorted values in column A. + m_pDoc->CalcAll(); // just in case... + for (size_t i = 0; i < nCount; ++i) + { + double fCheck = aSorted[i]; + CPPUNIT_ASSERT_EQUAL(fCheck, m_pDoc->GetValue(ScAddress(2,i+1,0))); // column C + } + + // Turn it back on. + aInputOption.SetSortRefUpdate(true); + m_pDoc->DeleteTab(0); } |