diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-12-01 15:54:22 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-12-01 17:55:22 +0100 |
commit | a0a9a5f0927fbc2f9ce5984ae65584c4ad7b0c68 (patch) | |
tree | f8e76cbf6666ff1791e83fb08746ed5dce898241 | |
parent | e0285cd5e179037ebc0e7e33b65ae0386a6a68da (diff) |
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 ffcf83434119..be88c53916f2 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); } |