diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2022-08-23 22:25:28 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-08-25 13:05:39 +0200 |
commit | 83e53d664f3c4a476e6e855119b019a2ae691a7c (patch) | |
tree | 1afdaa0169d8f89eb1f8d8c6510ce7e14dbb6c19 /vcl/qa | |
parent | 9481156090d0b455c6b35eaadd363f47c24b8086 (diff) |
vcl: test removeMnemonicsFromString()
Change-Id: Id0a84fb5cb9fa2f6f286ffeab1e1baea641d677a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138728
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/mnemonic.cxx | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/mnemonic.cxx b/vcl/qa/cppunit/mnemonic.cxx index 5a2131da2e3b..fc95fc527068 100644 --- a/vcl/qa/cppunit/mnemonic.cxx +++ b/vcl/qa/cppunit/mnemonic.cxx @@ -24,9 +24,23 @@ public: } void testMnemonic(); + void testRemoveMnemonicFromString(); + void testRemoveDoubleMarkedMnemonicFromString(); + void testRemoveMultipleMnemonicsFromString(); + void testRemoveDoubleMarkingsThenMnemonicFromString(); + void testRemoveMnemonicThenDoubleMarkingsFromString(); + void testRemoveMnemonicFromEndOfString(); + void testRemoveNoMnemonicFromString(); CPPUNIT_TEST_SUITE(VclMnemonicTest); CPPUNIT_TEST(testMnemonic); + CPPUNIT_TEST(testRemoveMnemonicFromString); + CPPUNIT_TEST(testRemoveDoubleMarkedMnemonicFromString); + CPPUNIT_TEST(testRemoveMultipleMnemonicsFromString); + CPPUNIT_TEST(testRemoveDoubleMarkingsThenMnemonicFromString); + CPPUNIT_TEST(testRemoveMnemonicThenDoubleMarkingsFromString); + CPPUNIT_TEST(testRemoveMnemonicFromEndOfString); + CPPUNIT_TEST(testRemoveNoMnemonicFromString); CPPUNIT_TEST_SUITE_END(); }; @@ -54,6 +68,62 @@ void VclMnemonicTest::testMnemonic() } } +void VclMnemonicTest::testRemoveMnemonicFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("this is a ~test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this is a test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveDoubleMarkedMnemonicFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("this ~~is a test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this ~is a test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveMultipleMnemonicsFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("t~his is a ~test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this is a test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveDoubleMarkingsThenMnemonicFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("t~~his is a ~test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("t~his is a test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveMnemonicThenDoubleMarkingsFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("t~his is a ~~test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this is a ~test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveMnemonicFromEndOfString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("this is a test~", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this is a test~"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), nMnemonicIndex); +} + +void VclMnemonicTest::testRemoveNoMnemonicFromString() +{ + sal_Int32 nMnemonicIndex; + OUString sNonMnemonicString = removeMnemonicFromString("this is a test", nMnemonicIndex); + CPPUNIT_ASSERT_EQUAL(OUString("this is a test"), sNonMnemonicString); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), nMnemonicIndex); +} + CPPUNIT_TEST_SUITE_REGISTRATION(VclMnemonicTest); CPPUNIT_PLUGIN_IMPLEMENT(); |