sc/qa/unit/GoalSeekTest.cxx |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit 7e123665eb8afb9b46422e28ade5bb512fafe12c
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Jun 14 16:07:51 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Jun 14 23:56:04 2024 +0200

    tdf#68034: sc_goal_seek: Add unittest
    
    Change-Id: I675d59cd7e22c09ea1c673e016d71f8d3ed404a5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168890
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sc/qa/unit/GoalSeekTest.cxx b/sc/qa/unit/GoalSeekTest.cxx
index ea0920ba8760..aab6d0ef2dba 100644
--- a/sc/qa/unit/GoalSeekTest.cxx
+++ b/sc/qa/unit/GoalSeekTest.cxx
@@ -46,6 +46,31 @@ CPPUNIT_TEST_FIXTURE(ScGoalSeekTest, testTdf161511)
     CPPUNIT_ASSERT_EQUAL(0.0, res.Result);
 }
 
+CPPUNIT_TEST_FIXTURE(ScGoalSeekTest, testTdf68034)
+{
+    createScDoc();
+
+    insertStringToCell(u"A1"_ustr, u"=SQRT(B1)");
+
+    table::CellAddress aVariableCell;
+    aVariableCell.Sheet = 0;
+    aVariableCell.Row = 0;
+    aVariableCell.Column = 1;
+    table::CellAddress aFormulaCell;
+    aFormulaCell.Sheet = 0;
+    aFormulaCell.Row = 0;
+    aFormulaCell.Column = 0;
+
+    ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+    CPPUNIT_ASSERT(pModelObj);
+
+    sheet::GoalResult res = pModelObj->seekGoal(aFormulaCell, aVariableCell, 
"2");
+    // Without the fix in place, this test would have failed with
+    // - Expected: 4
+    // - Actual  : 0
+    CPPUNIT_ASSERT_EQUAL(4.0, res.Result);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to