Skip to content

Commit f1872f6

Browse files
author
Xisco Fauli
committed
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 <[email protected]>
1 parent 6fc2135 commit f1872f6

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

sc/CppunitTest_sc_goal_seek_test.mk

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2+
#*************************************************************************
3+
#
4+
# This file is part of the LibreOffice project.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
#
10+
#*************************************************************************
11+
12+
$(eval $(call gb_CppunitTest_CppunitTest,sc_goal_seek_test))
13+
14+
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_goal_seek_test))
15+
16+
$(eval $(call gb_CppunitTest_add_exception_objects,sc_goal_seek_test, \
17+
sc/qa/unit/GoalSeekTest \
18+
))
19+
20+
$(eval $(call gb_CppunitTest_use_externals,sc_goal_seek_test, \
21+
boost_headers \
22+
mdds_headers \
23+
libxml2 \
24+
))
25+
26+
$(eval $(call gb_CppunitTest_use_libraries,sc_goal_seek_test, \
27+
basegfx \
28+
comphelper \
29+
cppu \
30+
cppuhelper \
31+
docmodel \
32+
sal \
33+
salhelper \
34+
sax \
35+
sc \
36+
scqahelper \
37+
sfx \
38+
subsequenttest \
39+
test \
40+
tl \
41+
unotest \
42+
utl \
43+
vcl \
44+
))
45+
46+
$(eval $(call gb_CppunitTest_use_externals,sc_goal_seek_test,\
47+
boost_headers \
48+
))
49+
50+
$(eval $(call gb_CppunitTest_set_include,sc_goal_seek_test,\
51+
-I$(SRCDIR)/sc/source/ui/inc \
52+
-I$(SRCDIR)/sc/inc \
53+
$$(INCLUDE) \
54+
))
55+
56+
$(eval $(call gb_CppunitTest_use_api,sc_goal_seek_test,\
57+
offapi \
58+
udkapi \
59+
))
60+
61+
$(eval $(call gb_CppunitTest_use_sdk_api,sc_goal_seek_test))
62+
63+
$(eval $(call gb_CppunitTest_use_ure,sc_goal_seek_test))
64+
$(eval $(call gb_CppunitTest_use_vcl,sc_goal_seek_test))
65+
66+
$(eval $(call gb_CppunitTest_use_rdb,sc_goal_seek_test,services))
67+
68+
$(eval $(call gb_CppunitTest_use_components,sc_goal_seek_test))
69+
70+
$(eval $(call gb_CppunitTest_use_configuration,sc_goal_seek_test))
71+
72+
$(eval $(call gb_CppunitTest_add_arguments,sc_goal_seek_test, \
73+
-env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
74+
))
75+
76+
# vim: set noet sw=4 ts=4:

sc/Module_sc.mk

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
8181
CppunitTest_sc_cond_format_merge \
8282
CppunitTest_sc_copypaste \
8383
CppunitTest_sc_html_export_test \
84+
CppunitTest_sc_goal_seek_test \
8485
CppunitTest_sc_macros_test \
8586
CppunitTest_sc_new_cond_format_api \
8687
CppunitTest_sc_pdf_export \

sc/qa/unit/GoalSeekTest.cxx

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
/*
3+
* This file is part of the LibreOffice project.
4+
*
5+
* This Source Code Form is subject to the terms of the Mozilla Public
6+
* License, v. 2.0. If a copy of the MPL was not distributed with this
7+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
8+
*/
9+
10+
#include <sal/config.h>
11+
12+
#include "helper/qahelper.hxx"
13+
#include <comphelper/servicehelper.hxx>
14+
15+
using namespace ::com::sun::star;
16+
17+
class ScGoalSeekTest : public ScModelTestBase
18+
{
19+
public:
20+
ScGoalSeekTest();
21+
};
22+
23+
ScGoalSeekTest::ScGoalSeekTest()
24+
: ScModelTestBase(u"/sc/qa/unit/data/"_ustr)
25+
{
26+
}
27+
28+
CPPUNIT_TEST_FIXTURE(ScGoalSeekTest, testTdf161511)
29+
{
30+
createScDoc();
31+
32+
table::CellAddress aVariableCell;
33+
aVariableCell.Sheet = 0;
34+
aVariableCell.Row = 0;
35+
aVariableCell.Column = 3;
36+
table::CellAddress aFormulaCell;
37+
aFormulaCell.Sheet = 0;
38+
aFormulaCell.Row = 0;
39+
aFormulaCell.Column = 4;
40+
41+
ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
42+
CPPUNIT_ASSERT(pModelObj);
43+
44+
// Without the fix in place, this test would have crashed
45+
sheet::GoalResult res = pModelObj->seekGoal(aFormulaCell, aVariableCell, "100");
46+
CPPUNIT_ASSERT_EQUAL(0.0, res.Result);
47+
}
48+
49+
CPPUNIT_PLUGIN_IMPLEMENT();
50+
51+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

0 commit comments

Comments
 (0)