diff options
author | August Sodora <augsod@gmail.com> | 2011-11-26 13:55:52 -0500 |
---|---|---|
committer | August Sodora <augsod@gmail.com> | 2011-11-26 13:55:52 -0500 |
commit | 091ba739bad456938d462d808f5a76927d884ed9 (patch) | |
tree | 20ae59b7a508685c76e62d5768474f78c9fce50a /svl/qa | |
parent | e81f36f6b62c6686f0156aef151ad8bf6d1b7917 (diff) |
Added test for linguistic::RemoveHyphen and some simplification
Diffstat (limited to 'svl/qa')
-rw-r--r-- | svl/qa/unit/test_lngmisc.cxx | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/svl/qa/unit/test_lngmisc.cxx b/svl/qa/unit/test_lngmisc.cxx new file mode 100644 index 000000000000..47f671a9dfe6 --- /dev/null +++ b/svl/qa/unit/test_lngmisc.cxx @@ -0,0 +1,83 @@ +#include "sal/config.h" +#include "sal/precppunit.hxx" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" + +#include "svl/lngmisc.hxx" + +#include <rtl/ustrbuf.hxx> + +namespace +{ + class LngMiscTest : public CppUnit::TestFixture + { + private: + void testRemoveHyphens(); + // void testRemoveControlChars(); + // void testReplaceControlChars(); + // void testGetThesaurusReplaceText(); + + CPPUNIT_TEST_SUITE(LngMiscTest); + + CPPUNIT_TEST(testRemoveHyphens); + // CPPUNIT_TEST(testRemoveControlChars); + // CPPUNIT_TEST(testReplaceControlChars); + // CPPUNIT_TEST(testGetThesaurusReplaceText); + + CPPUNIT_TEST_SUITE_END(); + }; + + void LngMiscTest::testRemoveHyphens() + { + ::rtl::OUString str1(RTL_CONSTASCII_USTRINGPARAM("")); + ::rtl::OUString str2(RTL_CONSTASCII_USTRINGPARAM("a-b--c---")); + + ::rtl::OUStringBuffer str3Buf; + str3Buf.append(SVT_SOFT_HYPHEN); + str3Buf.append(SVT_HARD_HYPHEN); + str3Buf.append(SVT_HARD_HYPHEN); + ::rtl::OUString str3(str3Buf.makeStringAndClear()); + + ::rtl::OUString str4(RTL_CONSTASCII_USTRINGPARAM("asdf")); + + bool bModified = linguistic::RemoveHyphens(str1); + CPPUNIT_ASSERT(!bModified); + CPPUNIT_ASSERT(str1.isEmpty()); + + // Note that '-' isn't a hyphen to RemoveHyphens. + bModified = linguistic::RemoveHyphens(str2); + CPPUNIT_ASSERT(!bModified); + CPPUNIT_ASSERT(str2.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("a-b--c---"))); + + bModified = linguistic::RemoveHyphens(str3); + CPPUNIT_ASSERT(bModified); + CPPUNIT_ASSERT(str3.isEmpty()); + + bModified = linguistic::RemoveHyphens(str4); + CPPUNIT_ASSERT(!bModified); + CPPUNIT_ASSERT(str4.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("asdf"))); + } + + /* + void LngMiscTest::testRemoveControlChars() + { + CPPUNIT_ASSERT(true); + } + + void LngMiscTest::testReplaceControlChars() + { + CPPUNIT_ASSERT(true); + } + + void LngMiscTest::testGetThesaurusReplaceText() + { + CPPUNIT_ASSERT(true); + } + */ + + CPPUNIT_TEST_SUITE_REGISTRATION(LngMiscTest); +} +CPPUNIT_PLUGIN_IMPLEMENT(); |