summaryrefslogtreecommitdiff
path: root/sal/qa
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-03-28 08:12:16 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-03-28 09:07:17 +0200
commit3ba10632a34a4740e77da76d7aa5bda8a2eb99ab (patch)
tree3f5e5abd3b96ef75d22023accaa65d25effddf27 /sal/qa
parent533eadeb46c3db40daf0f18f89096c24e7f9c2bd (diff)
string literal overloads for rest of OString methods
Diffstat (limited to 'sal/qa')
-rw-r--r--sal/qa/rtl/strings/test_ostring_stringliterals.cxx60
1 files changed, 57 insertions, 3 deletions
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index d665ee2e0f84..0ada7097221b 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -139,10 +139,30 @@ void test::ostring::StringLiterals::checkUsage()
// simply check that all string literal based calls work as expected
// also check that they really use string literal overload and do not convert to OString
rtl::OString foo( "foo" );
+ rtl::OString FoO( "FoO" );
+ rtl::OString foobarfoo( "foobarfoo" );
+ rtl::OString foobar( "foobar" );
+ rtl::OString FooBaRfoo( "FooBaRfoo" );
+ rtl::OString FooBaR( "FooBaR" );
+ rtl::OString bar( "bar" );
+ rtl::OString test( "test" );
rtl_string_unittest_const_literal = false; // start checking for OString conversions
rtl_string_unittest_non_const_literal_function = false; // and check for non-const variants
CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = "foo" );
+ CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( "fOo" ));
+ CPPUNIT_ASSERT( foobarfoo.match( "bar", 3 ));
+ CPPUNIT_ASSERT( foobar.match( "foo" ));
+ CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( "bAr", 3 ));
+ CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( "fOo" ));
+ CPPUNIT_ASSERT( foobar.endsWith( "bar" ));
+// CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( "bar" ));
+ CPPUNIT_ASSERT( foo == "foo" );
+ CPPUNIT_ASSERT( "foo" == foo );
+ CPPUNIT_ASSERT( foo != "bar" );
+ CPPUNIT_ASSERT( "foo" != bar );
+ CPPUNIT_ASSERT( foobarfoo.indexOf( "foo", 1 ) == 6 );
+// CPPUNIT_ASSERT( foobarfoo.lastIndexOf( "foo" ) == 6 );
// if this is not true, some of the calls above converted to OString
CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
// if this is not true, some of the calls above used non-const variants
@@ -153,14 +173,48 @@ void test::ostring::StringLiterals::checkNonConstUsage()
{
// check that (non-const) char[] overloads work and do not use const char[] overloads
rtl::OString foo( "foo" );
+ rtl::OString FoO( "FoO" );
+ rtl::OString foobarfoo( "foobarfoo" );
+ rtl::OString foobar( "foobar" );
+ rtl::OString FooBaRfoo( "FooBaRfoo" );
+ rtl::OString FooBaR( "FooBaR" );
+ rtl::OString bar( "bar" );
+ rtl::OString test( "test" );
char foo_c[] = "foo";
+ char bar_c[] = "bar";
+ char fOo_c[] = "fOo";
+ char bAr_c[] = "bAr";
rtl_string_unittest_const_literal = false; // start checking for OString conversions
rtl_string_unittest_const_literal_function = false; // and check for const variants
- CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = (const char*)"foo" );
+ CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = (const char*)foo_c );
CPPUNIT_ASSERT_EQUAL( foo, rtl::OString() = foo_c );
- // if this is not true, some of the calls above converted to OString
- CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false );
+ CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( (const char*)fOo_c ));
+ CPPUNIT_ASSERT( FoO.equalsIgnoreAsciiCase( fOo_c ));
+ CPPUNIT_ASSERT( foobarfoo.match( (const char*)bar_c, 3 ));
+ CPPUNIT_ASSERT( foobarfoo.match( bar_c, 3 ));
+ CPPUNIT_ASSERT( foobar.match( (const char*)foo_c ));
+ CPPUNIT_ASSERT( foobar.match( foo_c ));
+ CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( (const char*)bAr_c, 3 ));
+ CPPUNIT_ASSERT( FooBaRfoo.matchIgnoreAsciiCase( bAr_c, 3 ));
+ CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( (const char*)fOo_c ));
+ CPPUNIT_ASSERT( FooBaR.matchIgnoreAsciiCase( fOo_c ));
+ CPPUNIT_ASSERT( foobar.endsWith( (const char*)bar_c ));
+ CPPUNIT_ASSERT( foobar.endsWith( bar_c ));
+// CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( (const char*)bar_c ));
+// CPPUNIT_ASSERT( FooBaR.endsWithIgnoreAsciiCase( bar_c ));
+ CPPUNIT_ASSERT( foo == (const char*)foo_c );
+ CPPUNIT_ASSERT( foo == foo_c );
+ CPPUNIT_ASSERT( (const char*)foo_c == foo );
+ CPPUNIT_ASSERT( foo_c == foo );
+ CPPUNIT_ASSERT( foo != (const char*)bar_c );
+ CPPUNIT_ASSERT( foo != bar_c );
+ CPPUNIT_ASSERT( (const char*)foo_c != bar );
+ CPPUNIT_ASSERT( foo_c != bar );
+ CPPUNIT_ASSERT( foobarfoo.indexOf( (const char*)foo_c, 1 ) == 6 );
+ CPPUNIT_ASSERT( foobarfoo.indexOf( foo_c, 1 ) == 6 );
+// CPPUNIT_ASSERT( foobarfoo.lastIndexOf( (const char*)foo_c ) == 6 );
+// CPPUNIT_ASSERT( foobarfoo.lastIndexOf( foo_c ) == 6 );
// if this is not true, some of the calls above used const variants
CPPUNIT_ASSERT( rtl_string_unittest_const_literal_function == false );
}