diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-02 21:14:01 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-02 21:32:25 -0400 |
commit | 8cd605901532c9408422059bb94e35f92088b18e (patch) | |
tree | 24029473ea5a1686652af08dcce2f6cd7ceed01d /sc/qa | |
parent | 1b1e50ccc02b833f2ca8ef85a47dd2e8c28a479b (diff) |
Another test case for this feature.
Change-Id: Ia406baec2867605bf515dac0ba090500e2bbd1ce
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 75 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 |
2 files changed, 77 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index c7c81b8bcb1d..415cca51a174 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6124,6 +6124,81 @@ void Test::testFormulaToValue() m_pDoc->DeleteTab(0); } +void Test::testFormulaToValue2() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); + FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1); + + m_pDoc->InsertTab(0, "Test"); + + const char* aData[][2] = { + { "=1", "=ISFORMULA(RC[-1])" }, + { "=2", "=ISFORMULA(RC[-1])" }, + { "3", "=ISFORMULA(RC[-1])" }, + { "=4", "=ISFORMULA(RC[-1])" }, + { "=5", "=ISFORMULA(RC[-1])" }, + }; + + // Insert data into B2:C6. + ScAddress aPos(1,1,0); // B2 + 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); + + { + // Expected output table content. 0 = empty cell + const char* aOutputCheck[][2] = { + { "1", "TRUE" }, + { "2", "TRUE" }, + { "3", "FALSE" }, + { "4", "TRUE" }, + { "5", "TRUE" }, + }; + + bool bSuccess = checkOutput<2>(m_pDoc, aDataRange, aOutputCheck, "Initial value"); + CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); + } + + // Convert B3:B5 to a value. + ScDocFunc& rFunc = getDocShell().GetDocFunc(); + ScRange aConvRange(1,2,0,1,4,0); // B3:B5 + rFunc.ConvertFormulaToValue(aConvRange, true, false); + + { + // Expected output table content. 0 = empty cell + const char* aOutputCheck[][2] = { + { "1", "TRUE" }, + { "2", "FALSE" }, + { "3", "FALSE" }, + { "4", "FALSE" }, + { "5", "TRUE" }, + }; + + bool bSuccess = checkOutput<2>(m_pDoc, aDataRange, aOutputCheck, "Initial value"); + CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); + } + + // Undo and check. + SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); + CPPUNIT_ASSERT(pUndoMgr); + pUndoMgr->Undo(); + + { + // Expected output table content. 0 = empty cell + const char* aOutputCheck[][2] = { + { "1", "TRUE" }, + { "2", "TRUE" }, + { "3", "FALSE" }, + { "4", "TRUE" }, + { "5", "TRUE" }, + }; + + bool bSuccess = checkOutput<2>(m_pDoc, aDataRange, aOutputCheck, "Initial value"); + CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); + } + + m_pDoc->DeleteTab(0); +} + void Test::testMixData() { m_pDoc->InsertTab(0, "Test"); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index e59378cefa7b..259d0a236a6e 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -388,6 +388,7 @@ public: void testTransliterateText(); void testFormulaToValue(); + void testFormulaToValue2(); void testColumnFindEditCells(); @@ -572,6 +573,7 @@ public: CPPUNIT_TEST(testDeleteContents); CPPUNIT_TEST(testTransliterateText); CPPUNIT_TEST(testFormulaToValue); + CPPUNIT_TEST(testFormulaToValue2); CPPUNIT_TEST(testColumnFindEditCells); CPPUNIT_TEST_SUITE_END(); |