diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-02 19:11:28 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-04 19:15:23 -0400 |
commit | 57bc9f7edf6ec33c7c81c856cf5a51ea41b67932 (patch) | |
tree | 4fe16ed65f59a0889f76686bf9277a7b7940a785 /svl/qa/unit | |
parent | 00d08001da8dceeb77f16dca523979aa8ccc3755 (diff) |
A little more test on shared string pool's life cycle management.
Change-Id: Ic676dd875c27ce60a0707903d7f22207764829e0
Diffstat (limited to 'svl/qa/unit')
-rw-r--r-- | svl/qa/unit/svl.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 90f4c44571ad..11a52e6f2a2f 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -36,6 +36,8 @@ #include "svl/stringpool.hxx" #include "unotools/syslocale.hxx" +#include <boost/scoped_ptr.hpp> + #define DEBUG_UNIT_TEST 1 #if DEBUG_UNIT_TEST @@ -353,6 +355,48 @@ void Test::testStringPoolPurge() aPool.purge(); CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 0); CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 0); + + // Now, create string objects on the heap. + boost::scoped_ptr<OUString> pStr1(new OUString("Andy")); + boost::scoped_ptr<OUString> pStr2(new OUString("andy")); + boost::scoped_ptr<OUString> pStr3(new OUString("ANDY")); + boost::scoped_ptr<OUString> pStr4(new OUString("Bruce")); + aPool.intern(*pStr1); + aPool.intern(*pStr2); + aPool.intern(*pStr3); + aPool.intern(*pStr4); + + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 4); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 2); + + // This shouldn't purge anything. + aPool.purge(); + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 4); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 2); + + // Delete one heap string object, and purge. That should purge one string. + pStr1.reset(); + aPool.purge(); + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 3); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 2); + + // Ditto... + pStr3.reset(); + aPool.purge(); + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 2); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 2); + + // Again. + pStr2.reset(); + aPool.purge(); + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 1); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 1); + + // Delete 'Bruce' and purge. + pStr4.reset(); + aPool.purge(); + CPPUNIT_ASSERT_MESSAGE("Wrong string count.", aPool.getCount() == 0); + CPPUNIT_ASSERT_MESSAGE("Wrong case insensitive string count.", aPool.getCountIgnoreCase() == 0); } void Test::checkPreviewString(SvNumberFormatter& aFormatter, |