Kaydet (Commit) 57bc9f7e authored tarafından Kohei Yoshida's avatar Kohei Yoshida

A little more test on shared string pool's life cycle management.

Change-Id: Ic676dd875c27ce60a0707903d7f22207764829e0
üst 00d08001
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment