diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-12-01 15:54:22 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-12-01 16:51:23 +0100 |
commit | 098e9dc376346ad13c63fdef292ab640d89c6a21 (patch) | |
tree | 6a01742f31d9075315925cd90d1ad7eb4171636c | |
parent | sc unit tests: Prefix the format names. (diff) | |
download | core-098e9dc376346ad13c63fdef292ab640d89c6a21.tar.gz core-098e9dc376346ad13c63fdef292ab640d89c6a21.zip |
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
-rw-r--r-- | sc/CppunitTest_sc_ucalc.mk | 4 | ||||
-rw-r--r-- | 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 <docpool.hxx> #include <formula/vectortoken.hxx> +#include <officecfg/Office/Common.hxx> #include <svl/broadcast.hxx> #include <memory> @@ -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); } |