sw/inc/ToxLinkProcessor.hxx | 5 ++++- sw/qa/core/test_ToxLinkProcessor.cxx | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit 5d81c9f24fbe48a0717640c1ba6bcf882b9358e2 Author: Tobias Lippert <d...@fastmail.fm> Date: Thu Aug 6 20:30:28 2015 +0200 tdf#85872 ToxLinkProcessor correct header and tests commit 6b9ab853b6a5fa71c0b6c594ed0e6e6016d13a3b changed the behavior of the class, but the header comments were not updated. This commit adds comments for the new behavior. Also: The tested behavior in the unittest was changed. This commit adapts the unittest name to the new behavior. Change-Id: Ia364ebbc3e2bfe1b0b8e3e26269a3c162e1a05d1 Reviewed-on: https://gerrit.libreoffice.org/17510 Reviewed-by: Noel Grandin <noelgran...@gmail.com> Tested-by: Noel Grandin <noelgran...@gmail.com> diff --git a/sw/inc/ToxLinkProcessor.hxx b/sw/inc/ToxLinkProcessor.hxx index a8b06d0..3887121 100644 --- a/sw/inc/ToxLinkProcessor.hxx +++ b/sw/inc/ToxLinkProcessor.hxx @@ -34,7 +34,10 @@ public: /** Close a link which has been found during processing. * - * @throw std::runtime_error If there are no open links. + * @internal + * If you close more links than were opened, then the method will behave + * as if a start link was opened at position 0 with the character style + * STR_POOLCHR_TOXJUMP. */ void CloseLink(sal_Int32 endPosition, const OUString& url); diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx index e768c21..660d745 100644 --- a/sw/qa/core/test_ToxLinkProcessor.cxx +++ b/sw/qa/core/test_ToxLinkProcessor.cxx @@ -20,22 +20,27 @@ #include <cppunit/plugin/TestPlugIn.h> #include <test/bootstrapfixture.hxx> +#include <poolfmt.hrc> #include <swdll.hxx> +#include "swtypes.hxx" +#include "SwStyleNameMapper.hxx" using namespace sw; class ToxLinkProcessorTest : public test::BootstrapFixture { - void ExceptionIsThrownIfTooManyLinksAreClosed(); + void NoExceptionIsThrownIfTooManyLinksAreClosed(); void AddingAndClosingTwoLinksResultsInTwoClosedLinks(); void LinkIsCreatedCorrectly(); void LinkSequenceIsPreserved(); + void StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed(); CPPUNIT_TEST_SUITE(ToxLinkProcessorTest); - CPPUNIT_TEST(ExceptionIsThrownIfTooManyLinksAreClosed); + CPPUNIT_TEST(NoExceptionIsThrownIfTooManyLinksAreClosed); CPPUNIT_TEST(AddingAndClosingTwoLinksResultsInTwoClosedLinks); CPPUNIT_TEST(LinkIsCreatedCorrectly); CPPUNIT_TEST(LinkSequenceIsPreserved); + CPPUNIT_TEST(StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed); CPPUNIT_TEST_SUITE_END(); public: void setUp() SAL_OVERRIDE { @@ -59,7 +64,7 @@ const sal_uInt16 ToxLinkProcessorTest::POOL_ID_1 = 42; const sal_uInt16 ToxLinkProcessorTest::POOL_ID_2 = 43; void -ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed() +ToxLinkProcessorTest::NoExceptionIsThrownIfTooManyLinksAreClosed() { ToxLinkProcessor sut; sut.StartNewLink(0, STYLE_NAME_1); @@ -70,6 +75,17 @@ ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed() } void +ToxLinkProcessorTest::StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed() +{ + ToxLinkProcessor sut; + sut.StartNewLink(0, STYLE_NAME_1); + sut.CloseLink(1, URL_1); + sut.CloseLink(1, URL_1); + CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size())); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.mClosedLinks.at(1).mEndTextPos)); +} + +void ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks() { ToxLinkProcessor sut; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits