ICU-1225 test new Any-Hex and Hex-Any variants

X-SVN-Rev: 7050
This commit is contained in:
Alan Liu 2001-11-21 07:08:13 +00:00
parent 76b369219e
commit efe00fdd38
2 changed files with 59 additions and 0 deletions

View File

@ -140,6 +140,7 @@ TransliteratorTest::runIndexedTest(int32_t index, UBool exec,
TESTCASE(58,TestInvalidPostContext);
TESTCASE(59,TestIDForms);
TESTCASE(60,TestToRulesMark);
TESTCASE(61,TestEscape);
default: name = ""; break;
}
}
@ -2834,6 +2835,59 @@ void TransliteratorTest::TestToRulesMark() {
delete t3;
}
/**
* Test Escape and Unescape transliterators.
*/
void TransliteratorTest::TestEscape() {
UParseError pe;
UErrorCode ec;
Transliterator *t;
ec = U_ZERO_ERROR;
t = Transliterator::createInstance("Hex-Any", UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
errln((UnicodeString)"FAIL: createInstance");
} else {
expect(*t,
"\\x{40}\\U000000312Q",
"@12Q");
}
delete t;
ec = U_ZERO_ERROR;
t = Transliterator::createInstance("Any-Hex/C", UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
errln((UnicodeString)"FAIL: createInstance");
} else {
expect(*t,
CharsToUnicodeString("A\\U0010BEEF\\uFEED"),
"\\u0041\\U0010BEEF\\uFEED");
}
delete t;
ec = U_ZERO_ERROR;
t = Transliterator::createInstance("Any-Hex/Java", UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
errln((UnicodeString)"FAIL: createInstance");
} else {
expect(*t,
CharsToUnicodeString("A\\U0010BEEF\\uFEED"),
"\\u0041\\uDBEF\\uDEEF\\uFEED");
}
delete t;
ec = U_ZERO_ERROR;
t = Transliterator::createInstance("Any-Hex/Perl", UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
errln((UnicodeString)"FAIL: createInstance");
} else {
expect(*t,
CharsToUnicodeString("A\\U0010BEEF\\uFEED"),
"\\x{41}\\x{10BEEF}\\x{FEED}");
}
delete t;
}
//======================================================================
// icu4c ONLY
// These tests are not mirrored (yet) in icu4j at

View File

@ -287,6 +287,11 @@ class TransliteratorTest : public IntlTest {
*/
void TestToRulesMark();
/**
* Test Escape and Unescape transliterators.
*/
void TestEscape();
//======================================================================
// Support methods
//======================================================================