summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-06-14 14:40:05 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-06-18 00:07:35 +0200
commitcee79f814756c0461e2793d5b01bb96e70b232af (patch)
treebf1b5c1d410b4b3542e4bf6591c8d8c5e425b4f8
parentd5b06b32bf86a2a8d3cb525f44ae62ed8312353f (diff)
tdf#161511: sc_goal_seek: Add unittest
Change-Id: Icc05195a4870d5bb4f8c5ffc9b3bcae89367a89d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168866 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169048
-rw-r--r--sc/CppunitTest_sc_goal_seek_test.mk76
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/unit/GoalSeekTest.cxx51
3 files changed, 128 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_goal_seek_test.mk b/sc/CppunitTest_sc_goal_seek_test.mk
new file mode 100644
index 000000000000..f4f91d9a9b1c
--- /dev/null
+++ b/sc/CppunitTest_sc_goal_seek_test.mk
@@ -0,0 +1,76 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_goal_seek_test, \
+ sc/qa/unit/GoalSeekTest \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_goal_seek_test, \
+ boost_headers \
+ mdds_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_goal_seek_test, \
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ docmodel \
+ sal \
+ salhelper \
+ sax \
+ sc \
+ scqahelper \
+ sfx \
+ subsequenttest \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_goal_seek_test,\
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_goal_seek_test,\
+ -I$(SRCDIR)/sc/source/ui/inc \
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_goal_seek_test,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_goal_seek_test))
+$(eval $(call gb_CppunitTest_use_vcl,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_use_rdb,sc_goal_seek_test,services))
+
+$(eval $(call gb_CppunitTest_use_components,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_goal_seek_test))
+
+$(eval $(call gb_CppunitTest_add_arguments,sc_goal_seek_test, \
+ -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 25b43c6b19df..ab9dada68aa7 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
CppunitTest_sc_cond_format_merge \
CppunitTest_sc_copypaste \
CppunitTest_sc_html_export_test \
+ CppunitTest_sc_goal_seek_test \
CppunitTest_sc_macros_test \
CppunitTest_sc_new_cond_format_api \
CppunitTest_sc_pdf_export \
diff --git a/sc/qa/unit/GoalSeekTest.cxx b/sc/qa/unit/GoalSeekTest.cxx
new file mode 100644
index 000000000000..ea0920ba8760
--- /dev/null
+++ b/sc/qa/unit/GoalSeekTest.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include "helper/qahelper.hxx"
+#include <comphelper/servicehelper.hxx>
+
+using namespace ::com::sun::star;
+
+class ScGoalSeekTest : public ScModelTestBase
+{
+public:
+ ScGoalSeekTest();
+};
+
+ScGoalSeekTest::ScGoalSeekTest()
+ : ScModelTestBase(u"/sc/qa/unit/data/"_ustr)
+{
+}
+
+CPPUNIT_TEST_FIXTURE(ScGoalSeekTest, testTdf161511)
+{
+ createScDoc();
+
+ table::CellAddress aVariableCell;
+ aVariableCell.Sheet = 0;
+ aVariableCell.Row = 0;
+ aVariableCell.Column = 3;
+ table::CellAddress aFormulaCell;
+ aFormulaCell.Sheet = 0;
+ aFormulaCell.Row = 0;
+ aFormulaCell.Column = 4;
+
+ ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+ CPPUNIT_ASSERT(pModelObj);
+
+ // Without the fix in place, this test would have crashed
+ sheet::GoalResult res = pModelObj->seekGoal(aFormulaCell, aVariableCell, "100");
+ CPPUNIT_ASSERT_EQUAL(0.0, res.Result);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */