summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-03-26 12:01:54 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-03-26 17:30:49 +0100
commitbcfad35ee4033e50c351671e9229f9d16c107e67 (patch)
treea3de48e856d4218463a4b660ff224dfa47af7417 /sc
parentc46d3b5204077e5faae75f15711ec7c88f60f28d (diff)
tdf#116216: sc_ucalc: Add unittest
Change-Id: I07237a491e3018b1d54794ac8456ea0fce3ae07d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113153 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx30
2 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d5000f042c1e..17422ea8e804 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -206,6 +206,7 @@ public:
void testFuncLEN();
void testFuncLOOKUP();
void testFuncLOOKUParrayWithError();
+ void testTdf116216();
void testFuncVLOOKUP();
void testFuncMATCH();
void testFuncCELL();
@@ -654,6 +655,7 @@ public:
CPPUNIT_TEST(testFuncLEN);
CPPUNIT_TEST(testFuncLOOKUP);
CPPUNIT_TEST(testFuncLOOKUParrayWithError);
+ CPPUNIT_TEST(testTdf116216);
CPPUNIT_TEST(testFuncVLOOKUP);
CPPUNIT_TEST(testFuncMATCH);
CPPUNIT_TEST(testFuncCELL);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 6ff96cfd4b89..3d1a9a3677d8 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -5538,6 +5538,36 @@ void Test::testFuncLOOKUParrayWithError()
m_pDoc->DeleteTab(0);
}
+void Test::testTdf116216()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
+ m_pDoc->InsertTab(0, "Test1");
+ m_pDoc->InsertTab(1, "Test2");
+
+ std::vector<std::vector<const char*>> aData = {
+ { "k1", "value1"},
+ { "k2", "value2"},
+ { "k3", "value3"}
+ };
+
+ insertRangeData(m_pDoc, ScAddress(0,1,1), aData); // A2:B4
+ m_pDoc->SetString(4,0,1, "k2"); // E1
+
+ m_pDoc->SetString(4,1,1, "=LOOKUP(1;1/(A$2:A$4=E$1);1)");
+ m_pDoc->SetString(4,2,1, "=LOOKUP(E1;A$2:A$4;B2:B4)");
+ m_pDoc->SetString(4,3,1, "=LOOKUP(1;1/(A$2:A$4=E$1);B2:B4)");
+
+ // Without the fix in place, this test would haved failed with
+ // - Expected: #N/A
+ // - Actual :
+ CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), m_pDoc->GetString(4,1,1));
+ CPPUNIT_ASSERT_EQUAL(OUString("value2"), m_pDoc->GetString(4,2,1));
+ CPPUNIT_ASSERT_EQUAL(OUString("value2"), m_pDoc->GetString(4,3,1));
+
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncVLOOKUP()
{
// VLOOKUP