summaryrefslogtreecommitdiffstats
path: root/sc/qa
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-26 13:12:16 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-03-26 16:59:20 +0100
commit931c6a095c5f26dc78c531b127aed2ebc86af98d (patch)
tree2162a149ec15c2fc6f0e2a7341bcaaaab525612f /sc/qa
parentswitch to a listener based cond format update, tdf#95437 (diff)
downloadcore-931c6a095c5f26dc78c531b127aed2ebc86af98d.tar.gz
core-931c6a095c5f26dc78c531b127aed2ebc86af98d.zip
add a few unit tests for ScFormulaListener
Change-Id: Ie6c26967167a2dffa0e2047a78eb2b44b6c502f3
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.hxx8
-rw-r--r--sc/qa/unit/ucalc_condformat.cxx78
2 files changed, 86 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 848521d299ac..59a445b5e233 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -444,6 +444,10 @@ public:
void testIconSet();
void testDataBarLengthAutomaticAxis();
void testDataBarLengthMiddleAxis();
+ void testFormulaListenerSingleCellToSingleCell();
+ void testFormulaListenerMultipleCellsToSingleCell();
+ void testFormulaListenerSingleCellToMultipleCells();
+ void testFormulaListenerMultipleCellsToMultipleCells();
void testCondFormatEndsWithStr();
void testCondFormatEndsWithVal();
@@ -691,6 +695,10 @@ public:
CPPUNIT_TEST(testIconSet);
CPPUNIT_TEST(testDataBarLengthAutomaticAxis);
CPPUNIT_TEST(testDataBarLengthMiddleAxis);
+ CPPUNIT_TEST(testFormulaListenerSingleCellToSingleCell);
+ CPPUNIT_TEST(testFormulaListenerSingleCellToMultipleCells);
+ CPPUNIT_TEST(testFormulaListenerMultipleCellsToSingleCell);
+ CPPUNIT_TEST(testFormulaListenerMultipleCellsToMultipleCells);
CPPUNIT_TEST(testImportStream);
CPPUNIT_TEST(testDeleteContents);
CPPUNIT_TEST(testTransliterateText);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 7af25cf66969..aa21471cf511 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -18,6 +18,8 @@
#include "scitems.hxx"
#include "attrib.hxx"
#include "fillinfo.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
#include <svl/sharedstringpool.hxx>
#include <o3tl/make_unique.hxx>
@@ -665,4 +667,80 @@ void Test::testCondFormatEndsWithVal()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaListenerSingleCellToSingleCell()
+{
+ m_pDoc->InsertTab(0, "test");
+
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
+ aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+
+ std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
+
+ ScFormulaListener aListener(m_pDoc);
+
+ aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0));
+
+ m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+ CPPUNIT_ASSERT(aListener.NeedsRepaint());
+
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testFormulaListenerSingleCellToMultipleCells()
+{
+ m_pDoc->InsertTab(0, "test");
+
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
+ aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+
+ std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
+
+ ScFormulaListener aListener(m_pDoc);
+
+ aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0));
+
+ m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+ CPPUNIT_ASSERT(aListener.NeedsRepaint());
+
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testFormulaListenerMultipleCellsToSingleCell()
+{
+ m_pDoc->InsertTab(0, "test");
+
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
+ aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+
+ std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
+
+ ScFormulaListener aListener(m_pDoc);
+
+ aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0));
+
+ m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+ CPPUNIT_ASSERT(aListener.NeedsRepaint());
+
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testFormulaListenerMultipleCellsToMultipleCells()
+{
+ m_pDoc->InsertTab(0, "test");
+
+ ScCompiler aCompiler(m_pDoc, ScAddress(10, 10, 0));
+ aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH);
+
+ std::unique_ptr<ScTokenArray> pTokenArray(aCompiler.CompileString("A1"));
+
+ ScFormulaListener aListener(m_pDoc);
+
+ aListener.addTokenArray(pTokenArray.get(), ScAddress(10, 10, 0));
+
+ m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+ CPPUNIT_ASSERT(aListener.NeedsRepaint());
+
+ m_pDoc->DeleteTab(0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */