From 73b1097f5309dfec2d73cc47566643fff1cd8e06 Mon Sep 17 00:00:00 2001 From: Syn Wee Quek Date: Thu, 21 Nov 2002 21:43:03 +0000 Subject: [PATCH] ICU-2118 code coverage updates X-SVN-Rev: 10321 --- icu4c/source/test/intltest/apicoll.cpp | 37 +++++++++++++++++++++++++ icu4c/source/test/intltest/apicoll.h | 5 ++++ icu4c/source/test/intltest/srchtest.cpp | 19 +++++++++++++ icu4c/source/test/intltest/srchtest.h | 1 + 4 files changed, 62 insertions(+) diff --git a/icu4c/source/test/intltest/apicoll.cpp b/icu4c/source/test/intltest/apicoll.cpp index ee09e515cd5..bacc481424e 100644 --- a/icu4c/source/test/intltest/apicoll.cpp +++ b/icu4c/source/test/intltest/apicoll.cpp @@ -1706,6 +1706,42 @@ void CollationAPITest::TestGetTailoredSet() } } +void CollationAPITest::TestUClassID() +{ + char id = *((char *)RuleBasedCollator::getStaticClassID()); + if (id != 0) { + errln("Static class id for RuleBasedCollator should be 0"); + } + UErrorCode status = U_ZERO_ERROR; + RuleBasedCollator *coll + = (RuleBasedCollator *)Collator::createInstance(status); + id = *((char *)coll->getDynamicClassID()); + if (id != 0) { + errln("Dynamic class id for RuleBasedCollator should be 0"); + } + id = *((char *)CollationKey::getStaticClassID()); + if (id != 0) { + errln("Static class id for CollationKey should be 0"); + } + CollationKey *key = new CollationKey(); + id = *((char *)key->getDynamicClassID()); + if (id != 0) { + errln("Dynamic class id for CollationKey should be 0"); + } + id = *((char *)CollationElementIterator::getStaticClassID()); + if (id != 0) { + errln("Static class id for CollationElementIterator should be 0"); + } + UnicodeString str("testing"); + CollationElementIterator *iter = coll->createCollationElementIterator(str); + id = *((char *)iter->getDynamicClassID()); + if (id != 0) { + errln("Dynamic class id for CollationElementIterator should be 0"); + } + delete iter; + delete coll; +} + void CollationAPITest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */) { if (exec) logln("TestSuite CollationAPITest: "); @@ -1730,6 +1766,7 @@ void CollationAPITest::runIndexedTest( int32_t index, UBool exec, const char* &n case 17: name = "TestGetLocale"; if (exec) TestGetLocale(); break; case 18: name = "TestBounds"; if (exec) TestBounds(); break; case 19: name = "TestGetTailoredSet"; if (exec) TestGetTailoredSet(); break; + case 20: name = "TestUClassID"; if (exec) TestUClassID(); break; default: name = ""; break; } } diff --git a/icu4c/source/test/intltest/apicoll.h b/icu4c/source/test/intltest/apicoll.h index 4093c0ff189..79cb3ca0d38 100644 --- a/icu4c/source/test/intltest/apicoll.h +++ b/icu4c/source/test/intltest/apicoll.h @@ -149,6 +149,11 @@ public: */ void TestGetTailoredSet(); + /** + * Tests the dynamic and static ids of collation classes + */ + void TestUClassID(); + private: // If this is too small for the test data, just increase it. // Just don't make it too large, otherwise the executable will get too big diff --git a/icu4c/source/test/intltest/srchtest.cpp b/icu4c/source/test/intltest/srchtest.cpp index 1f1018c3e3e..1b6196c069e 100644 --- a/icu4c/source/test/intltest/srchtest.cpp +++ b/icu4c/source/test/intltest/srchtest.cpp @@ -135,6 +135,7 @@ void StringSearchTest::runIndexedTest(int32_t index, UBool exec, CASE(31, TestSupplementaryCanonical) CASE(32, TestContractionCanonical) CASE(33, TestSearchIterator) + CASE(34, TestUClassID) default: name = ""; break; } } @@ -2165,4 +2166,22 @@ void StringSearchTest::TestSearchIterator() } } +void StringSearchTest::TestUClassID() +{ + char id = *((char *)StringSearch::getStaticClassID()); + if (id != 0) { + errln("Static class id for StringSearch should be 0"); + } + UErrorCode status = U_ZERO_ERROR; + UnicodeString text("text"); + UnicodeString pattern("pattern"); + StringSearch *strsrch = new StringSearch(pattern, text, m_en_us_, NULL, + status); + id = *((char *)strsrch->getDynamicClassID()); + if (id != 0) { + errln("Dynamic class id for StringSearch should be 0"); + } + delete strsrch; +} + #endif /* #if !UCONFIG_NO_COLLATION */ diff --git a/icu4c/source/test/intltest/srchtest.h b/icu4c/source/test/intltest/srchtest.h index c8b13a13f54..c65487f47f2 100644 --- a/icu4c/source/test/intltest/srchtest.h +++ b/icu4c/source/test/intltest/srchtest.h @@ -86,6 +86,7 @@ private: void TestSupplementaryCanonical(); void TestContractionCanonical(); void TestSearchIterator(); + void TestUClassID(); }; #endif /* #if !UCONFIG_NO_COLLATION */