summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-11-28 13:32:31 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-11-28 15:02:06 +0100
commit6676c4ebbd264448e1d7871c91c1b3ba72c0dda0 (patch)
tree3589454140bd251862697da604b7bf1311c80373 /sal
parent47dfe5b8fd4abf9b5cb3c52db4ea6f4af6ea6b9c (diff)
Fix rtl::OUString::compareToIgnoreAsciiCase
Change-Id: I40005ef4fad4d44314ec2fb2881fec82e926970e
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/ustring.hxx10
-rw-r--r--sal/qa/rtl/strings/test_oustring_compare.cxx15
2 files changed, 19 insertions, 6 deletions
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index aeb2b798bd67..4fc1360027f9 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -527,8 +527,8 @@ public:
/**
Perform a ASCII lowercase comparison of two strings.
- Compare teh two string with uppercase ASCII
- character values between 65 and 90 (ASCII A-Z) are interpreted as
+ Compare the two strings with uppercase ASCII
+ character values between 65 and 90 (ASCII A-Z) interpreted as
values between 97 and 122 (ASCII a-z).
This function can't be used for language specific comparison.
@@ -536,13 +536,11 @@ public:
@return 0 - if both strings are equal
< 0 - if this string is less than the string argument
> 0 - if this string is greater than the string argument
+
+ @since LibreOffice 4.0
*/
sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
{
- if ( pData->length != str.pData->length )
- return sal_False;
- if ( pData == str.pData )
- return sal_True;
return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
str.pData->buffer, str.pData->length );
}
diff --git a/sal/qa/rtl/strings/test_oustring_compare.cxx b/sal/qa/rtl/strings/test_oustring_compare.cxx
index c41c2238243e..8b506b78d728 100644
--- a/sal/qa/rtl/strings/test_oustring_compare.cxx
+++ b/sal/qa/rtl/strings/test_oustring_compare.cxx
@@ -32,9 +32,12 @@ private:
void compareToAscii();
+ void compareToIgnoreAsciiCase();
+
CPPUNIT_TEST_SUITE(Compare);
CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
CPPUNIT_TEST(compareToAscii);
+CPPUNIT_TEST(compareToIgnoreAsciiCase);
CPPUNIT_TEST_SUITE_END();
};
@@ -70,4 +73,16 @@ void test::oustring::Compare::compareToAscii()
sal_Int32(0), abc.compareToAscii(RTL_CONSTASCII_STRINGPARAM("a")));
}
+void test::oustring::Compare::compareToIgnoreAsciiCase()
+{
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(0),
+ rtl::OUString("abc").compareToIgnoreAsciiCase(rtl::OUString("ABC")));
+ CPPUNIT_ASSERT(
+ rtl::OUString("ABC").compareToIgnoreAsciiCase(rtl::OUString("abcdef"))
+ < 0);
+ CPPUNIT_ASSERT(
+ rtl::OUString("A").compareToIgnoreAsciiCase(rtl::OUString("_")) > 0);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */