diff options
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 13 | ||||
-rw-r--r-- | sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 5760914fcc3f..c9fe25ec6131 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -528,6 +528,19 @@ public: } /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 4.1 + */ + template< typename T > + typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const SAL_THROW(()) + { + assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); + return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length, + literal, internal::ConstCharArrayDetector< T, void >::size - 1 ); + } + + /** Perform a comparison of two strings. The result is true if and only if second string diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index a6d7145b9700..873b5366f6a5 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -145,6 +145,7 @@ void test::oustring::StringLiterals::checkUsage() CPPUNIT_ASSERT( foobarfoo.replaceFirst( "foo", "test" ) == "testbarfoo" ); CPPUNIT_ASSERT( foobarfoo.replaceAll( "foo", test ) == "testbartest" ); CPPUNIT_ASSERT( foobarfoo.replaceAll( "foo", "test" ) == "testbartest" ); + CPPUNIT_ASSERT( foo.reverseCompareTo( "foo" ) == 0 ); // if this is not true, some of the calls above converted to OUString CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false ); } |