From c8c8e70be7ec0d47e13724105eccbf4b9ab5a7c6 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 10 May 2017 18:06:57 +0200 Subject: Add unit test for non-propagation of array context, tdf#107724 Change-Id: I59abfaba2866c25dac7db2b8bc5ce8c563a88240 --- sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_formula.cxx | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'sc/qa') diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index f02989466ab5..acb918642fe4 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -189,6 +189,7 @@ public: void testFuncDATEDIF(); void testFuncINDIRECT(); void testFuncINDIRECT2(); + void testFunc_MATCH_INDIRECT(); void testFuncIF(); void testFuncCHOOSE(); void testFuncIFERROR(); @@ -592,6 +593,7 @@ public: CPPUNIT_TEST(testFuncDATEDIF); CPPUNIT_TEST(testFuncINDIRECT); CPPUNIT_TEST(testFuncINDIRECT2); + CPPUNIT_TEST(testFunc_MATCH_INDIRECT); CPPUNIT_TEST(testFuncIF); CPPUNIT_TEST(testFuncCHOOSE); CPPUNIT_TEST(testFuncIFERROR); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 9603934f3b52..474fedbcacf5 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -5221,6 +5221,32 @@ void Test::testFuncINDIRECT2() m_pDoc->DeleteTab(0); } +// Test for tdf#107724 do not propagate an array context from MATCH to INDIRECT +// as INDIRECT returns ParamClass::Reference +void Test::testFunc_MATCH_INDIRECT() +{ + CPPUNIT_ASSERT_MESSAGE("failed to insert sheet", m_pDoc->InsertTab( 0, "foo")); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation. + + ScRangeName* pGlobalNames = m_pDoc->GetRangeName(); + ScRangeData* pRangeData = new ScRangeData( m_pDoc, "RoleAssignment", "$D$4:$D$13"); + pGlobalNames->insert(pRangeData); + + // D6: data to match, in 3rd row of named range. + m_pDoc->SetString( 3,5,0, "Test1"); + // F15: Formula generating indirect reference of corner addresses taking + // row+offset and column from named range, which are not in array context + // thus don't create arrays of offsets. + m_pDoc->SetString( 5,14,0, "=MATCH(\"Test1\";INDIRECT(ADDRESS(ROW(RoleAssignment)+1;COLUMN(RoleAssignment))&\":\"&ADDRESS(ROW(RoleAssignment)+ROWS(RoleAssignment)-1;COLUMN(RoleAssignment)));0)"); + + // Match in 2nd row of range offset by 1 expected. + ASSERT_DOUBLES_EQUAL_MESSAGE("Failed to not propagate array context from MATCH to INDIRECT", + 2.0, m_pDoc->GetValue(5,14,0)); + + m_pDoc->DeleteTab(0); +} + void Test::testFormulaDepTracking() { CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo")); -- cgit