summaryrefslogtreecommitdiff
path: root/svl/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-02 11:29:42 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-04 19:15:22 -0400
commit4d076d4ceeb05061b6b0699c19af9ba5ed0fcd00 (patch)
tree1cca2e9da7b436a91addc3590d5a209e61129be7 /svl/qa
parent5d3ea0cde3f4c61832c48281e75dabd22621a893 (diff)
Write some rudimentary tests for the new shared string pool class.
Change-Id: Ie66de46d69f664839aa0a2d056cd3b8df4d4989b
Diffstat (limited to 'svl/qa')
-rw-r--r--svl/qa/unit/svl.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 8d46ecff46e8..f41ab737783d 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -33,6 +33,8 @@
#include "svl/zforlist.hxx"
#include "svl/zformat.hxx"
+#include "svl/stringpool.hxx"
+#include "unotools/syslocale.hxx"
#define DEBUG_UNIT_TEST 0
@@ -65,11 +67,13 @@ public:
virtual void tearDown();
void testNumberFormat();
+ void testStringPool();
void testFdo60915();
void testI116701();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testNumberFormat);
+ CPPUNIT_TEST(testStringPool);
CPPUNIT_TEST(testFdo60915);
CPPUNIT_TEST(testI116701);
CPPUNIT_TEST_SUITE_END();
@@ -288,6 +292,42 @@ void Test::testNumberFormat()
}
}
+void Test::testStringPool()
+{
+ SvtSysLocale aSysLocale;
+ svl::StringPool aPool(aSysLocale.GetCharClassPtr());
+
+ const rtl_uString* p1 = aPool.intern("Andy");
+ const rtl_uString* p2 = aPool.intern("Andy");
+ CPPUNIT_ASSERT_EQUAL(p1, p2);
+
+ p2 = aPool.intern("Bruce");
+ CPPUNIT_ASSERT_MESSAGE("They must differ.", p1 != p2);
+
+ OUString aAndy("Andy");
+ p2 = aPool.getIdentifier(aAndy);
+ CPPUNIT_ASSERT_EQUAL(p1, p2);
+
+ // Test case insensitive string ID's.
+ OUString aAndyLower("andy"), aAndyUpper("ANDY");
+ p1 = aPool.getIdentifier("Andy");
+ CPPUNIT_ASSERT_MESSAGE("This shouldn't be NULL.", p1);
+ p2 = aPool.intern(aAndyLower);
+ CPPUNIT_ASSERT_MESSAGE("They must differ.", p1 != p2);
+ p2 = aPool.intern(aAndyUpper);
+ CPPUNIT_ASSERT_MESSAGE("They must differ.", p1 != p2);
+
+ p1 = aPool.getIdentifierIgnoreCase("Andy");
+ CPPUNIT_ASSERT_MESSAGE("This shouldn't be NULL.", p1);
+ p2 = aPool.getIdentifierIgnoreCase("andy");
+ CPPUNIT_ASSERT_MESSAGE("This shouldn't be NULL.", p2);
+ CPPUNIT_ASSERT_EQUAL(p1, p2);
+
+ p2 = aPool.getIdentifierIgnoreCase("ANDY");
+ CPPUNIT_ASSERT_MESSAGE("This shouldn't be NULL.", p2);
+ CPPUNIT_ASSERT_EQUAL(p1, p2);
+}
+
void Test::checkPreviewString(SvNumberFormatter& aFormatter,
const OUString& sCode,
double fPreviewNumber,