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>
This commit is contained in:
Xisco Fauli 2024-06-14 14:40:05 +02:00
parent 6fc21353bb
commit f1872f6e47
3 changed files with 128 additions and 0 deletions

View file

@ -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:

View file

@ -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 \

View file

@ -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: */