summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-05-14 12:26:12 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-05-17 17:48:19 +0200
commitc29f91f3d7a0deb902b900ff07e6c32632b8c958 (patch)
tree0889403f2c2460ed1373e172501041e7e3dd37e2
parent9bbf8057d9d92857aa3c693c1387589ad378695d (diff)
sc_ucalc: move formula tests to their own module
in order to split sc_ucalc monster into smaller modules Now, we can change CppunitTest_sc_ucalc.mk to use the template - Enable testExternalRefUnresolved on Linux/Mac - Remove testFormulaHashAndTag. it was disabled in f4dc8a869ac49f19c20fc5fa606448e9103726bd < the idea behind the test can't work right now > Change-Id: I864341442ccd321c8ef4f7147db4512bcc7a6b21 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115595 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--compilerplugins/clang/unusedmethods.results6
-rw-r--r--sc/CppunitTest_sc_ucalc.mk109
-rw-r--r--sc/CppunitTest_sc_ucalc_formula.mk14
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/unit/helper/qahelper.cxx7
-rw-r--r--sc/qa/unit/helper/qahelper.hxx1
-rw-r--r--sc/qa/unit/ucalc.cxx15
-rw-r--r--sc/qa/unit/ucalc.hxx254
-rw-r--r--sc/qa/unit/ucalc_formula.cxx828
9 files changed, 536 insertions, 699 deletions
diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results
index 88857e7f81f2..172eaaec7b09 100644
--- a/compilerplugins/clang/unusedmethods.results
+++ b/compilerplugins/clang/unusedmethods.results
@@ -1176,12 +1176,6 @@ sc/qa/unit/helper/qahelper.hxx:155
class std::__cxx11::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > print(const class ScAddress &)
sc/qa/unit/screenshots/screenshots.cxx:325
int main()
-sc/qa/unit/ucalc.hxx:151
- void Test::testFormulaHashAndTag()
-sc/qa/unit/ucalc.hxx:191
- void Test::testSingleCellCopyColumnLabel()
-sc/qa/unit/ucalc.hxx:251
- void Test::testExternalRefUnresolved()
sc/source/core/inc/interpre.hxx:71
basic_ostream<type-parameter-?-?, type-parameter-?-?> & sc::operator<<(basic_ostream<type-parameter-?-?, type-parameter-?-?> &,const struct sc::ParamIfsResult &)
sc/source/core/opencl/formulagroupcl.cxx:1061
diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk
index 16dfcf0e1d55..16fe696f9b13 100644
--- a/sc/CppunitTest_sc_ucalc.mk
+++ b/sc/CppunitTest_sc_ucalc.mk
@@ -9,112 +9,7 @@
#
#*************************************************************************
-$(eval $(call gb_CppunitTest_CppunitTest,sc_ucalc))
-
-$(eval $(call gb_Library_use_common_precompiled_header,sc_ucalc))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,sc_ucalc, \
- sc/qa/unit/ucalc \
- sc/qa/unit/ucalc_formula \
-))
-
-$(eval $(call gb_CppunitTest_use_library_objects,sc_ucalc, \
- sc \
- scqahelper \
-))
-
-$(eval $(call gb_CppunitTest_use_externals,sc_ucalc,\
- boost_headers \
- $(call gb_Helper_optional,OPENCL, \
- clew) \
- icu_headers \
- icui18n \
- icuuc \
- libxml2 \
- mdds_headers \
- orcus \
- orcus-parser \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,sc_ucalc, \
- $(call gb_Helper_optional,AVMEDIA,avmedia) \
- basegfx \
- comphelper \
- cppu \
- cppuhelper \
- dbtools \
- drawinglayer \
- editeng \
- for \
- forui \
- i18nlangtag \
- i18nutil \
- $(call gb_Helper_optional,OPENCL, \
- opencl) \
- sal \
- salhelper \
- sax \
- sb \
- sfx \
- sot \
- svl \
- svt \
- svx \
- svxcore \
- test \
- tk \
- tl \
- ucbhelper \
- unotest \
- utl \
- vbahelper \
- vcl \
- xo \
-))
-
-$(eval $(call gb_CppunitTest_set_include,sc_ucalc,\
- -I$(SRCDIR)/sc/source/ui/inc \
- -I$(SRCDIR)/sc/source/core/inc \
- -I$(SRCDIR)/sc/inc \
- $$(INCLUDE) \
-))
-
-$(eval $(call gb_CppunitTest_use_api,sc_ucalc,\
- udkapi \
- offapi \
- oovbaapi \
-))
-
-$(eval $(call gb_CppunitTest_use_custom_headers,sc_ucalc,\
- officecfg/registry \
-))
-
-$(eval $(call gb_CppunitTest_use_ure,sc_ucalc))
-$(eval $(call gb_CppunitTest_use_vcl,sc_ucalc))
-
-$(eval $(call gb_CppunitTest_use_components,sc_ucalc,\
- configmgr/source/configmgr \
- framework/util/fwk \
- i18npool/source/search/i18nsearch \
- i18npool/util/i18npool \
- sax/source/expatwrap/expwrap \
- scaddins/source/analysis/analysis \
- scaddins/source/datefunc/date \
- scaddins/source/pricing/pricing \
- sfx2/util/sfx \
- ucb/source/core/ucb1 \
- ucb/source/ucp/file/ucpfile1 \
- unoxml/source/service/unoxml \
- uui/util/uui \
- vcl/vcl.common \
-))
-
-ifeq ($(OS),LINUX)
-$(eval $(call gb_CppunitTest_add_libs,sc_ucalc,\
- -lrt \
-))
-endif
-
-$(eval $(call gb_CppunitTest_use_configuration,sc_ucalc))
+# empty second argument (i.e. no 1)
+$(eval $(call sc_ucalc_test,))
# vim: set noet sw=4 ts=4:
diff --git a/sc/CppunitTest_sc_ucalc_formula.mk b/sc/CppunitTest_sc_ucalc_formula.mk
new file mode 100644
index 000000000000..2dfeddb318cd
--- /dev/null
+++ b/sc/CppunitTest_sc_ucalc_formula.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call sc_ucalc_test,_formula))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 94880fb19a72..1d31df9b44fa 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
CppunitTest_sc_ucalc) \
CppunitTest_sc_ucalc_condformat \
CppunitTest_sc_ucalc_copypaste \
+ CppunitTest_sc_ucalc_formula \
CppunitTest_sc_ucalc_pivottable \
CppunitTest_sc_ucalc_sharedformula \
CppunitTest_sc_ucalc_sort \
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 46196f9c28f4..8502cf6caf52 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -979,6 +979,13 @@ void pasteOneCellFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, ScDoc
rDestRange.aEnd.Col(), rDestRange.aEnd.Row());
}
+void setCalcAsShown(ScDocument* pDoc, bool bCalcAsShown)
+{
+ ScDocOptions aOpt = pDoc->GetDocOptions();
+ aOpt.SetCalcAsShown(bCalcAsShown);
+ pDoc->SetDocOptions(aOpt);
+}
+
ScDocShell* findLoadedDocShellByName(std::u16string_view rName)
{
ScDocShell* pShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<ScDocShell>, false));
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 4d9986dd7373..d0a449f88f5d 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -252,6 +252,7 @@ SCQAHELPER_DLLPUBLIC ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRa
SCQAHELPER_DLLPUBLIC void pasteOneCellFromClip(ScDocument* pDestDoc, const ScRange& rDestRange,
ScDocument* pClipDoc,
InsertDeleteFlags eFlags = InsertDeleteFlags::ALL);
+SCQAHELPER_DLLPUBLIC void setCalcAsShown(ScDocument* pDoc, bool bCalcAsShown);
SCQAHELPER_DLLPUBLIC ScDocShell* findLoadedDocShellByName(std::u16string_view rName);
SCQAHELPER_DLLPUBLIC ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos,
const std::vector<std::vector<const char*>>& rData);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 49238a0f4191..ae37d3007981 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5869,21 +5869,6 @@ void Test::testEmptyCalcDocDefaults()
CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasManualBreaks(tab) );
}
-void Test::setExpandRefs(bool bExpand)
-{
- ScModule* pMod = SC_MOD();
- ScInputOptions aOpt = pMod->GetInputOptions();
- aOpt.SetExpandRefs(bExpand);
- pMod->SetInputOptions(aOpt);
-}
-
-void Test::setCalcAsShown(ScDocument* pDoc, bool bCalcAsShown)
-{
- ScDocOptions aOpt = pDoc->GetDocOptions();
- aOpt.SetCalcAsShown(bCalcAsShown);
- pDoc->SetDocOptions(aOpt);
-}
-
void Test::checkPrecisionAsShown( OUString& rCode, double fValue, double fExpectedRoundVal )
{
SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1cb34cec4b25..5d272430f88c 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -22,14 +22,6 @@ class ScUndoCut;
class Test : public test::BootstrapFixture
{
public:
- /**
- * Enable or disable expand reference options which controls how
- * references in formula are expanded when inserting rows or columns.
- */
- static void setExpandRefs(bool bExpand);
-
- static void setCalcAsShown(ScDocument* pDoc, bool bCalcAsShown);
-
void checkPrecisionAsShown(OUString& rCode, double fValue, double fExpectedRoundVal);
Test();
@@ -72,110 +64,6 @@ public:
void testMarkedCellIteration();
- void testFormulaCreateStringFromTokens();
- void testFormulaParseReference();
- void testFetchVectorRefArray();
- void testGroupConverter3D();
- void testFormulaHashAndTag();
- void testFormulaTokenEquality();
- void testFormulaRefData();
- void testFormulaCompiler();
- void testFormulaCompilerJumpReordering();
- void testFormulaCompilerImplicitIntersection2Param();
- void testFormulaCompilerImplicitIntersection1ParamNoChange();
- void testFormulaCompilerImplicitIntersection1ParamWithChange();
- void testFormulaCompilerImplicitIntersection1NoGroup();
- void testFormulaCompilerImplicitIntersectionOperators();
- void testFormulaAnnotateTrimOnDoubleRefs();
- void testFormulaRefUpdate();
- void testFormulaRefUpdateRange();
- void testFormulaRefUpdateSheets();
- void testFormulaRefUpdateSheetsDelete();
- void testFormulaRefUpdateInsertRows();
- void testFormulaRefUpdateInsertColumns();
- void testFormulaRefUpdateMove();
- void testFormulaRefUpdateMoveUndo();
- void testFormulaRefUpdateMoveUndo2();
- void testFormulaRefUpdateMoveUndo3NonShared();
- void testFormulaRefUpdateMoveUndo3Shared();
- void testFormulaRefUpdateMoveUndoDependents();
- void testFormulaRefUpdateMoveUndo4();
- void testFormulaRefUpdateMoveToSheet();
- void testFormulaRefUpdateDeleteContent();
- void testFormulaRefUpdateDeleteAndShiftLeft();
- void testFormulaRefUpdateDeleteAndShiftLeft2();
- void testFormulaRefUpdateDeleteAndShiftUp();
- void testFormulaRefUpdateName();
- void testFormulaRefUpdateNameMove();
- void testFormulaRefUpdateNameExpandRef();
- void testFormulaRefUpdateNameExpandRef2();
- void testFormulaRefUpdateNameDeleteRow();
- void testFormulaRefUpdateNameCopySheet();
- void testFormulaRefUpdateNameCopySheetCheckTab(SCTAB Tab, bool bCheckNames);
- void testFormulaRefUpdateSheetLocalMove();
- void testFormulaRefUpdateNameDelete();
- void testFormulaRefUpdateValidity();
- void testTokenArrayRefUpdateMove();
- void testSingleCellCopyColumnLabel();
- void testIntersectionOpExcel();
- void testMultipleOperations();
- void testFuncCOLUMN();
- void testFuncCOUNT();
- void testFuncCOUNTBLANK();
- void testFuncROW();
- void testFuncSUM();
- void testFuncPRODUCT();
- void testFuncSUMPRODUCT();
- void testFuncSUMXMY2();
- void testFuncMIN();
- void testFuncN();
- void testFuncCOUNTIF();
- void testFuncNUMBERVALUE();
- void testFuncLEN();
- void testFuncLOOKUP();
- void testFuncLOOKUParrayWithError();
- void testTdf141146();
- void testFuncVLOOKUP();
- void testFuncMATCH();
- void testFuncCELL();
- void testFuncDATEDIF();
- void testFuncINDIRECT();
- void testFuncINDIRECT2();
- void testFunc_MATCH_INDIRECT();
- void testFuncIF();
- void testFuncCHOOSE();
- void testFuncIFERROR();
- void testFuncSHEET();
- void testFuncNOW();
- void testMatrixOp();
- void testFuncRangeOp();
- void testFuncFORMULA();
- void testFuncTableRef();
- void testFuncFTEST();
- void testFuncFTESTBug();
- void testFuncCHITEST();
- void testFuncTTEST();
- void testFuncSUMX2PY2();
- void testFuncSUMX2MY2();
- void testFuncGCD();
- void testFuncLCM();
- void testFuncSUMSQ();
- void testFuncMDETERM();
- void testFuncSUMIFS();
- void testFuncRefListArraySUBTOTAL();
- void testFuncJumpMatrixArrayIF();
- void testFuncJumpMatrixArrayOFFSET();
- void testMatConcat();
- void testMatConcatReplication();
- void testRefR1C1WholeCol();
- void testRefR1C1WholeRow();
- void testIterations();
-
- void testExternalRef();
- void testExternalRefFunctions();
- void testExternalRangeName();
- void testExternalRefUnresolved();
-
void testCopyToDocument();
void testHorizontalIterator();
@@ -183,24 +71,6 @@ public:
void testHorizontalAttrIterator();
/**
- * Basic test for formula dependency tracking.
- */
- void testFormulaDepTracking();
-
- /**
- * Another test for formula dependency tracking, inspired by fdo#56278.
- */
- void testFormulaDepTracking2();
-
- void testFormulaDepTracking3();
-
- void testFormulaDepTrackingDeleteRow();
-
- void testFormulaDepTrackingDeleteCol();
-
- void testFormulaMatrixResultUpdate();
-
- /**
* More direct test for cell broadcaster management, used to track formula
* dependencies.
*/
@@ -294,23 +164,14 @@ public:
// tdf#80137
void testCopyPasteMatrixFormula();
void testUndoDataAnchor();
- void testFormulaErrorPropagation();
void testSetFormula();
void testMultipleDataCellsInRange();
- void testTdf97369();
- void testTdf97587();
- void testTdf93415();
- void testTdf100818();
-
void testEmptyCalcDocDefaults();
void testPrecisionAsShown();
void testProtectedSheetEditByRow();
void testProtectedSheetEditByColumn();
- void testFuncRowsHidden();
- void testInsertColCellStoreEventSwap();
- void testFormulaAfterDeleteRows();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testCollator);
@@ -328,117 +189,10 @@ public:
CPPUNIT_TEST(testDataEntries);
CPPUNIT_TEST(testSelectionFunction);
CPPUNIT_TEST(testMarkedCellIteration);
- CPPUNIT_TEST(testFormulaCreateStringFromTokens);
- CPPUNIT_TEST(testFormulaParseReference);
- CPPUNIT_TEST(testFetchVectorRefArray);
- CPPUNIT_TEST(testGroupConverter3D);
- // CPPUNIT_TEST(testFormulaHashAndTag);
- CPPUNIT_TEST(testFormulaTokenEquality);
- CPPUNIT_TEST(testFormulaRefData);
- CPPUNIT_TEST(testFormulaCompiler);
- CPPUNIT_TEST(testFormulaCompilerJumpReordering);
- CPPUNIT_TEST(testFormulaCompilerImplicitIntersection2Param);
- CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1ParamNoChange);
- CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1ParamWithChange);
- CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1NoGroup);
- CPPUNIT_TEST(testFormulaCompilerImplicitIntersectionOperators);
- CPPUNIT_TEST(testFormulaAnnotateTrimOnDoubleRefs);
- CPPUNIT_TEST(testFormulaRefUpdate);
- CPPUNIT_TEST(testFormulaRefUpdateRange);
- CPPUNIT_TEST(testFormulaRefUpdateSheets);
- CPPUNIT_TEST(testFormulaRefUpdateSheetsDelete);
- CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
- CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
- CPPUNIT_TEST(testFormulaRefUpdateMove);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndo2);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndoDependents);
- CPPUNIT_TEST(testFormulaRefUpdateMoveUndo4);
- CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
- CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
- CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
- CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft2);
- CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftUp);
- CPPUNIT_TEST(testFormulaRefUpdateName);
- CPPUNIT_TEST(testFormulaRefUpdateNameMove);
- CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef);
- CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef2);
- CPPUNIT_TEST(testFormulaRefUpdateNameDeleteRow);
- CPPUNIT_TEST(testFormulaRefUpdateNameCopySheet);
- CPPUNIT_TEST(testFormulaRefUpdateSheetLocalMove);
- CPPUNIT_TEST(testFormulaRefUpdateNameDelete);
- CPPUNIT_TEST(testFormulaRefUpdateValidity);
- CPPUNIT_TEST(testTokenArrayRefUpdateMove);
- CPPUNIT_TEST(testIntersectionOpExcel);
- CPPUNIT_TEST(testMultipleOperations);
- CPPUNIT_TEST(testFuncCOLUMN);
- CPPUNIT_TEST(testFuncCOUNT);
- CPPUNIT_TEST(testFuncCOUNTBLANK);
- CPPUNIT_TEST(testFuncROW);
- CPPUNIT_TEST(testFuncSUM);
- CPPUNIT_TEST(testFuncPRODUCT);
- CPPUNIT_TEST(testFuncSUMPRODUCT);
- CPPUNIT_TEST(testFuncSUMXMY2);
- CPPUNIT_TEST(testFuncMIN);
- CPPUNIT_TEST(testFuncN);
- CPPUNIT_TEST(testFuncCOUNTIF);
- CPPUNIT_TEST(testFuncNUMBERVALUE);
- CPPUNIT_TEST(testFuncLEN);
- CPPUNIT_TEST(testFuncLOOKUP);
- CPPUNIT_TEST(testFuncLOOKUParrayWithError);
- CPPUNIT_TEST(testTdf141146);
- CPPUNIT_TEST(testFuncVLOOKUP);
- CPPUNIT_TEST(testFuncMATCH);
- CPPUNIT_TEST(testFuncCELL);
- CPPUNIT_TEST(testFuncDATEDIF);
- CPPUNIT_TEST(testFuncINDIRECT);
- CPPUNIT_TEST(testFuncINDIRECT2);
- CPPUNIT_TEST(testFunc_MATCH_INDIRECT);
- CPPUNIT_TEST(testFuncIF);
- CPPUNIT_TEST(testFuncCHOOSE);
- CPPUNIT_TEST(testFuncIFERROR);
- CPPUNIT_TEST(testRefR1C1WholeCol);
- CPPUNIT_TEST(testRefR1C1WholeRow);
- CPPUNIT_TEST(testIterations);
- CPPUNIT_TEST(testMatrixOp);
- CPPUNIT_TEST(testFuncRangeOp);
- CPPUNIT_TEST(testFuncFORMULA);
- CPPUNIT_TEST(testFuncTableRef);
- CPPUNIT_TEST(testFuncFTEST);
- CPPUNIT_TEST(testFuncFTESTBug);
- CPPUNIT_TEST(testFuncCHITEST);
- CPPUNIT_TEST(testFuncTTEST);
- CPPUNIT_TEST(testFuncSUMX2PY2);
- CPPUNIT_TEST(testFuncSUMX2MY2);
- CPPUNIT_TEST(testFuncGCD);
- CPPUNIT_TEST(testFuncLCM);
- CPPUNIT_TEST(testFuncSUMSQ);
- CPPUNIT_TEST(testFuncMDETERM);
- CPPUNIT_TEST(testFuncSUMIFS);
- CPPUNIT_TEST(testFuncRefListArraySUBTOTAL);
- CPPUNIT_TEST(testFuncJumpMatrixArrayIF);
- CPPUNIT_TEST(testFuncJumpMatrixArrayOFFSET);
- CPPUNIT_TEST(testMatConcat);
- CPPUNIT_TEST(testMatConcatReplication);
- CPPUNIT_TEST(testExternalRef);
- CPPUNIT_TEST(testExternalRangeName);
- CPPUNIT_TEST(testExternalRefFunctions);
- // currently crashes windows
- // CPPUNIT_TEST(testExternalRefUnresolved);
CPPUNIT_TEST(testCopyToDocument);
- CPPUNIT_TEST(testFuncSHEET);
- CPPUNIT_TEST(testFuncNOW);
CPPUNIT_TEST(testHorizontalIterator);
CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testHorizontalAttrIterator);
- CPPUNIT_TEST(testFormulaDepTracking);
- CPPUNIT_TEST(testFormulaDepTracking2);
- CPPUNIT_TEST(testFormulaDepTracking3);
- CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
- CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
- CPPUNIT_TEST(testFormulaMatrixResultUpdate);
CPPUNIT_TEST(testCellBroadcaster);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);
@@ -496,20 +250,12 @@ public:
CPPUNIT_TEST(testSetStringAndNote);
CPPUNIT_TEST(testCopyPasteMatrixFormula);
CPPUNIT_TEST(testUndoDataAnchor);
- CPPUNIT_TEST(testFormulaErrorPropagation);
CPPUNIT_TEST(testSetFormula);
CPPUNIT_TEST(testMultipleDataCellsInRange);
- CPPUNIT_TEST(testTdf97369);
- CPPUNIT_TEST(testTdf97587);
- CPPUNIT_TEST(testTdf93415);
- CPPUNIT_TEST(testTdf100818);
CPPUNIT_TEST(testEmptyCalcDocDefaults);
CPPUNIT_TEST(testPrecisionAsShown);
CPPUNIT_TEST(testProtectedSheetEditByRow);
CPPUNIT_TEST(testProtectedSheetEditByColumn);
- CPPUNIT_TEST(testFuncRowsHidden);
- CPPUNIT_TEST(testInsertColCellStoreEventSwap);
- CPPUNIT_TEST(testFormulaAfterDeleteRows);
CPPUNIT_TEST_SUITE_END();
private:
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 3a2dca70affe..41e769b59877 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "ucalc.hxx"
+#include <test/bootstrapfixture.hxx>
#include "helper/debughelper.hxx"
#include "helper/qahelper.hxx"
#include <markdata.hxx>
@@ -20,6 +20,7 @@
#include <formulacell.hxx>
#include <docsh.hxx>
#include <docfunc.hxx>
+#include <inputopt.hxx>
#include <paramisc.hxx>
#include <tokenstringcontext.hxx>
#include <refupdatecontext.hxx>
@@ -32,6 +33,7 @@
#include <docoptio.hxx>
#include <formulaopt.hxx>
#include <externalrefmgr.hxx>
+#include <scdll.hxx>
#include <scmod.hxx>
#include <svl/itemset.hxx>
@@ -85,9 +87,391 @@ ScRange getCachedRange(const ScExternalRefCache::TableTypeRef& pCacheTab)
return aRange;
}
+void setExpandRefs(bool bExpand)
+{
+ ScModule* pMod = SC_MOD();
+ ScInputOptions aOpt = pMod->GetInputOptions();
+ aOpt.SetExpandRefs(bExpand);
+ pMod->SetInputOptions(aOpt);
+}
+
+void testFormulaRefUpdateNameCopySheetCheckTab( ScDocument* pDoc, SCTAB nTab, bool bCheckNames )
+{
+ if (bCheckNames)
+ {
+ const ScRangeData* pName;
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("LOCAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_GLOBAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_GLOBAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_LOCAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_LOCAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_UNUSED");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_UNUSED should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_UNUSED_NOREF");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_UNUSED_NOREF should not exist", !pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_GLOBAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_GLOBAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_LOCAL");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_LOCAL should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_UNUSED");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_UNUSED should exist", pName);
+ pName = pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_UNUSED_NOREF");
+ CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_UNUSED_NOREF should exist", pName);
+ }
+
+ ScAddress aPos(0,0,0);
+ aPos.SetRow(0);
+ aPos.SetTab(nTab);
+ int nSheet = nTab + 1;
+ CPPUNIT_ASSERT_EQUAL( 1.0 * nSheet, pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL( 11.0 * nSheet, pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL( 100.0 * nSheet, pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL( 11000.0 * nSheet, pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL( 10000.0 * nSheet, pDoc->GetValue(aPos));
+ aPos.IncRow();
+ CPPUNIT_ASSERT_EQUAL( 1100000.0 * nSheet, pDoc->GetValue(aPos));
+}
+
+class ColumnTest
+{
+ ScDocument * m_pDoc;
+
+ const SCROW m_nTotalRows;
+ const SCROW m_nStart1;
+ const SCROW m_nEnd1;
+ const SCROW m_nStart2;
+ const SCROW m_nEnd2;
+
+public:
+ ColumnTest( ScDocument * pDoc, SCROW nTotalRows,
+ SCROW nStart1, SCROW nEnd1, SCROW nStart2, SCROW nEnd2 )
+ : m_pDoc(pDoc), m_nTotalRows(nTotalRows)
+ , m_nStart1(nStart1), m_nEnd1(nEnd1)
+ , m_nStart2(nStart2), m_nEnd2(nEnd2)
+ {}
+
+ void operator() ( SCCOL nColumn, const OUString& rFormula,
+ std::function<double(SCROW )> const & lExpected ) const
+ {
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ ScMarkData aMark(m_pDoc->GetSheetLimits());
+
+ ScAddress aPos(nColumn, m_nStart1, 0);
+ m_pDoc->SetString(aPos, rFormula);
+ ASSERT_DOUBLES_EQUAL( lExpected(m_nStart1), m_pDoc->GetValue(aPos) );
+
+ // Copy formula cell to clipboard.
+ ScClipParam aClipParam(aPos, false);
+ aMark.SetMarkArea(aPos);
+ m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
+
+ // Paste it to first range.
+ InsertDeleteFlags nFlags = InsertDeleteFlags::CONTENTS;
+ ScRange aDestRange(nColumn, m_nStart1, 0, nColumn, m_nEnd1, 0);
+ aMark.SetMarkArea(aDestRange);
+ m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
+
+ // Paste it second range.
+ aDestRange = ScRange(nColumn, m_nStart2, 0, nColumn, m_nEnd2, 0);
+ aMark.SetMarkArea(aDestRange);
+ m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
+
+ // Check the formula results for passed column.
+ for( SCROW i = 0; i < m_nTotalRows; ++i )
+ {
+ if( !((m_nStart1 <= i && i <= m_nEnd1) || (m_nStart2 <= i && i <= m_nEnd2)) )
+ continue;
+ double fExpected = lExpected(i);
+ ASSERT_DOUBLES_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(nColumn,i,0)));
+ }
+ }
+};
+
+}
+
+class TestFormula : public test::BootstrapFixture
+{
+public:
+ TestFormula();
+
+ virtual void setUp() override;
+ virtual void tearDown() override;
+
+ void testFormulaCreateStringFromTokens();
+ void testFormulaParseReference();
+ void testFetchVectorRefArray();
+ void testGroupConverter3D();
+ void testFormulaTokenEquality();
+ void testFormulaRefData();
+ void testFormulaCompiler();
+ void testFormulaCompilerJumpReordering();
+ void testFormulaCompilerImplicitIntersection2Param();
+ void testFormulaCompilerImplicitIntersection1ParamNoChange();
+ void testFormulaCompilerImplicitIntersection1ParamWithChange();
+ void testFormulaCompilerImplicitIntersection1NoGroup();
+ void testFormulaCompilerImplicitIntersectionOperators();
+ void testFormulaAnnotateTrimOnDoubleRefs();
+ void testFormulaRefUpdate();
+ void testFormulaRefUpdateRange();
+ void testFormulaRefUpdateSheets();
+ void testFormulaRefUpdateSheetsDelete();
+ void testFormulaRefUpdateInsertRows();
+ void testFormulaRefUpdateInsertColumns();
+ void testFormulaRefUpdateMove();
+ void testFormulaRefUpdateMoveUndo();
+ void testFormulaRefUpdateMoveUndo2();
+ void testFormulaRefUpdateMoveUndo3NonShared();
+ void testFormulaRefUpdateMoveUndo3Shared();
+ void testFormulaRefUpdateMoveUndoDependents();
+ void testFormulaRefUpdateMoveUndo4();
+ void testFormulaRefUpdateMoveToSheet();
+ void testFormulaRefUpdateDeleteContent();
+ void testFormulaRefUpdateDeleteAndShiftLeft();
+ void testFormulaRefUpdateDeleteAndShiftLeft2();
+ void testFormulaRefUpdateDeleteAndShiftUp();
+ void testFormulaRefUpdateName();
+ void testFormulaRefUpdateNameMove();
+ void testFormulaRefUpdateNameExpandRef();
+ void testFormulaRefUpdateNameExpandRef2();
+ void testFormulaRefUpdateNameDeleteRow();
+ void testFormulaRefUpdateNameCopySheet();
+ void testFormulaRefUpdateSheetLocalMove();
+ void testFormulaRefUpdateNameDelete();
+ void testFormulaRefUpdateValidity();
+ void testTokenArrayRefUpdateMove();
+ void testSingleCellCopyColumnLabel();
+ void testIntersectionOpExcel();
+ void testTdf97369();
+ void testTdf97587();
+ void testTdf93415();
+ void testTdf100818();
+ void testMatConcat();
+ void testMatConcatReplication();
+ void testExternalRef();
+ void testFormulaDepTracking();
+ void testFormulaDepTracking2();
+ void testFormulaDepTracking3();
+ void testFormulaDepTrackingDeleteRow();
+ void testFormulaDepTrackingDeleteCol();
+ void testFormulaMatrixResultUpdate();
+ void testExternalRefFunctions();
+ void testExternalRangeName();
+ void testExternalRefUnresolved();
+ void testRefR1C1WholeCol();
+ void testRefR1C1WholeRow();
+ void testIterations();
+ void testInsertColCellStoreEventSwap();
+ void testFormulaAfterDeleteRows();
+ void testMultipleOperations();
+ void testFuncCOLUMN();
+ void testFuncCOUNT();
+ void testFuncCOUNTBLANK();
+ void testFuncROW();
+ void testFuncSUM();
+ void testFuncPRODUCT();
+ void testFuncSUMPRODUCT();
+ void testFuncSUMXMY2();
+ void testFuncMIN();
+ void testFuncN();
+ void testFuncCOUNTIF();
+ void testFuncNUMBERVALUE();
+ void testFuncLEN();
+ void testFuncLOOKUP();
+ void testFuncLOOKUParrayWithError();
+ void testTdf141146();
+ void testFuncVLOOKUP();
+ void testFuncMATCH();
+ void testFuncCELL();
+ void testFuncDATEDIF();
+ void testFuncINDIRECT();
+ void testFuncINDIRECT2();
+ void testFunc_MATCH_INDIRECT();
+ void testFuncIF();
+ void testFuncCHOOSE();
+ void testFuncIFERROR();
+ void testFuncSHEET();
+ void testFuncNOW();
+ void testMatrixOp();
+ void testFuncRangeOp();
+ void testFuncFORMULA();
+ void testFuncTableRef();
+ void testFuncFTEST();
+ void testFuncFTESTBug();
+ void testFuncCHITEST();
+ void testFuncTTEST();
+ void testFuncSUMX2PY2();
+ void testFuncSUMX2MY2();
+ void testFuncGCD();
+ void testFuncLCM();
+ void testFuncSUMSQ();
+ void testFuncMDETERM();
+ void testFormulaErrorPropagation();
+ void testFuncRowsHidden();
+ void testFuncSUMIFS();
+ void testFuncRefListArraySUBTOTAL();
+ void testFuncJumpMatrixArrayIF();
+ void testFuncJumpMatrixArrayOFFSET();
+
+ CPPUNIT_TEST_SUITE(TestFormula);
+
+ CPPUNIT_TEST(testFormulaCreateStringFromTokens);
+ CPPUNIT_TEST(testFormulaParseReference);
+ CPPUNIT_TEST(testFetchVectorRefArray);
+ CPPUNIT_TEST(testGroupConverter3D);
+ CPPUNIT_TEST(testFormulaTokenEquality);
+ CPPUNIT_TEST(testFormulaRefData);
+ CPPUNIT_TEST(testFormulaCompiler);
+ CPPUNIT_TEST(testFormulaCompilerJumpReordering);
+ CPPUNIT_TEST(testFormulaCompilerImplicitIntersection2Param);
+ CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1ParamNoChange);
+ CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1ParamWithChange);
+ CPPUNIT_TEST(testFormulaCompilerImplicitIntersection1NoGroup);
+ CPPUNIT_TEST(testFormulaCompilerImplicitIntersectionOperators);
+ CPPUNIT_TEST(testFormulaAnnotateTrimOnDoubleRefs);
+ CPPUNIT_TEST(testFormulaRefUpdate);
+ CPPUNIT_TEST(testFormulaRefUpdateRange);
+ CPPUNIT_TEST(testFormulaRefUpdateSheets);
+ CPPUNIT_TEST(testFormulaRefUpdateSheetsDelete);
+ CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
+ CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
+ CPPUNIT_TEST(testFormulaRefUpdateMove);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndo2);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndoDependents);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveUndo4);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft2);
+ CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftUp);
+ CPPUNIT_TEST(testFormulaRefUpdateName);
+ CPPUNIT_TEST(testFormulaRefUpdateNameMove);
+ CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef);
+ CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef2);
+ CPPUNIT_TEST(testFormulaRefUpdateNameDeleteRow);
+ CPPUNIT_TEST(testFormulaRefUpdateNameCopySheet);
+ CPPUNIT_TEST(testFormulaRefUpdateSheetLocalMove);
+ CPPUNIT_TEST(testFormulaRefUpdateNameDelete);
+ CPPUNIT_TEST(testFormulaRefUpdateValidity);
+ CPPUNIT_TEST(testTokenArrayRefUpdateMove);
+ CPPUNIT_TEST(testSingleCellCopyColumnLabel);
+ CPPUNIT_TEST(testIntersectionOpExcel);
+ CPPUNIT_TEST(testTdf97369);
+ CPPUNIT_TEST(testTdf97587);
+ CPPUNIT_TEST(testTdf93415);
+ CPPUNIT_TEST(testTdf100818);
+ CPPUNIT_TEST(testMatConcat);
+ CPPUNIT_TEST(testMatConcatReplication);
+ CPPUNIT_TEST(testExternalRef);
+ CPPUNIT_TEST(testFormulaDepTracking);
+ CPPUNIT_TEST(testFormulaDepTracking2);
+ CPPUNIT_TEST(testFormulaDepTracking3);
+ CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
+ CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
+ CPPUNIT_TEST(testFormulaMatrixResultUpdate);
+ CPPUNIT_TEST(testExternalRefFunctions);
+ CPPUNIT_TEST(testExternalRangeName);
+ CPPUNIT_TEST(testExternalRefUnresolved);
+ CPPUNIT_TEST(testRefR1C1WholeCol);
+ CPPUNIT_TEST(testRefR1C1WholeRow);
+ CPPUNIT_TEST(testIterations);
+ CPPUNIT_TEST(testInsertColCellStoreEventSwap);
+ CPPUNIT_TEST(testFormulaAfterDeleteRows);
+ CPPUNIT_TEST(testMultipleOperations);
+ CPPUNIT_TEST(testFuncCOLUMN);
+ CPPUNIT_TEST(testFuncCOUNT);
+ CPPUNIT_TEST(testFuncCOUNTBLANK);
+ CPPUNIT_TEST(testFuncROW);
+ CPPUNIT_TEST(testFuncSUM);
+ CPPUNIT_TEST(testFuncPRODUCT);
+ CPPUNIT_TEST(testFuncSUMPRODUCT);
+ CPPUNIT_TEST(testFuncSUMXMY2);
+ CPPUNIT_TEST(testFuncMIN);
+ CPPUNIT_TEST(testFuncN);
+ CPPUNIT_TEST(testFuncCOUNTIF);
+ CPPUNIT_TEST(testFuncNUMBERVALUE);
+ CPPUNIT_TEST(testFuncLEN);
+ CPPUNIT_TEST(testFuncLOOKUP);
+ CPPUNIT_TEST(testFuncLOOKUParrayWithError);
+ CPPUNIT_TEST(testTdf141146);
+ CPPUNIT_TEST(testFuncVLOOKUP);
+ CPPUNIT_TEST(testFuncMATCH);
+ CPPUNIT_TEST(testFuncCELL);
+ CPPUNIT_TEST(testFuncDATEDIF);
+ CPPUNIT_TEST(testFuncINDIRECT);
+ CPPUNIT_TEST(testFuncINDIRECT2);
+ CPPUNIT_TEST(testFunc_MATCH_INDIRECT);
+ CPPUNIT_TEST(testFuncIF);
+ CPPUNIT_TEST(testFuncCHOOSE);
+ CPPUNIT_TEST(testFuncIFERROR);
+ CPPUNIT_TEST(testFuncSHEET);
+ CPPUNIT_TEST(testFuncNOW);
+ CPPUNIT_TEST(testMatrixOp);
+ CPPUNIT_TEST(testFuncRangeOp);
+ CPPUNIT_TEST(testFuncFORMULA);
+ CPPUNIT_TEST(testFuncTableRef);
+ CPPUNIT_TEST(testFuncFTEST);
+ CPPUNIT_TEST(testFuncFTESTBug);
+ CPPUNIT_TEST(testFuncCHITEST);
+ CPPUNIT_TEST(testFuncTTEST);
+ CPPUNIT_TEST(testFuncSUMX2PY2);
+ CPPUNIT_TEST(testFuncSUMX2MY2);
+ CPPUNIT_TEST(testFuncGCD);
+ CPPUNIT_TEST(testFuncLCM);
+ CPPUNIT_TEST(testFuncSUMSQ);
+ CPPUNIT_TEST(testFuncMDETERM);
+ CPPUNIT_TEST(testFormulaErrorPropagation);
+ CPPUNIT_TEST(testFuncRowsHidden);
+ CPPUNIT_TEST(testFuncSUMIFS);
+ CPPUNIT_TEST(testFuncRefListArraySUBTOTAL);
+ CPPUNIT_TEST(testFuncJumpMatrixArrayIF);
+ CPPUNIT_TEST(testFuncJumpMatrixArrayOFFSET);
+
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ ScDocShellRef m_xDocShell;
+ ScDocument* m_pDoc;
+};
+
+TestFormula::TestFormula()
+{
+}
+
+void TestFormula::setUp()
+{
+ BootstrapFixture::setUp();
+
+ ScDLL::Init();
+
+ m_xDocShell = new ScDocShell(
+ SfxModelFlags::EMBEDDED_OBJECT |
+ SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
+ SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
+ m_xDocShell->SetIsInUcalc();
+ m_xDocShell->DoInitUnitTest();
+
+ m_pDoc = &m_xDocShell->GetDocument();
}
-void Test::testFormulaCreateStringFromTokens()
+void TestFormula::tearDown()
+{
+ m_xDocShell->DoClose();
+ m_xDocShell.clear();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void TestFormula::testFormulaCreateStringFromTokens()
{
// Insert sheets.
m_pDoc->InsertTab(0, "Test");
@@ -248,7 +632,7 @@ bool equals( const formula::VectorRefArray& rArray, size_t nPos, const OUString&
}
-void Test::testFormulaParseReference()
+void TestFormula::testFormulaParseReference()
{
OUString aTab1("90's Music"), aTab2("90's and 70's"), aTab3("All Others"), aTab4("NoQuote");
m_pDoc->InsertTab(0, "Dummy"); // just to shift the sheet indices...
@@ -478,7 +862,7 @@ void Test::testFormulaParseReference()
m_pDoc->DeleteTab(0);
}
-void Test::testFetchVectorRefArray()
+void TestFormula::testFetchVectorRefArray()
{
m_pDoc->InsertTab(0, "Test");
@@ -774,7 +1158,7 @@ void Test::testFetchVectorRefArray()
m_pDoc->DeleteTab(0);
}
-void Test::testGroupConverter3D()
+void TestFormula::testGroupConverter3D()
{
m_pDoc->InsertTab(0, "Test");
m_pDoc->InsertTab(1, "Test2");
@@ -795,100 +1179,7 @@ void Test::testGroupConverter3D()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaHashAndTag()
-{
- m_pDoc->InsertTab(0, "Test");
-
- ScAddress aPos1(0,0,0), aPos2(1,0,0);
-
- // Test formula hashing.
-
- static const struct {
- const char* pFormula1; const char* pFormula2; bool bEqual;
- } aHashTests[] = {
- { "=1", "=2", false }, // different constants
- { "=SUM(1;2;3;4;5)", "=AVERAGE(1;2;3;4;5)", false }, // different functions
- { "=C2*3", "=D2*3", true }, // relative references
- { "=C2*3", "=D2*4", false }, // different constants
- { "=C2*4", "=D2*4", true }, // relative references
- { "=3*4*5", "=3*4*\"foo\"", false }, // numeric vs string constants
- { "=$C3/2", "=$C3/2", true }, // absolute column references
- { "=C$3/2", "=D$3/2", true }, // absolute row references
- { "=$E$30/2", "=$E$30/2", true }, // absolute references
- { "=X20", "=$X$20", false }, // absolute vs relative
- { "=X20", "=X$20", false }, // absolute vs relative
- { "=X20", "=$X20", false }, // absolute vs relative
- { "=X$20", "=$X20", false }, // column absolute vs row absolute
- // similar enough for merging ...
- { "=A1", "=B1", true },
- { "=$A$1", "=$B$1", true },
- { "=A1", "=C2", true },
- { "=SUM(A1)", "=SUM(B1)", true },
- { "=A1+3", "=B1+3", true },
- { "=A1+7", "=B1+42", false },
- };
-
- for (size_t i = 0; i < SAL_N_ELEMENTS(aHashTests); ++i)
- {
- m_pDoc->SetString(aPos1, OUString::createFromAscii(aHashTests[i].pFormula1));
- m_pDoc->SetString(aPos2, OUString::createFromAscii(aHashTests[i].pFormula2));
- size_t nHashVal1 = m_pDoc->GetFormulaHash(aPos1);
- size_t nHashVal2 = m_pDoc->GetFormulaHash(aPos2);
-
- std::ostringstream os;
- os << "(expr1:" << aHashTests[i].pFormula1 << "; expr2:" << aHashTests[i].pFormula2 << ")";
- if (aHashTests[i].bEqual)
- {
- os << " Error: these hashes should be equal." << endl;
- CPPUNIT_ASSERT_EQUAL_MESSAGE(os.str(), nHashVal1, nHashVal2);
- }
- else
- {
- os << " Error: these hashes should differ." << endl;
- CPPUNIT_ASSERT_MESSAGE(os.str(), nHashVal1 != nHashVal2);
- }
-
- aPos1.IncRow();
- aPos2.IncRow();
- }
-
- // Go back to row 1.
- aPos1.SetRow(0);
- aPos2.SetRow(0);
-
- // Test formula vectorization state.
-
- static const struct {
- const char* pFormula;
- ScFormulaVectorState eState;
- } aVectorTests[] = {
- { "=SUM(1;2;3;4;5)", FormulaVectorEnabled },
- { "=NOW()", FormulaVectorDisabled },
- { "=AVERAGE(X1:Y200)", FormulaVectorCheckReference },
- { "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference },
- { "=MIN(10;11;22)", FormulaVectorEnabled },
- { "=H4", FormulaVectorCheckReference },
- };
-
- for (size_t i = 0; i < SAL_N_ELEMENTS(aVectorTests); ++i)
- {
- m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula));
- ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1);
- ScFormulaVectorState eReferenceState = aVectorTests[i].eState;
-
- if (eState != eReferenceState)
- {
- std::ostringstream os;
- os << "Unexpected vectorization state: expr: '" << aVectorTests[i].pFormula << "'";
- CPPUNIT_ASSERT_MESSAGE(os.str(), false);
- }
- aPos1.IncRow();
- }
-
- m_pDoc->DeleteTab(0);
-}
-
-void Test::testFormulaTokenEquality()
+void TestFormula::testFormulaTokenEquality()
{
struct FormulaTokenEqualityTest
{
@@ -943,7 +1234,7 @@ void Test::testFormulaTokenEquality()
}
}
-void Test::testFormulaRefData()
+void TestFormula::testFormulaRefData()
{
std::unique_ptr<ScDocument> pDoc = std::make_unique<ScDocument>();
@@ -986,7 +1277,7 @@ void Test::testFormulaRefData()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end position of extended range.", ScAddress(8,6,0), aTest.aEnd);
}
-void Test::testFormulaCompiler()
+void TestFormula::testFormulaCompiler()
{
static const struct {
const char* pInput; FormulaGrammar::Grammar eInputGram;
@@ -1008,7 +1299,7 @@ void Test::testFormulaCompiler()
}
}
-void Test::testFormulaCompilerJumpReordering()
+void TestFormula::testFormulaCompilerJumpReordering()
{
struct TokenCheck
{
@@ -1075,7 +1366,7 @@ void Test::testFormulaCompilerJumpReordering()
}
}
-void Test::testFormulaCompilerImplicitIntersection2Param()
+void TestFormula::testFormulaCompilerImplicitIntersection2Param()
{
struct TestCaseFormula
{
@@ -1201,7 +1492,7 @@ void Test::testFormulaCompilerImplicitIntersection2Param()
}
}
-void Test::testFormulaCompilerImplicitIntersection1ParamNoChange()
+void TestFormula::testFormulaCompilerImplicitIntersection1ParamNoChange()
{
struct TestCaseFormulaNoChange
{
@@ -1298,7 +1589,7 @@ void Test::testFormulaCompilerImplicitIntersection1ParamNoChange()
}
}
-void Test::testFormulaCompilerImplicitIntersection1ParamWithChange()
+void TestFormula::testFormulaCompilerImplicitIntersection1ParamWithChange()
{
struct TestCaseFormula
{
@@ -1379,7 +1670,7 @@ void Test::testFormulaCompilerImplicitIntersection1ParamWithChange()
}
}
-void Test::testFormulaCompilerImplicitIntersection1NoGroup()
+void TestFormula::testFormulaCompilerImplicitIntersection1NoGroup()
{
m_pDoc->InsertTab(0, "Formula");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -1396,7 +1687,7 @@ void Test::testFormulaCompilerImplicitIntersection1NoGroup()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaCompilerImplicitIntersectionOperators()
+void TestFormula::testFormulaCompilerImplicitIntersectionOperators()
{
struct TestCase
{
@@ -1432,7 +1723,7 @@ void Test::testFormulaCompilerImplicitIntersectionOperators()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaAnnotateTrimOnDoubleRefs()
+void TestFormula::testFormulaAnnotateTrimOnDoubleRefs()
{
m_pDoc->InsertTab(0, "Test");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -1541,7 +1832,7 @@ void Test::testFormulaAnnotateTrimOnDoubleRefs()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdate()
+void TestFormula::testFormulaRefUpdate()
{
m_pDoc->InsertTab(0, "Formula");
@@ -1748,7 +2039,7 @@ void Test::testFormulaRefUpdate()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateRange()
+void TestFormula::testFormulaRefUpdateRange()
{
m_pDoc->InsertTab(0, "Formula");
@@ -2182,7 +2473,7 @@ void Test::testFormulaRefUpdateRange()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateSheets()
+void TestFormula::testFormulaRefUpdateSheets()
{
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
@@ -2326,7 +2617,7 @@ void Test::testFormulaRefUpdateSheets()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateInsertRows()
+void TestFormula::testFormulaRefUpdateInsertRows()
{
setExpandRefs(false);
@@ -2381,7 +2672,7 @@ void Test::testFormulaRefUpdateInsertRows()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateSheetsDelete()
+void TestFormula::testFormulaRefUpdateSheetsDelete()
{
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
@@ -2457,7 +2748,7 @@ void Test::testFormulaRefUpdateSheetsDelete()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateInsertColumns()
+void TestFormula::testFormulaRefUpdateInsertColumns()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
setExpandRefs(false);
@@ -2547,7 +2838,7 @@ void Test::testFormulaRefUpdateInsertColumns()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMove()
+void TestFormula::testFormulaRefUpdateMove()
{
m_pDoc->InsertTab(0, "Sheet1");
@@ -2620,7 +2911,7 @@ void Test::testFormulaRefUpdateMove()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndo()
+void TestFormula::testFormulaRefUpdateMoveUndo()
{
m_pDoc->InsertTab(0, "Test");
@@ -2718,7 +3009,7 @@ void Test::testFormulaRefUpdateMoveUndo()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndo2()
+void TestFormula::testFormulaRefUpdateMoveUndo2()
{
m_pDoc->InsertTab(0, "Test");
@@ -2782,7 +3073,7 @@ void Test::testFormulaRefUpdateMoveUndo2()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndo3NonShared()
+void TestFormula::testFormulaRefUpdateMoveUndo3NonShared()
{
m_pDoc->InsertTab(0, "Test");
@@ -2836,7 +3127,7 @@ void Test::testFormulaRefUpdateMoveUndo3NonShared()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndo3Shared()
+void TestFormula::testFormulaRefUpdateMoveUndo3Shared()
{
m_pDoc->InsertTab(0, "Test");
@@ -2908,7 +3199,7 @@ void Test::testFormulaRefUpdateMoveUndo3Shared()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndoDependents()
+void TestFormula::testFormulaRefUpdateMoveUndoDependents()
{
m_pDoc->InsertTab(0, "Test");
@@ -2973,7 +3264,7 @@ void Test::testFormulaRefUpdateMoveUndoDependents()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveUndo4()
+void TestFormula::testFormulaRefUpdateMoveUndo4()
{
m_pDoc->InsertTab(0, "Test");
@@ -3038,7 +3329,7 @@ void Test::testFormulaRefUpdateMoveUndo4()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateMoveToSheet()
+void TestFormula::testFormulaRefUpdateMoveToSheet()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3082,7 +3373,7 @@ void Test::testFormulaRefUpdateMoveToSheet()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateDeleteContent()
+void TestFormula::testFormulaRefUpdateDeleteContent()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3120,7 +3411,7 @@ void Test::testFormulaRefUpdateDeleteContent()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateDeleteAndShiftLeft()
+void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3223,7 +3514,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateDeleteAndShiftLeft2()
+void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft2()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3294,7 +3585,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftLeft2()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateDeleteAndShiftUp()
+void TestFormula::testFormulaRefUpdateDeleteAndShiftUp()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3397,7 +3688,7 @@ void Test::testFormulaRefUpdateDeleteAndShiftUp()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateName()
+void TestFormula::testFormulaRefUpdateName()
{
m_pDoc->InsertTab(0, "Formula");
@@ -3529,7 +3820,7 @@ void Test::testFormulaRefUpdateName()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameMove()
+void TestFormula::testFormulaRefUpdateNameMove()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -3631,7 +3922,7 @@ void Test::testFormulaRefUpdateNameMove()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameExpandRef()
+void TestFormula::testFormulaRefUpdateNameExpandRef()
{
setExpandRefs(true);
@@ -3753,7 +4044,7 @@ void Test::testFormulaRefUpdateNameExpandRef()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameExpandRef2()
+void TestFormula::testFormulaRefUpdateNameExpandRef2()
{
setExpandRefs(true);
@@ -3780,7 +4071,7 @@ void Test::testFormulaRefUpdateNameExpandRef2()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameDeleteRow()
+void TestFormula::testFormulaRefUpdateNameDeleteRow()
{
m_pDoc->InsertTab(0, "Test");
@@ -3904,7 +4195,7 @@ void Test::testFormulaRefUpdateNameDeleteRow()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameCopySheet()
+void TestFormula::testFormulaRefUpdateNameCopySheet()
{
m_pDoc->InsertTab(0, "Test");
m_pDoc->InsertTab(1, "Test2");
@@ -4049,69 +4340,25 @@ void Test::testFormulaRefUpdateNameCopySheet()
aPos.IncRow();
m_pDoc->SetString(aPos, "=local_local");
- testFormulaRefUpdateNameCopySheetCheckTab( 0, false);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 0, false);
// Copy sheet after.
m_pDoc->CopyTab(0, 1);
- testFormulaRefUpdateNameCopySheetCheckTab( 0, false);
- testFormulaRefUpdateNameCopySheetCheckTab( 1, true);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 0, false);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 1, true);
// Copy sheet before, shifting following now two sheets.
m_pDoc->CopyTab(1, 0);
- testFormulaRefUpdateNameCopySheetCheckTab( 0, true);
- testFormulaRefUpdateNameCopySheetCheckTab( 1, false);
- testFormulaRefUpdateNameCopySheetCheckTab( 2, true);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 0, true);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 1, false);
+ testFormulaRefUpdateNameCopySheetCheckTab( m_pDoc, 2, true);
m_pDoc->DeleteTab(2);
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameCopySheetCheckTab( SCTAB nTab, bool bCheckNames )
-{
- if (bCheckNames)
- {
- const ScRangeData* pName;
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("LOCAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_GLOBAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_GLOBAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_LOCAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_LOCAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_UNUSED");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_UNUSED should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("GLOBAL_UNUSED_NOREF");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name GLOBAL_UNUSED_NOREF should not exist", !pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_GLOBAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_GLOBAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_LOCAL");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_LOCAL should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_UNUSED");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_UNUSED should exist", pName);
- pName = m_pDoc->GetRangeName(nTab)->findByUpperName("LOCAL_UNUSED_NOREF");
- CPPUNIT_ASSERT_MESSAGE("Sheet-local name LOCAL_UNUSED_NOREF should exist", pName);
- }
-
- ScAddress aPos(0,0,0);
- aPos.SetRow(0);
- aPos.SetTab(nTab);
- int nSheet = nTab + 1;
- CPPUNIT_ASSERT_EQUAL( 1.0 * nSheet, m_pDoc->GetValue(aPos));
- aPos.IncRow();
- CPPUNIT_ASSERT_EQUAL( 11.0 * nSheet, m_pDoc->GetValue(aPos));
- aPos.IncRow();
- CPPUNIT_ASSERT_EQUAL( 100.0 * nSheet, m_pDoc->GetValue(aPos));
- aPos.IncRow();
- CPPUNIT_ASSERT_EQUAL( 11000.0 * nSheet, m_pDoc->GetValue(aPos));
- aPos.IncRow();
- CPPUNIT_ASSERT_EQUAL( 10000.0 * nSheet, m_pDoc->GetValue(aPos));
- aPos.IncRow();
- CPPUNIT_ASSERT_EQUAL( 1100000.0 * nSheet, m_pDoc->GetValue(aPos));
-}
-
-void Test::testFormulaRefUpdateSheetLocalMove()
+void TestFormula::testFormulaRefUpdateSheetLocalMove()
{
SCTAB nSheet1 = 0;
SCTAB nSheet2 = 1;
@@ -4271,7 +4518,7 @@ void Test::testFormulaRefUpdateSheetLocalMove()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateNameDelete()
+void TestFormula::testFormulaRefUpdateNameDelete()
{
m_pDoc->InsertTab(0, "Test");
@@ -4291,7 +4538,7 @@ void Test::testFormulaRefUpdateNameDelete()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaRefUpdateValidity()
+void TestFormula::testFormulaRefUpdateValidity()
{
struct {
@@ -4414,7 +4661,7 @@ void Test::testFormulaRefUpdateValidity()
m_pDoc->DeleteTab(0);
}
-void Test::testTokenArrayRefUpdateMove()
+void TestFormula::testTokenArrayRefUpdateMove()
{
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
@@ -4460,7 +4707,7 @@ void Test::testTokenArrayRefUpdateMove()
m_pDoc->DeleteTab(0);
}
-void Test::testMultipleOperations()
+void TestFormula::testMultipleOperations()
{
m_pDoc->InsertTab(0, "MultiOp");
@@ -4511,7 +4758,7 @@ void Test::testMultipleOperations()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCOLUMN()
+void TestFormula::testFuncCOLUMN()
{
m_pDoc->InsertTab(0, "Formula");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -4540,7 +4787,7 @@ void Test::testFuncCOLUMN()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCOUNT()
+void TestFormula::testFuncCOUNT()
{
m_pDoc->InsertTab(0, "Formula");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -4580,7 +4827,7 @@ void Test::testFuncCOUNT()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCOUNTBLANK()
+void TestFormula::testFuncCOUNTBLANK()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Formula");
@@ -4627,7 +4874,7 @@ void Test::testFuncCOUNTBLANK()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncROW()
+void TestFormula::testFuncROW()
{
m_pDoc->InsertTab(0, "Formula");
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -4685,7 +4932,7 @@ void Test::testFuncROW()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUM()
+void TestFormula::testFuncSUM()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -4748,7 +4995,7 @@ void Test::testFuncSUM()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncPRODUCT()
+void TestFormula::testFuncPRODUCT()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
@@ -4801,7 +5048,7 @@ void Test::testFuncPRODUCT()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUMPRODUCT()
+void TestFormula::testFuncSUMPRODUCT()
{
m_pDoc->InsertTab(0, "Test");
@@ -4839,7 +5086,7 @@ void Test::testFuncSUMPRODUCT()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUMXMY2()
+void TestFormula::testFuncSUMXMY2()
{
m_pDoc->InsertTab(0, "Test SumXMY2");
@@ -4869,7 +5116,7 @@ void Test::testFuncSUMXMY2()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncMIN()
+void TestFormula::testFuncMIN()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
m_pDoc->InsertTab(0, "Formula");
@@ -4919,7 +5166,7 @@ void Test::testFuncMIN()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncN()
+void TestFormula::testFuncN()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -4998,7 +5245,7 @@ void Test::testFuncN()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCOUNTIF()
+void TestFormula::testFuncCOUNTIF()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -5118,7 +5365,7 @@ void Test::testFuncCOUNTIF()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncIF()
+void TestFormula::testFuncIF()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -5167,7 +5414,7 @@ void Test::testFuncIF()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCHOOSE()
+void TestFormula::testFuncCHOOSE()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -5189,7 +5436,7 @@ void Test::testFuncCHOOSE()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncIFERROR()
+void TestFormula::testFuncIFERROR()
{
// IFERROR/IFNA (fdo#56124)
@@ -5302,7 +5549,7 @@ void Test::testFuncIFERROR()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSHEET()
+void TestFormula::testFuncSHEET()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (SC_TAB_APPEND, "test1"));
@@ -5333,7 +5580,7 @@ void Test::testFuncSHEET()
m_pDoc->DeleteTab(--nTabCount);
}
-void Test::testFuncNOW()
+void TestFormula::testFuncNOW()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -5362,7 +5609,7 @@ void Test::testFuncNOW()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncNUMBERVALUE()
+void TestFormula::testFuncNUMBERVALUE()
{
// NUMBERVALUE fdo#57180
@@ -5421,7 +5668,7 @@ void Test::testFuncNUMBERVALUE()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncLEN()
+void TestFormula::testFuncLEN()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -5454,7 +5701,7 @@ void Test::testFuncLEN()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncLOOKUP()
+void TestFormula::testFuncLOOKUP()
{
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
@@ -5503,7 +5750,7 @@ void Test::testFuncLOOKUP()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncLOOKUParrayWithError()
+void TestFormula::testFuncLOOKUParrayWithError()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
m_pDoc->InsertTab(0, "Test");
@@ -5532,7 +5779,7 @@ void Test::testFuncLOOKUParrayWithError()
m_pDoc->DeleteTab(0);
}
-void Test::testTdf141146()
+void TestFormula::testTdf141146()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
m_pDoc->InsertTab(0, "Test1");
@@ -5562,7 +5809,7 @@ void Test::testTdf141146()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncVLOOKUP()
+void TestFormula::testFuncVLOOKUP()
{
// VLOOKUP
@@ -5802,7 +6049,7 @@ static void runTestHorizontalMATCH(ScDocument* pDoc, const char* aData[DataSize]
}
}
-void Test::testFuncMATCH()
+void TestFormula::testFuncMATCH()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -5937,7 +6184,7 @@ void Test::testFuncMATCH()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCELL()
+void TestFormula::testFuncCELL()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -5980,7 +6227,7 @@ void Test::testFuncCELL()
}
/** See also test case document fdo#44456 sheet cpearson */
-void Test::testFuncDATEDIF()
+void TestFormula::testFuncDATEDIF()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -6020,7 +6267,7 @@ void Test::testFuncDATEDIF()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncINDIRECT()
+void TestFormula::testFuncINDIRECT()
{
OUString aTabName("foo");
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
@@ -6114,7 +6361,7 @@ void Test::testFuncINDIRECT()
// Test case for tdf#83365 - Access across spreadsheet returns Err:504
//
-void Test::testFuncINDIRECT2()
+void TestFormula::testFuncINDIRECT2()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
m_pDoc->InsertTab (0, "foo"));
@@ -6182,7 +6429,7 @@ void Test::testFuncINDIRECT2()
// Test for tdf#107724 do not propagate an array context from MATCH to INDIRECT
// as INDIRECT returns ParamClass::Reference
-void Test::testFunc_MATCH_INDIRECT()
+void TestFormula::testFunc_MATCH_INDIRECT()
{
CPPUNIT_ASSERT_MESSAGE("failed to insert sheet", m_pDoc->InsertTab( 0, "foo"));
@@ -6206,7 +6453,7 @@ void Test::testFunc_MATCH_INDIRECT()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaDepTracking()
+void TestFormula::testFormulaDepTracking()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
@@ -6314,7 +6561,7 @@ void Test::testFormulaDepTracking()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaDepTracking2()
+void TestFormula::testFormulaDepTracking2()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
@@ -6338,7 +6585,7 @@ void Test::testFormulaDepTracking2()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaDepTracking3()
+void TestFormula::testFormulaDepTracking3()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
@@ -6367,7 +6614,7 @@ void Test::testFormulaDepTracking3()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaDepTrackingDeleteRow()
+void TestFormula::testFormulaDepTrackingDeleteRow()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
@@ -6420,7 +6667,7 @@ void Test::testFormulaDepTrackingDeleteRow()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaDepTrackingDeleteCol()
+void TestFormula::testFormulaDepTrackingDeleteCol()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
@@ -6534,7 +6781,7 @@ void Test::testFormulaDepTrackingDeleteCol()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaMatrixResultUpdate()
+void TestFormula::testFormulaMatrixResultUpdate()
{
m_pDoc->InsertTab(0, "Test");
@@ -6562,7 +6809,7 @@ void Test::testFormulaMatrixResultUpdate()
m_pDoc->DeleteTab(0);
}
-void Test::testExternalRef()
+void TestFormula::testExternalRef()
{
ScDocShellRef xExtDocSh = new ScDocShell;
xExtDocSh->SetIsInUcalc();
@@ -6737,7 +6984,7 @@ void Test::testExternalRef()
m_pDoc->DeleteTab(0);
}
-void Test::testExternalRangeName()
+void TestFormula::testExternalRangeName()
{
ScDocShellRef xExtDocSh = new ScDocShell;
xExtDocSh->SetIsInUcalc();
@@ -6849,7 +7096,7 @@ static void testExtRefConcat(ScDocument* pDoc, ScDocument& rExtDoc)
CPPUNIT_ASSERT_EQUAL(OUString("Answer: 42"), pDoc->GetString(ScAddress(0,0,0)));
}
-void Test::testExternalRefFunctions()
+void TestFormula::testExternalRefFunctions()
{
ScDocShellRef xExtDocSh = new ScDocShell;
xExtDocSh->SetIsInUcalc();
@@ -6945,8 +7192,9 @@ void Test::testExternalRefFunctions()
m_pDoc->DeleteTab(0);
}
-void Test::testExternalRefUnresolved()
+void TestFormula::testExternalRefUnresolved()
{
+#if !defined(_WIN32) //FIXME
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
m_pDoc->InsertTab(0, "Test");
@@ -7023,9 +7271,10 @@ void Test::testExternalRefUnresolved()
CPPUNIT_ASSERT_MESSAGE("Unresolved reference check failed", bSuccess);
m_pDoc->DeleteTab(0);
+#endif
}
-void Test::testMatrixOp()
+void TestFormula::testMatrixOp()
{
m_pDoc->InsertTab(0, "Test");
@@ -7062,7 +7311,7 @@ void Test::testMatrixOp()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncRangeOp()
+void TestFormula::testFuncRangeOp()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
@@ -7146,7 +7395,7 @@ void Test::testFuncRangeOp()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncFORMULA()
+void TestFormula::testFuncFORMULA()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
@@ -7187,7 +7436,7 @@ void Test::testFuncFORMULA()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncTableRef()
+void TestFormula::testFuncTableRef()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
@@ -7533,7 +7782,7 @@ void Test::testFuncTableRef()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncFTEST()
+void TestFormula::testFuncFTEST()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -7686,7 +7935,7 @@ void Test::testFuncFTEST()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncFTESTBug()
+void TestFormula::testFuncFTESTBug()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -7706,7 +7955,7 @@ void Test::testFuncFTESTBug()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncCHITEST()
+void TestFormula::testFuncCHITEST()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -7828,7 +8077,7 @@ void Test::testFuncCHITEST()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncTTEST()
+void TestFormula::testFuncTTEST()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -7933,7 +8182,7 @@ void Test::testFuncTTEST()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUMX2PY2()
+void TestFormula::testFuncSUMX2PY2()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -7999,7 +8248,7 @@ void Test::testFuncSUMX2PY2()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUMX2MY2()
+void TestFormula::testFuncSUMX2MY2()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8075,7 +8324,7 @@ void Test::testFuncSUMX2MY2()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncGCD()
+void TestFormula::testFuncGCD()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8173,7 +8422,7 @@ void Test::testFuncGCD()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncLCM()
+void TestFormula::testFuncLCM()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8269,7 +8518,7 @@ void Test::testFuncLCM()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncSUMSQ()
+void TestFormula::testFuncSUMSQ()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8344,7 +8593,7 @@ void Test::testFuncSUMSQ()
m_pDoc->DeleteTab(0);
}
-void Test::testFuncMDETERM()
+void TestFormula::testFuncMDETERM()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8399,7 +8648,7 @@ void Test::testFuncMDETERM()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaErrorPropagation()
+void TestFormula::testFormulaErrorPropagation()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
@@ -8474,66 +8723,7 @@ void Test::testFormulaErrorPropagation()
m_pDoc->DeleteTab(0);
}
-namespace {
-
-class ColumnTest
-{
- ScDocument * m_pDoc;
-
- const SCROW m_nTotalRows;
- const SCROW m_nStart1;
- const SCROW m_nEnd1;
- const SCROW m_nStart2;
- const SCROW m_nEnd2;
-
-public:
- ColumnTest( ScDocument * pDoc, SCROW nTotalRows,
- SCROW nStart1, SCROW nEnd1, SCROW nStart2, SCROW nEnd2 )
- : m_pDoc(pDoc), m_nTotalRows(nTotalRows)
- , m_nStart1(nStart1), m_nEnd1(nEnd1)
- , m_nStart2(nStart2), m_nEnd2(nEnd2)
- {}
-
- void operator() ( SCCOL nColumn, const OUString& rFormula,
- std::function<double(SCROW )> const & lExpected ) const
- {
- ScDocument aClipDoc(SCDOCMODE_CLIP);
- ScMarkData aMark(m_pDoc->GetSheetLimits());
-
- ScAddress aPos(nColumn, m_nStart1, 0);
- m_pDoc->SetString(aPos, rFormula);
- ASSERT_DOUBLES_EQUAL( lExpected(m_nStart1), m_pDoc->GetValue(aPos) );
-
- // Copy formula cell to clipboard.
- ScClipParam aClipParam(aPos, false);
- aMark.SetMarkArea(aPos);
- m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false);
-
- // Paste it to first range.
- InsertDeleteFlags nFlags = InsertDeleteFlags::CONTENTS;
- ScRange aDestRange(nColumn, m_nStart1, 0, nColumn, m_nEnd1, 0);
- aMark.SetMarkArea(aDestRange);
- m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
-
- // Paste it second range.
- aDestRange = ScRange(nColumn, m_nStart2, 0, nColumn, m_nEnd2, 0);
- aMark.SetMarkArea(aDestRange);
- m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, nullptr, &aClipDoc);
-
- // Check the formula results for passed column.
- for( SCROW i = 0; i < m_nTotalRows; ++i )
- {
- if( !((m_nStart1 <= i && i <= m_nEnd1) || (m_nStart2 <= i && i <= m_nEnd2)) )
- continue;
- double fExpected = lExpected(i);
- ASSERT_DOUBLES_EQUAL(fExpected, m_pDoc->GetValue(ScAddress(nColumn,i,0)));
- }
- }
-};
-
-}
-
-void Test::testTdf97369()
+void TestFormula::testTdf97369()
{
const SCROW TOTAL_ROWS = 330;
const SCROW ROW_RANGE = 10;
@@ -8593,7 +8783,7 @@ void Test::testTdf97369()
m_pDoc->DeleteTab(0);
}
-void Test::testTdf97587()
+void TestFormula::testTdf97587()
{
const SCROW TOTAL_ROWS = 150;
const SCROW ROW_RANGE = 10;
@@ -8645,7 +8835,7 @@ void Test::testTdf97587()
m_pDoc->DeleteTab(0);
}
-void Test::testTdf93415()
+void TestFormula::testTdf93415()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Sheet1"));
@@ -8665,7 +8855,7 @@ void Test::testTdf93415()
m_pDoc->DeleteTab(0);
}
-void Test::testTdf100818()
+void TestFormula::testTdf100818()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Sheet1"));
@@ -8691,7 +8881,7 @@ void Test::testTdf100818()
m_pDoc->DeleteTab(0);
}
-void Test::testMatConcat()
+void TestFormula::testMatConcat()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
@@ -8752,7 +8942,7 @@ void Test::testMatConcat()
m_pDoc->DeleteTab(0);
}
-void Test::testMatConcatReplication()
+void TestFormula::testMatConcatReplication()
{
// if one of the matrices is a one column or row matrix
// the matrix is replicated across the larger matrix
@@ -8782,7 +8972,7 @@ void Test::testMatConcatReplication()
m_pDoc->DeleteTab(0);
}
-void Test::testRefR1C1WholeCol()
+void TestFormula::testRefR1C1WholeCol()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
@@ -8797,7 +8987,7 @@ void Test::testRefR1C1WholeCol()
m_pDoc->DeleteTab(0);
}
-void Test::testRefR1C1WholeRow()
+void TestFormula::testRefR1C1WholeRow()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
@@ -8812,7 +9002,7 @@ void Test::testRefR1C1WholeRow()
m_pDoc->DeleteTab(0);
}
-void Test::testSingleCellCopyColumnLabel()
+void TestFormula::testSingleCellCopyColumnLabel()
{
ScDocOptions aOptions = m_pDoc->GetDocOptions();
aOptions.SetLookUpColRowNames(true);
@@ -8838,7 +9028,7 @@ void Test::testSingleCellCopyColumnLabel()
}
// Significant whitespace operator intersection in Excel syntax, tdf#96426
-void Test::testIntersectionOpExcel()
+void TestFormula::testIntersectionOpExcel()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
@@ -8872,7 +9062,7 @@ void Test::testIntersectionOpExcel()
}
//Test Subtotal and Aggregate during hide rows #tdf93171
-void Test::testFuncRowsHidden()
+void TestFormula::testFuncRowsHidden()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -8916,7 +9106,7 @@ void Test::testFuncRowsHidden()
}
// Test COUNTIFS, SUMIFS, AVERAGEIFS in array context.
-void Test::testFuncSUMIFS()
+void TestFormula::testFuncSUMIFS()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9086,7 +9276,7 @@ void Test::testFuncSUMIFS()
}
// Test SUBTOTAL with reference lists in array context.
-void Test::testFuncRefListArraySUBTOTAL()
+void TestFormula::testFuncRefListArraySUBTOTAL()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9206,7 +9396,7 @@ void Test::testFuncRefListArraySUBTOTAL()
// tdf#115493 jump commands return the matrix result instead of the reference
// list array.
-void Test::testFuncJumpMatrixArrayIF()
+void TestFormula::testFuncJumpMatrixArrayIF()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9236,7 +9426,7 @@ void Test::testFuncJumpMatrixArrayIF()
// tdf#123477 OFFSET() returns the matrix result instead of the reference list
// array if result is not used as ReferenceOrRefArray.
-void Test::testFuncJumpMatrixArrayOFFSET()
+void TestFormula::testFuncJumpMatrixArrayOFFSET()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9262,7 +9452,7 @@ void Test::testFuncJumpMatrixArrayOFFSET()
}
// Test iterations with circular chain of references.
-void Test::testIterations()
+void TestFormula::testIterations()
{
ScDocOptions aDocOpts = m_pDoc->GetDocOptions();
aDocOpts.SetIter( true );
@@ -9297,7 +9487,7 @@ void Test::testIterations()
// tdf#111428 CellStoreEvent and its counter used for quick "has a column
// formula cells" must point to the correct column.
-void Test::testInsertColCellStoreEventSwap()
+void TestFormula::testInsertColCellStoreEventSwap()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9323,7 +9513,7 @@ void Test::testInsertColCellStoreEventSwap()
m_pDoc->DeleteTab(0);
}
-void Test::testFormulaAfterDeleteRows()
+void TestFormula::testFormulaAfterDeleteRows()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Test");
@@ -9343,4 +9533,8 @@ void Test::testFormulaAfterDeleteRows()
ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong value at A4", 3.0, m_pDoc->GetValue(aPos));
}
+CPPUNIT_TEST_SUITE_REGISTRATION(TestFormula);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */