Kaydet (Commit) 091ba739 authored tarafından August Sodora's avatar August Sodora

Added test for linguistic::RemoveHyphen and some simplification

üst e81f36f6
$(eval $(call gb_CppunitTest_CppunitTest,svl_lngmisc))
$(eval $(call gb_CppunitTest_add_exception_objects,svl_lngmisc, \
svl/qa/unit/test_lngmisc \
))
# add a list of all needed libraries here
$(eval $(call gb_CppunitTest_add_linked_libs,svl_lngmisc, \
comphelper \
cppu \
cppuhelper \
sal \
salhelper \
sb \
sot \
svl \
svt \
tl \
utl \
vcl \
xcr \
$(gb_STDLIBS) \
))
ifeq ($(GUI),WNT)
$(eval $(call gb_CppunitTest_add_linked_libs,svl_lngmisc, \
oleaut32 \
))
endif
$(eval $(call gb_CppunitTest_set_include,svl_lngmisc,\
-I$(realpath $(SRCDIR)/svl/source/inc) \
-I$(realpath $(SRCDIR)/svl/inc) \
$$(INCLUDE) \
-I$(OUTDIR)/inc \
))
\ No newline at end of file
......@@ -36,6 +36,10 @@ $(eval $(call gb_Module_add_targets,svl,\
Package_inc \
))
$(eval $(call gb_Module_add_check_targets,svl,\
CppunitTest_svl_lngmisc \
))
$(eval $(call gb_Module_add_subsequentcheck_targets,svl,\
JunitTest_svl_complex \
))
......
......@@ -31,6 +31,8 @@
#include "svl/svldllapi.h"
#include <rtl/ustring.hxx>
class String;
///////////////////////////////////////////////////////////////////////////
......
#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();
......@@ -58,14 +58,10 @@ sal_Int32 GetNumControlChars( const OUString &rTxt )
sal_Bool RemoveHyphens( OUString &rTxt )
{
sal_Bool bModified = sal_False;
if (HasHyphens(rTxt))
{
rTxt = comphelper::string::remove(rTxt, SVT_SOFT_HYPHEN);
rTxt = comphelper::string::remove(rTxt, SVT_HARD_HYPHEN);
bModified = sal_True;
}
return bModified;
sal_Int32 n = rTxt.getLength();
rTxt = comphelper::string::remove(rTxt, SVT_SOFT_HYPHEN);
rTxt = comphelper::string::remove(rTxt, SVT_HARD_HYPHEN);
return n != rTxt.getLength();
}
sal_Bool RemoveControlChars( OUString &rTxt )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment