]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/tscoll.cpp
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / tscoll.cpp
index 3644e4a3a1eb7e4902781483109727dd2cdf777d..b13f30ae6d240b0a9c49fbb95f28901d46619d75 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2009, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
 #if !UCONFIG_NO_COLLATION
 
 #include "unicode/localpointer.h"
+#include "unicode/sortkey.h"
 #include "unicode/uchar.h"
 #include "unicode/ustring.h"
 
-#include "dadrcoll.h"
-
 #include "encoll.h"
 #include "frcoll.h"
 #include "decoll.h"
 #include "thcoll.h"
 #include "srchtest.h"
 #include "ssearch.h"
-#include "cntabcol.h"
 #include "lcukocol.h"
 #include "ucaconf.h"
 #include "svccoll.h"
 #include "cmemory.h"
-//#include "rndmcoll.h"
+#include "alphaindextst.h"
 
 // Set to 1 to test offsets in backAndForth()
 #define TEST_OFFSETS 0
 
-#define TESTCLASS(n,classname)        \
-    case n:                           \
-        name = #classname;            \
-        if (exec) {                   \
-            logln(#classname "---");  \
-            logln("");                \
-            classname t;              \
-            callTest(t, par);         \
-        }                             \
-        break
+extern IntlTest *createCollationTest();
 
 void IntlTestCollator::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
 {
@@ -71,35 +62,32 @@ void IntlTestCollator::runIndexedTest( int32_t index, UBool exec, const char* &n
         logln("TestSuite Collator: ");
     }
 
-    switch (index) {
-      TESTCLASS(0, CollationEnglishTest);
-      TESTCLASS(1, CollationFrenchTest);
-      TESTCLASS(2, CollationGermanTest);
-      TESTCLASS(3, CollationSpanishTest);
-      TESTCLASS(4, CollationKanaTest);
-      TESTCLASS(5, CollationTurkishTest);
-      TESTCLASS(6, CollationDummyTest);
-      TESTCLASS(7, G7CollationTest);
-      TESTCLASS(8, CollationMonkeyTest);
-      TESTCLASS(9, CollationAPITest);
-      TESTCLASS(10, CollationRegressionTest);
-      TESTCLASS(11, CollationCurrencyTest);
-      TESTCLASS(12, CollationIteratorTest);
-      TESTCLASS(13, CollationThaiTest);
-      TESTCLASS(14, LotusCollationKoreanTest);
-      TESTCLASS(15, StringSearchTest);
-      TESTCLASS(16, ContractionTableTest);
-#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
-      TESTCLASS(17, DataDrivenCollatorTest);
+    TESTCASE_AUTO_BEGIN;
+    TESTCASE_AUTO_CLASS(CollationEnglishTest);
+    TESTCASE_AUTO_CLASS(CollationFrenchTest);
+    TESTCASE_AUTO_CLASS(CollationGermanTest);
+    TESTCASE_AUTO_CLASS(CollationSpanishTest);
+    TESTCASE_AUTO_CLASS(CollationKanaTest);
+    TESTCASE_AUTO_CLASS(CollationTurkishTest);
+    TESTCASE_AUTO_CLASS(CollationDummyTest);
+    TESTCASE_AUTO_CLASS(G7CollationTest);
+    TESTCASE_AUTO_CLASS(CollationMonkeyTest);
+    TESTCASE_AUTO_CLASS(CollationAPITest);
+    TESTCASE_AUTO_CLASS(CollationRegressionTest);
+    TESTCASE_AUTO_CLASS(CollationCurrencyTest);
+    TESTCASE_AUTO_CLASS(CollationIteratorTest);
+    TESTCASE_AUTO_CLASS(CollationThaiTest);
+    TESTCASE_AUTO_CLASS(LotusCollationKoreanTest);
+    TESTCASE_AUTO_CLASS(StringSearchTest);
+    TESTCASE_AUTO_CLASS(UCAConformanceTest);
+    TESTCASE_AUTO_CLASS(CollationServiceTest);
+    TESTCASE_AUTO_CLASS(CollationFinnishTest); // removed by weiv - we have changed Finnish collation
+    TESTCASE_AUTO_CLASS(SSearchTest);
+#if !UCONFIG_NO_NORMALIZATION
+    TESTCASE_AUTO_CLASS(AlphabeticIndexTest);
 #endif
-      TESTCLASS(18, UCAConformanceTest);
-      TESTCLASS(19, CollationServiceTest);
-      TESTCLASS(20, CollationFinnishTest); // removed by weiv - we have changed Finnish collation
-      //TESTCLASS(21, RandomCollatorTest); // See ticket 5747 about reenabling this test.
-      TESTCLASS(21, SSearchTest);
-
-      default: name = ""; break;
-    }
+    TESTCASE_AUTO_CREATE_CLASS(CollationTest);
+    TESTCASE_AUTO_END;
 }
 
 UCollationResult 
@@ -141,7 +129,7 @@ IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
 {   
   UErrorCode status = U_ZERO_ERROR;
 
-  UCollator *myCollation = (UCollator *)((RuleBasedCollator *)col)->getUCollator();
+  UCollator *myCollation = col->toUCollator();
 
   Collator::EComparisonResult compareResult = col->compare(source, target);
 
@@ -520,6 +508,10 @@ IntlTestCollator::Order *IntlTestCollator::getOrders(CollationElementIterator &i
         offset = iter.getOffset();
         size += 1;
     }
+    if (U_FAILURE(status)) {
+        errln("CollationElementIterator.next() failed - %s",
+              u_errorName(status));
+    }
 
     if (maxSize > size)
     {