]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/trnserr.cpp
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / test / intltest / trnserr.cpp
index 05446c5ca967845d63a566129c519d3bbea378b6..0b76616672fadbace88ec8781f81216eb37b1d1d 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2001-2003, International Business Machines Corporation and
+ * Copyright (c) 2001-2005, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /************************************************************************
@@ -23,8 +23,6 @@
 #include "unicode/translit.h"
 #include "unicode/uniset.h"
 #include "rbt.h"
-#include "unitohex.h"
-#include "hextouni.h"
 #include "unicode/unifilt.h"
 #include "cpdtrans.h"
 #include "nultrans.h"
@@ -44,9 +42,10 @@ TransliteratorErrorTest::runIndexedTest(int32_t index, UBool exec,
     switch (index) {
         TESTCASE(0,TestTransliteratorErrors);
         TESTCASE(1, TestUnicodeSetErrors);
-        TESTCASE(2, TestUniToHexErrors);
-        TESTCASE(3, TestRBTErrors);
-        TESTCASE(4, TestHexToUniErrors);
+        TESTCASE(2, TestRBTErrors);
+        TESTCASE(3, TestCoverage);
+        //TESTCASE(3, TestUniToHexErrors);
+        //TESTCASE(4, TestHexToUniErrors);
         // TODO: Add a subclass to test clone().
         default: name = ""; break;
     }
@@ -192,29 +191,29 @@ void TransliteratorErrorTest::TestUnicodeSetErrors() {
     delete set1;
 }
 
-void TransliteratorErrorTest::TestUniToHexErrors() {
-    UErrorCode status = U_ZERO_ERROR;
-    Transliterator *t = new UnicodeToHexTransliterator("", TRUE, NULL, status);
-    if (U_SUCCESS(status)) {
-        errln("FAIL: Created a UnicodeToHexTransliterator with an empty pattern.");
-    }
-    delete t;
-
-    status = U_ZERO_ERROR;
-    t = new UnicodeToHexTransliterator("\\x", TRUE, NULL, status);
-    if (U_SUCCESS(status)) {
-        errln("FAIL: Created a UnicodeToHexTransliterator with a bad pattern.");
-    }
-    delete t;
-
-    status = U_ZERO_ERROR;
-    t = new UnicodeToHexTransliterator();
-    ((UnicodeToHexTransliterator*)t)->applyPattern("\\x", status);
-    if (U_SUCCESS(status)) {
-        errln("FAIL: UnicodeToHexTransliterator::applyPattern succeeded with a bad pattern.");
-    }
-    delete t;
-}
+//void TransliteratorErrorTest::TestUniToHexErrors() {
+//    UErrorCode status = U_ZERO_ERROR;
+//    Transliterator *t = new UnicodeToHexTransliterator("", TRUE, NULL, status);
+//    if (U_SUCCESS(status)) {
+//        errln("FAIL: Created a UnicodeToHexTransliterator with an empty pattern.");
+//    }
+//    delete t;
+//
+//    status = U_ZERO_ERROR;
+//    t = new UnicodeToHexTransliterator("\\x", TRUE, NULL, status);
+//    if (U_SUCCESS(status)) {
+//        errln("FAIL: Created a UnicodeToHexTransliterator with a bad pattern.");
+//    }
+//    delete t;
+//
+//    status = U_ZERO_ERROR;
+//    t = new UnicodeToHexTransliterator();
+//    ((UnicodeToHexTransliterator*)t)->applyPattern("\\x", status);
+//    if (U_SUCCESS(status)) {
+//        errln("FAIL: UnicodeToHexTransliterator::applyPattern succeeded with a bad pattern.");
+//    }
+//    delete t;
+//}
 
 void TransliteratorErrorTest::TestRBTErrors() {
 
@@ -244,26 +243,47 @@ void TransliteratorErrorTest::TestRBTErrors() {
     } 
 }
 
-void TransliteratorErrorTest::TestHexToUniErrors() {
-    UErrorCode status = U_ZERO_ERROR;
-    Transliterator *t = new HexToUnicodeTransliterator("", NULL, status);
-    if (U_FAILURE(status)) {
-        errln("FAIL: Could not create a HexToUnicodeTransliterator with an empty pattern.");
+//void TransliteratorErrorTest::TestHexToUniErrors() {
+//    UErrorCode status = U_ZERO_ERROR;
+//    Transliterator *t = new HexToUnicodeTransliterator("", NULL, status);
+//    if (U_FAILURE(status)) {
+//        errln("FAIL: Could not create a HexToUnicodeTransliterator with an empty pattern.");
+//    }
+//    delete t;
+//    status = U_ZERO_ERROR;
+//    t = new HexToUnicodeTransliterator("\\x", NULL, status);
+//    if (U_SUCCESS(status)) {
+//        errln("FAIL: Created a HexToUnicodeTransliterator with a bad pattern.");
+//    }
+//    delete t;
+//    status = U_ZERO_ERROR;
+//    t = new HexToUnicodeTransliterator();
+//    ((HexToUnicodeTransliterator*)t)->applyPattern("\\x", status);
+//    if (U_SUCCESS(status)) {
+//        errln("FAIL: HexToUnicodeTransliterator::applyPattern succeeded with a bad pattern.");
+//    }
+//    delete t;
+//}
+
+class StubTransliterator: public Transliterator{
+public:
+    StubTransliterator(): Transliterator(UNICODE_STRING_SIMPLE("Any-Null"), 0) {}
+    virtual void handleTransliterate(Replaceable& ,UTransPosition& offsets,UBool) const {
+        offsets.start = offsets.limit;
     }
-    delete t;
-    status = U_ZERO_ERROR;
-    t = new HexToUnicodeTransliterator("\\x", NULL, status);
-    if (U_SUCCESS(status)) {
-        errln("FAIL: Created a HexToUnicodeTransliterator with a bad pattern.");
+
+    virtual UClassID getDynamicClassID() const{
+        static char classID = 0;
+        return (UClassID)&classID; 
     }
-    delete t;
-    status = U_ZERO_ERROR;
-    t = new HexToUnicodeTransliterator();
-    ((HexToUnicodeTransliterator*)t)->applyPattern("\\x", status);
-    if (U_SUCCESS(status)) {
-        errln("FAIL: HexToUnicodeTransliterator::applyPattern succeeded with a bad pattern.");
+};
+
+void TransliteratorErrorTest::TestCoverage() {
+    StubTransliterator stub;
+
+    if (stub.clone() != NULL){
+        errln("FAIL: default Transliterator::clone() should return NULL");
     }
-    delete t;
 }
 
 #endif /* #if !UCONFIG_NO_TRANSLITERATION */