/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2001-2003, International Business Machines Corporation and
+ * Copyright (c) 2001-2005, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/************************************************************************
#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"
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;
}
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() {
}
}
-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 */