From 098e9dc376346ad13c63fdef292ab640d89c6a21 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Tue, 1 Dec 2015 15:54:22 +0100 Subject: sc interpreter: Improve the unit test for S/W Interpreter. Some of the operations are blacklisted for vectorization there, so test both the normal and s/w interpreter case. Change-Id: I6d48831f6bdbbb1e150bea06fc97ea5d6e66365b --- sc/CppunitTest_sc_ucalc.mk | 4 ++++ sc/qa/unit/ucalc_formula.cxx | 47 ++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk index 7fd90f8bb953..07c74e50d148 100644 --- a/sc/CppunitTest_sc_ucalc.mk +++ b/sc/CppunitTest_sc_ucalc.mk @@ -90,6 +90,10 @@ $(eval $(call gb_CppunitTest_use_api,sc_ucalc,\ udkapi \ )) +$(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)) diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index e27973a28209..69b46bb85b22 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -789,30 +790,46 @@ void Test::testFormulaHashAndTag() // Test formula vectorization state. struct { - const char* pFormula; ScFormulaVectorState eState; + const char* pFormula; + ScFormulaVectorState eState; + ScFormulaVectorState eSwInterpreterState; // these can change when more is whitelisted } 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 }, + { "=SUM(1;2;3;4;5)", FormulaVectorEnabled, FormulaVectorEnabled }, + { "=NOW()", FormulaVectorDisabled, FormulaVectorDisabled }, + { "=AVERAGE(X1:Y200)", FormulaVectorCheckReference, FormulaVectorDisabled }, + { "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference, FormulaVectorDisabled }, + { "=MIN(10;11;22)", FormulaVectorEnabled, FormulaVectorDisabled }, + { "=H4", FormulaVectorCheckReference, FormulaVectorCheckReference }, }; - for (size_t i = 0; i < SAL_N_ELEMENTS(aVectorTests); ++i) + bool bSwInterpreter = officecfg::Office::Common::Misc::UseSwInterpreter::get(); + + for (bool bForceSwInterpreter : { false, true }) { - m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula)); - ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1); + std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::UseSwInterpreter::set(bForceSwInterpreter, xBatch); + xBatch->commit(); - if (eState != aVectorTests[i].eState) + for (size_t i = 0; i < SAL_N_ELEMENTS(aVectorTests); ++i) { - std::ostringstream os; - os << "Unexpected vectorization state: expr:" << aVectorTests[i].pFormula; - CPPUNIT_ASSERT_MESSAGE(os.str().c_str(), false); + m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula)); + ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1); + ScFormulaVectorState eReferenceState = bForceSwInterpreter? aVectorTests[i].eSwInterpreterState: aVectorTests[i].eState; + + if (eState != eReferenceState) + { + std::ostringstream os; + os << "Unexpected vectorization state: expr: '" << aVectorTests[i].pFormula << "', using software interpreter: " << bForceSwInterpreter; + CPPUNIT_ASSERT_MESSAGE(os.str().c_str(), false); + } + aPos1.IncRow(); } - aPos1.IncRow(); } + std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::UseSwInterpreter::set(bSwInterpreter, xBatch); + xBatch->commit(); + m_pDoc->DeleteTab(0); } -- cgit