Kaydet (Commit) a0a9a5f0 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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
üst e0285cd5
...@@ -90,6 +90,10 @@ $(eval $(call gb_CppunitTest_use_api,sc_ucalc,\ ...@@ -90,6 +90,10 @@ $(eval $(call gb_CppunitTest_use_api,sc_ucalc,\
udkapi \ 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_ure,sc_ucalc))
$(eval $(call gb_CppunitTest_use_vcl,sc_ucalc)) $(eval $(call gb_CppunitTest_use_vcl,sc_ucalc))
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <docpool.hxx> #include <docpool.hxx>
#include <formula/vectortoken.hxx> #include <formula/vectortoken.hxx>
#include <officecfg/Office/Common.hxx>
#include <svl/broadcast.hxx> #include <svl/broadcast.hxx>
#include <memory> #include <memory>
...@@ -789,30 +790,46 @@ void Test::testFormulaHashAndTag() ...@@ -789,30 +790,46 @@ void Test::testFormulaHashAndTag()
// Test formula vectorization state. // Test formula vectorization state.
struct { struct {
const char* pFormula; ScFormulaVectorState eState; const char* pFormula;
ScFormulaVectorState eState;
ScFormulaVectorState eSwInterpreterState; // these can change when more is whitelisted
} aVectorTests[] = { } aVectorTests[] = {
{ "=SUM(1;2;3;4;5)", FormulaVectorEnabled }, { "=SUM(1;2;3;4;5)", FormulaVectorEnabled, FormulaVectorEnabled },
{ "=NOW()", FormulaVectorDisabled }, { "=NOW()", FormulaVectorDisabled, FormulaVectorDisabled },
{ "=AVERAGE(X1:Y200)", FormulaVectorCheckReference }, { "=AVERAGE(X1:Y200)", FormulaVectorCheckReference, FormulaVectorDisabled },
{ "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference }, { "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference, FormulaVectorDisabled },
{ "=MIN(10;11;22)", FormulaVectorEnabled }, { "=MIN(10;11;22)", FormulaVectorEnabled, FormulaVectorDisabled },
{ "=H4", FormulaVectorCheckReference }, { "=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)); std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1); 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; m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula));
os << "Unexpected vectorization state: expr:" << aVectorTests[i].pFormula; ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1);
CPPUNIT_ASSERT_MESSAGE(os.str().c_str(), false); 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); m_pDoc->DeleteTab(0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment