summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-11 11:33:05 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-11 12:14:28 -0400
commit19ea624c6dc779333e84ca937e2f90a3f39871b1 (patch)
tree37fee97b24e52429683f7866bfdaaf9d49c29038 /svl
parent78cf106733680d2aedf85441cd359669f560b93a (diff)
Fix equality operator for SharedString & write test for it.
Change-Id: Ib592ca2fe359293da6c10aa9e1535a91627cfc43
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx24
-rw-r--r--svl/source/misc/sharedstring.cxx2
2 files changed, 19 insertions, 7 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 0ac019b0d47b..a34150f4a536 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -39,6 +39,7 @@
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
+using namespace svl;
namespace {
@@ -51,15 +52,17 @@ public:
virtual void tearDown();
void testNumberFormat();
- void testStringPool();
- void testStringPoolPurge();
+ void testSharedString();
+ void testSharedStringPool();
+ void testSharedStringPoolPurge();
void testFdo60915();
void testI116701();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testNumberFormat);
- CPPUNIT_TEST(testStringPool);
- CPPUNIT_TEST(testStringPoolPurge);
+ CPPUNIT_TEST(testSharedString);
+ CPPUNIT_TEST(testSharedStringPool);
+ CPPUNIT_TEST(testSharedStringPoolPurge);
CPPUNIT_TEST(testFdo60915);
CPPUNIT_TEST(testI116701);
CPPUNIT_TEST_SUITE_END();
@@ -278,7 +281,16 @@ void Test::testNumberFormat()
}
}
-void Test::testStringPool()
+void Test::testSharedString()
+{
+ // Use shared string as normal, non-shared string, which is allowed.
+ SharedString aSS1("Test"), aSS2("Test");
+ CPPUNIT_ASSERT_MESSAGE("Equality check should return true.", aSS1 == aSS2);
+ SharedString aSS3("test");
+ CPPUNIT_ASSERT_MESSAGE("Equality check is case sensitive.", aSS1 != aSS3);
+}
+
+void Test::testSharedStringPool()
{
SvtSysLocale aSysLocale;
svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
@@ -311,7 +323,7 @@ void Test::testStringPool()
CPPUNIT_ASSERT_MESSAGE("These two ID's should be equal.", p1.getDataIgnoreCase() == p2.getDataIgnoreCase());
}
-void Test::testStringPoolPurge()
+void Test::testSharedStringPoolPurge()
{
SvtSysLocale aSysLocale;
svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index 8389ff836c8f..6a5d3959ba8e 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -81,7 +81,7 @@ bool SharedString::operator== ( const SharedString& r ) const
if (mpData->length != r.mpData->length)
return false;
- return rtl_ustr_compare_WithLength(mpData->buffer, mpData->length, r.mpData->buffer, r.mpData->length);
+ return rtl_ustr_reverseCompare_WithLength(mpData->buffer, mpData->length, r.mpData->buffer, r.mpData->length) == 0;
}
return !r.mpData;