summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorTobias Lippert <drtl@fastmail.fm>2015-02-22 13:59:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-03-03 10:08:35 +0000
commit4bdbea5447f36beb9cc33df173a89a49a9918290 (patch)
tree8d7549c3091ce29e09cf9e552891c947270147e5 /sw/qa
parente719183ce3974ebd8034421e654d0ef0e9b16593 (diff)
tdf#89520 Make TOX creation more robust
The code is now more robust and will accept illegal arguments. Change-Id: I43ae82b953cea845fb170aa7b6e8d42470ad4e5e Reviewed-on: https://gerrit.libreoffice.org/14580 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/core/test_ToxWhitespaceStripper.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sw/qa/core/test_ToxWhitespaceStripper.cxx b/sw/qa/core/test_ToxWhitespaceStripper.cxx
index 30da0bdb1a6b..53819333579e 100644
--- a/sw/qa/core/test_ToxWhitespaceStripper.cxx
+++ b/sw/qa/core/test_ToxWhitespaceStripper.cxx
@@ -32,10 +32,14 @@ class ToxWhitespaceStripperTest : public CppUnit::TestFixture
void
PositionAfterStringCanBeRequested();
+ void
+ InvalidPositionIsMappedToLastEntry();
+
CPPUNIT_TEST_SUITE(ToxWhitespaceStripperTest);
CPPUNIT_TEST(MappingCharactersToVariousStrippedStringsWorks);
CPPUNIT_TEST(StrippingWhitespacesFromVariousStringsWorks);
CPPUNIT_TEST(PositionAfterStringCanBeRequested);
+ CPPUNIT_TEST(InvalidPositionIsMappedToLastEntry);
CPPUNIT_TEST_SUITE_END();
@@ -141,6 +145,16 @@ ToxWhitespaceStripperTest::PositionAfterStringCanBeRequested()
CPPUNIT_ASSERT_EQUAL(expected, sut.GetPositionInStrippedString(test.getLength()));
}
+void
+ToxWhitespaceStripperTest::InvalidPositionIsMappedToLastEntry()
+{
+ OUString test("ab c");
+ ToxWhitespaceStripper sut(test);
+ sal_Int32 expected = 4; // the length of the string after merging the two whitespaces
+ sal_Int32 result = sut.GetPositionInStrippedString(40); // a value past the original string length
+ CPPUNIT_ASSERT_EQUAL(expected, result);
+}
+
// Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION(ToxWhitespaceStripperTest);