diff options
-rw-r--r-- | sc/CppunitTest_sc_range_test.mk | 120 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/unit/range.cxx | 110 |
3 files changed, 231 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_range_test.mk b/sc/CppunitTest_sc_range_test.mk new file mode 100644 index 000000000000..0fdbd3c08fb5 --- /dev/null +++ b/sc/CppunitTest_sc_range_test.mk @@ -0,0 +1,120 @@ +# -*- 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_range_test)) + +$(eval $(call gb_CppunitTest_use_externals,sc_range_test, \ + boost_headers \ + icu_headers \ + icui18n \ + icuuc \ + libxml2 \ + mdds_headers \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_range_test, \ + sc/qa/unit/range \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_range_test, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + scqahelper \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tk \ + tl \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_range_test,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_range_test,\ + offapi \ + oovbaapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_range_test)) +$(eval $(call gb_CppunitTest_use_vcl,sc_range_test)) + +$(eval $(call gb_CppunitTest_use_components,sc_range_test,\ + basic/util/sb \ + chart2/source/chartcore \ + chart2/source/controller/chartcontroller \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + embeddedobj/util/embobj \ + eventattacher/source/evtatt \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scaddins/source/analysis/analysis \ + scaddins/source/datefunc/date \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svl/util/svl \ + svx/util/svx \ + svx/util/svxcore \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + xmloff/util/xo \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_range_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 5493c09eb648..ce7e4c135a3c 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -47,6 +47,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\ CppunitTest_sc_bugfix_test \ CppunitTest_sc_filters_test \ CppunitTest_sc_rangelst_test \ + CppunitTest_sc_range_test \ CppunitTest_sc_mark_test \ CppunitTest_sc_core \ )) diff --git a/sc/qa/unit/range.cxx b/sc/qa/unit/range.cxx new file mode 100644 index 000000000000..c1e4214ff014 --- /dev/null +++ b/sc/qa/unit/range.cxx @@ -0,0 +1,110 @@ +/* -*- 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 <test/bootstrapfixture.hxx> +#include "helper/qahelper.hxx" +#include "document.hxx" +#include "docsh.hxx" + +#include "address.hxx" + +class ScAddressTest : public test::BootstrapFixture +{ +public: + + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScAddressTest); + CPPUNIT_TEST(testAddressParsing); + CPPUNIT_TEST_SUITE_END(); + + void testAddressParsing(); + +private: + ScDocument *m_pDoc; + ScDocShellRef m_xDocShRef; +}; + +void ScAddressTest::testAddressParsing() +{ + ScAddress aAddr; + ScRefFlags nRes = aAddr.Parse("1", m_pDoc, formula::FormulaGrammar::CONV_OOO); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); +} + +void ScAddressTest::setUp() +{ + BootstrapFixture::setUp(); + + ScDLL::Init(); + m_xDocShRef = new ScDocShell( + SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + + m_pDoc = &m_xDocShRef->GetDocument(); +} + +void ScAddressTest::tearDown() +{ + m_xDocShRef.Clear(); + BootstrapFixture::tearDown(); +} + +class ScRangeTest : public test::BootstrapFixture +{ +public: + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(ScRangeTest); + CPPUNIT_TEST(testRangeParsing); + CPPUNIT_TEST_SUITE_END(); + + void testRangeParsing(); + +private: + ScDocument *m_pDoc; + ScDocShellRef m_xDocShRef; +}; + +void ScRangeTest::testRangeParsing() +{ + ScRange aRange; + ScRefFlags nRes = aRange.Parse(":1", m_pDoc, formula::FormulaGrammar::CONV_OOO); + CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", !(nRes & ScRefFlags::VALID)); +} + +void ScRangeTest::setUp() +{ + BootstrapFixture::setUp(); + + ScDLL::Init(); + m_xDocShRef = new ScDocShell( + SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + + m_pDoc = &m_xDocShRef->GetDocument(); +} + +void ScRangeTest::tearDown() +{ + m_xDocShRef.Clear(); + BootstrapFixture::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScAddressTest); +CPPUNIT_TEST_SUITE_REGISTRATION(ScRangeTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |