]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/itutil.cpp
ICU-511.34.tar.gz
[apple/icu.git] / icuSources / test / intltest / itutil.cpp
index bd5e392c1f72be1a4b176353f93fb3480cad644d..2f726101ce86bc5067c6bc53e8e4ed934c7f6026 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
  * others. All Rights Reserved.
  ********************************************************************/
 
 #include "aliastst.h"
 #include "usettest.h"
 
 #include "aliastst.h"
 #include "usettest.h"
 
+extern IntlTest *createBytesTrieTest();
 static IntlTest *createLocalPointerTest();
 static IntlTest *createLocalPointerTest();
+extern IntlTest *createUCharsTrieTest();
+static IntlTest *createEnumSetTest();
 
 #define CASE(id, test) case id:                               \
                           name = #test;                       \
 
 #define CASE(id, test) case id:                               \
                           name = #test;                       \
@@ -68,6 +71,30 @@ void IntlTestUtilities::runIndexedTest( int32_t index, UBool exec, const char* &
                 callTest(*test, par);
             }
             break;
                 callTest(*test, par);
             }
             break;
+        case 17:
+            name = "BytesTrieTest";
+            if (exec) {
+                logln("TestSuite BytesTrieTest---"); logln();
+                LocalPointer<IntlTest> test(createBytesTrieTest());
+                callTest(*test, par);
+            }
+            break;
+        case 18:
+            name = "UCharsTrieTest";
+            if (exec) {
+                logln("TestSuite UCharsTrieTest---"); logln();
+                LocalPointer<IntlTest> test(createUCharsTrieTest());
+                callTest(*test, par);
+            }
+            break;
+        case 19:
+            name = "EnumSetTest";
+            if (exec) {
+                logln("TestSuite EnumSetTest---"); logln();
+                LocalPointer<IntlTest> test(createEnumSetTest());
+                callTest(*test, par);
+            }
+            break;
         default: name = ""; break; //needed to end loop
     }
 }
         default: name = ""; break; //needed to end loop
     }
 }
@@ -304,7 +331,7 @@ void LocalPointerTest::TestLocalXyzPointer() {
     }
 
     LocalUDateTimePatternGeneratorPointer patgen(udatpg_open("root", errorCode));
     }
 
     LocalUDateTimePatternGeneratorPointer patgen(udatpg_open("root", errorCode));
-    if(errorCode.logIfFailureAndReset("udatpg_open()")) {
+    if(errorCode.logDataIfFailureAndReset("udatpg_open()")) {
         return;
     }
     if(patgen.isNull()) {
         return;
     }
     if(patgen.isNull()) {
@@ -334,7 +361,7 @@ void LocalPointerTest::TestLocalXyzPointer() {
 #endif  /* UCONFIG_NO_FORMATTING  */
 
 #if !UCONFIG_NO_NORMALIZATION
 #endif  /* UCONFIG_NO_FORMATTING  */
 
 #if !UCONFIG_NO_NORMALIZATION
-    const UNormalizer2 *nfc=unorm2_getInstance(NULL, "nfc", UNORM2_COMPOSE, errorCode);
+    const UNormalizer2 *nfc=unorm2_getNFCInstance(errorCode);
     UnicodeSet emptySet;
     LocalUNormalizer2Pointer fn2(unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode));
     if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) {
     UnicodeSet emptySet;
     LocalUNormalizer2Pointer fn2(unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode));
     if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) {
@@ -448,3 +475,84 @@ void LocalPointerTest::TestLocalXyzPointerNull() {
 #endif /* !UCONFIG_NO_TRANSLITERATION */
 
 }
 #endif /* !UCONFIG_NO_TRANSLITERATION */
 
 }
+
+/** EnumSet test **/
+#include "unicode/enumset.h"
+
+class EnumSetTest : public IntlTest {
+public:
+  EnumSetTest() {}
+  virtual void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=NULL);
+  void TestEnumSet();
+};
+
+static IntlTest *createEnumSetTest() {
+    return new EnumSetTest();
+}
+
+void EnumSetTest::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
+  TESTCASE_AUTO_BEGIN;
+  TESTCASE_AUTO(TestEnumSet);
+  TESTCASE_AUTO_END;
+}
+enum myEnum {
+    MAX_NONBOOLEAN=-1,
+    THING1,
+    THING2,
+    THING3,
+    LIMIT_BOOLEAN
+};
+
+void EnumSetTest::TestEnumSet() {
+    EnumSet<myEnum,
+            MAX_NONBOOLEAN+1,
+            LIMIT_BOOLEAN>
+                            flags;
+
+    logln("Enum is from [%d..%d]\n", MAX_NONBOOLEAN+1,
+          LIMIT_BOOLEAN);
+
+    TEST_ASSERT_TRUE(flags.get(THING1) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == FALSE);
+
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    logln("Value now: %d\n", flags.getAll());
+    flags.clear();
+    logln("clear -Value now: %d\n", flags.getAll());
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    TEST_ASSERT_TRUE(flags.get(THING1) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == FALSE);
+    flags.add(THING1);
+    logln("set THING1 -Value now: %d\n", flags.getAll());
+    TEST_ASSERT_TRUE(flags.get(THING1) == TRUE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == FALSE);
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    flags.add(THING3);
+    logln("set THING3 -Value now: %d\n", flags.getAll());
+    TEST_ASSERT_TRUE(flags.get(THING1) == TRUE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == TRUE);
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    flags.remove(THING2);
+    TEST_ASSERT_TRUE(flags.get(THING1) == TRUE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == TRUE);
+    logln("remove THING2 -Value now: %d\n", flags.getAll());
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    flags.remove(THING1);
+    TEST_ASSERT_TRUE(flags.get(THING1) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == TRUE);
+    logln("remove THING1 -Value now: %d\n", flags.getAll());
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+
+    flags.clear();
+    logln("clear -Value now: %d\n", flags.getAll());
+    logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n",          flags.get(THING1),          flags.get(THING2),          flags.get(THING3));
+    TEST_ASSERT_TRUE(flags.get(THING1) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING2) == FALSE);
+    TEST_ASSERT_TRUE(flags.get(THING3) == FALSE);
+}