summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-18 23:36:55 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-19 13:40:25 -0400
commitb13550ed57ec438a57f6482d9ea6d16f354eec14 (patch)
tree914b1e0bfc895c3d0db7775ddee373990c9fefb8 /sc/qa
parent307b9bfd17d34bcfc9a2ecdef7802413d79f3694 (diff)
Unit test for formula token array vectorization state.
Change-Id: I91dce36e56d86899ba506beb29df6188f10966c0
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index f255781f4a77..63b740b9b1a8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -67,6 +67,7 @@
#include "calcconfig.hxx"
#include "interpre.hxx"
#include "columniterator.hxx"
+#include "types.hxx"
#include "formula/IFunctionDescription.hxx"
@@ -1203,6 +1204,8 @@ void Test::testFormulaHashAndTag()
ScAddress aPos1(0,0,0), aPos2(1,0,0);
+ // Test formula hashing.
+
struct {
const char* pFormula1; const char* pFormula2; bool bEqual;
} aHashTests[] = {
@@ -1245,6 +1248,37 @@ void Test::testFormulaHashAndTag()
aPos2.IncRow();
}
+ // Go back to row 1.
+ aPos1.SetRow(0);
+ aPos2.SetRow(0);
+
+ // Test formula vectorization state.
+
+ 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);
+
+ if (eState != aVectorTests[i].eState)
+ {
+ std::ostringstream os;
+ os << "Unexpected vectorization state: expr:" << aVectorTests[i].pFormula;
+ CPPUNIT_ASSERT_MESSAGE(os.str().c_str(), false);
+ }
+ aPos1.IncRow();
+ }
+
m_pDoc->DeleteTab(0);
}