/*
**********************************************************************
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
#include "unicode/ustring.h"
#include "unicode/usetiter.h"
#include "unicode/uscript.h"
+#include "unicode/utf16.h"
#include "cpdtrans.h"
#include "nultrans.h"
#include "rbt.h"
TESTCASE(62,TestAnchorMasking);
TESTCASE(63,TestDisplayName);
TESTCASE(64,TestSpecialCases);
+#if !UCONFIG_NO_FILE_IO
TESTCASE(65,TestIncrementalProgress);
+#endif
TESTCASE(66,TestSurrogateCasing);
TESTCASE(67,TestFunction);
TESTCASE(68,TestInvalidBackRef);
TESTCASE(71,TestAnyX);
TESTCASE(72,TestSourceTargetSet);
TESTCASE(73,TestGurmukhiDevanagari);
- TESTCASE(74,TestRuleWhitespace);
+ TESTCASE(74,TestPatternWhiteSpace);
TESTCASE(75,TestAllCodepoints);
TESTCASE(76,TestBoilerplate);
TESTCASE(77,TestAlternateSyntax);
TESTCASE(81,TestRuleStripping);
TESTCASE(82,TestHalfwidthFullwidth);
TESTCASE(83,TestThai);
+ TESTCASE(84,TestAny);
default: name = ""; break;
}
}
-static const UVersionInfo ICU_39 = {3,9,4,0};
/**
* Make sure every system transliterator can be instantiated.
*
name.truncate(0);
Transliterator::getDisplayName(id, name);
if (t == 0) {
- errln(UnicodeString("FAIL: Couldn't create ") + id +
- /*", parse error " + parseError.code +*/
- ", line " + parseError.line +
- ", offset " + parseError.offset +
- ", pre-context " + prettify(parseError.preContext, TRUE) +
- ", post-context " +prettify(parseError.postContext,TRUE) +
- ", Error: " + u_errorName(status));
- // When createInstance fails, it deletes the failing
- // entry from the available ID list. We detect this
- // here by looking for a change in countAvailableIDs.
+#if UCONFIG_NO_BREAK_ITERATION
+ // If UCONFIG_NO_BREAK_ITERATION is on, then only Thai should fail.
+ if (id.compare((UnicodeString)"Thai-Latin") != 0)
+#endif
+ dataerrln(UnicodeString("FAIL: Couldn't create ") + id +
+ /*", parse error " + parseError.code +*/
+ ", line " + parseError.line +
+ ", offset " + parseError.offset +
+ ", pre-context " + prettify(parseError.preContext, TRUE) +
+ ", post-context " +prettify(parseError.postContext,TRUE) +
+ ", Error: " + u_errorName(status));
+ // When createInstance fails, it deletes the failing
+ // entry from the available ID list. We detect this
+ // here by looking for a change in countAvailableIDs.
int32_t nn = Transliterator::countAvailableIDs();
if (nn == (n - 1)) {
n = nn;
UTRANS_FORWARD, parseError,
status);
if (U_FAILURE(status)) {
- errln("FAIL: RBT constructor failed");
+ dataerrln("FAIL: RBT constructor failed - %s", u_errorName(status));
return;
}
expect(*t, "abcdefgABCDEFGU", "&bcd&fg!^**!^*&");
UErrorCode status = U_ZERO_ERROR;
Transliterator* t = Transliterator::createInstance("Latin-Hiragana;Hiragana-Latin", UTRANS_FORWARD, parseError, status);
if (t == 0) {
- errln("FAIL: construction of Latin-Hiragana;Hiragana-Latin failed");
+ dataerrln("FAIL: construction of Latin-Hiragana;Hiragana-Latin failed - %s", u_errorName(status));
} else {
expect(*t, "aaaaa", "aaaaa");
delete t;
UParseError parseError;
Transliterator *gl = Transliterator::createInstance("Greek-Latin; NFD; [:M:]Remove; NFC", UTRANS_FORWARD, parseError, status);
if (gl == NULL) {
- errln("FAIL: createInstance(Greek-Latin) returned NULL");
+ dataerrln("FAIL: createInstance(Greek-Latin) returned NULL - %s", u_errorName(status));
return;
}
Transliterator* hk = Transliterator::createInstance("Hiragana-Katakana", UTRANS_FORWARD, parseError, status);
Transliterator* kh = Transliterator::createInstance("Katakana-Hiragana", UTRANS_FORWARD, parseError, status);
if (hk == 0 || kh == 0) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(status));
delete hk;
delete kh;
return;
UParseError parseError;
Transliterator* dg = Transliterator::createInstance(ID, UTRANS_FORWARD, parseError, status);
if (dg == 0) {
- errln("FAIL: createInstance(" + ID + ") returned NULL");
+ dataerrln("FAIL: createInstance(" + ID + ") returned NULL - " + u_errorName(status));
return;
}
UnicodeString id = dg->getID();
// Careful: CharsToUS will convert "\\N" => "N"; use "\\\\N" for \N
expect(*uni2name, CharsToUnicodeString("\\u00A0abc\\u4E01\\u00B5\\u0A81\\uFFFD\\u0004\\u0009\\u0081\\uFFFF"),
- CharsToUnicodeString("\\\\N{NO-BREAK SPACE}abc\\\\N{CJK UNIFIED IDEOGRAPH-4E01}\\\\N{MICRO SIGN}\\\\N{GUJARATI SIGN CANDRABINDU}\\\\N{REPLACEMENT CHARACTER}\\\\N{END OF TRANSMISSION}\\\\N{CHARACTER TABULATION}\\\\N{<control-0081>}\\\\N{<noncharacter-FFFF>}"));
- expect(*name2uni, UNICODE_STRING_SIMPLE("{\\N { NO-BREAK SPACE}abc\\N{ CJK UNIFIED IDEOGRAPH-4E01 }\\N{x\\N{MICRO SIGN}\\N{GUJARATI SIGN CANDRABINDU}\\N{REPLACEMENT CHARACTER}\\N{END OF TRANSMISSION}\\N{CHARACTER TABULATION}\\N{<control-0081>}\\N{<noncharacter-FFFF>}\\N{<control-0004>}\\N{"),
+ CharsToUnicodeString("\\\\N{NO-BREAK SPACE}abc\\\\N{CJK UNIFIED IDEOGRAPH-4E01}\\\\N{MICRO SIGN}\\\\N{GUJARATI SIGN CANDRABINDU}\\\\N{REPLACEMENT CHARACTER}\\\\N{<control-0004>}\\\\N{<control-0009>}\\\\N{<control-0081>}\\\\N{<noncharacter-FFFF>}"));
+ expect(*name2uni, UNICODE_STRING_SIMPLE("{\\N { NO-BREAK SPACE}abc\\N{ CJK UNIFIED IDEOGRAPH-4E01 }\\N{x\\N{MICRO SIGN}\\N{GUJARATI SIGN CANDRABINDU}\\N{REPLACEMENT CHARACTER}\\N{<control-0004>}\\N{<control-0009>}\\N{<control-0081>}\\N{<noncharacter-FFFF>}\\N{<control-0004>}\\N{"),
CharsToUnicodeString("{\\u00A0abc\\u4E01\\\\N{x\\u00B5\\u0A81\\uFFFD\\u0004\\u0009\\u0081\\uFFFF\\u0004\\\\N{"));
delete uni2name;
for (int32_t i=0; i<DATA_length; i+=3) {
Transliterator *t = Transliterator::createInstance(DATA[i], UTRANS_FORWARD, parseError, status);
if (t == 0) {
- errln(UnicodeString("FAIL: ") + DATA[i+2] +
- " cannot create ID \"" + DATA[i] + "\"");
+ dataerrln(UnicodeString("FAIL: ") + DATA[i+2] +
+ " cannot create ID \"" + DATA[i] + "\" - " + u_errorName(status));
} else {
UnicodeString exp;
if (DATA[i+1]) {
logln((UnicodeString)"Ok: createInstance(" +
id + "," + DATA[i+1] + ") => " + newID);
} else {
- errln((UnicodeString)"FAIL: createInstance(" +
+ dataerrln((UnicodeString)"FAIL: createInstance(" +
id + "," + DATA[i+1] + ") => " + newID +
", expected " + expID);
}
Transliterator* NFD = Transliterator::createInstance("NFD", UTRANS_FORWARD, parseError, status);
Transliterator* NFC = Transliterator::createInstance("NFC", UTRANS_FORWARD, parseError, status);
if (!NFD || !NFC) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed: %s", u_errorName(status));
delete NFD;
delete NFC;
return;
Transliterator* NFKD = Transliterator::createInstance("NFKD", UTRANS_FORWARD, parseError, status);
Transliterator* NFKC = Transliterator::createInstance("NFKC", UTRANS_FORWARD, parseError, status);
if (!NFKD || !NFKC) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed");
delete NFKD;
delete NFKC;
return;
// Now test toRules
t = Transliterator::createInstance("Greek-Latin; Latin-Cyrillic", UTRANS_FORWARD, parseError, status);
if (t == 0) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(status));
return;
}
UnicodeString exp("::Greek-Latin;\n::Latin-Cyrillic;");
Transliterator *t = Transliterator::createInstance
("Greek-Latin; Latin-Greek; Lower", UTRANS_FORWARD, parseError, status);
if (t == 0) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(status));
return;
}
t->adoptFilter(new UnicodeSet("[^A]", status));
Transliterator *t = Transliterator::createFromRules("ID",
UnicodeString(DATA[d+1], -1, US_INV), UTRANS_FORWARD, parseError, status);
if (t == 0) {
- errln("FAIL: createFromRules failed");
+ dataerrln("FAIL: createFromRules failed - %s", u_errorName(status));
return;
}
UnicodeString rules, escapedRules;
Transliterator *t = Transliterator::createInstance
("Greek-Latin; Title()", UTRANS_REVERSE,parseError, status);
if (t == 0) {
- errln("FAIL: createInstance");
+ dataerrln("FAIL: createInstance - %s", u_errorName(status));
return;
}
UnicodeString exp("(Title);Latin-Greek");
"TEST", "::NFD; aa > Q; a > q;",
UTRANS_FORWARD, pe, ec);
if (t == NULL || U_FAILURE(ec)) {
- errln("FAIL: Transliterator::createFromRules failed with %s", u_errorName(ec));
+ dataerrln("FAIL: Transliterator::createFromRules failed with %s", u_errorName(ec));
return;
}
expect(*t, "aa", "Q");
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance(ID, UTRANS_FORWARD, pe, ec);
if (t == 0 || U_FAILURE(ec)) {
- errln("FAIL: createInstance");
+ dataerrln("FAIL: createInstance - %s", u_errorName(ec));
return;
}
Transliterator *u = t->createInverse(ec);
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance(ID, UTRANS_FORWARD, pe, ec);
if (t == 0 || U_FAILURE(ec)) {
- errln("FAIL: createInstance");
+ dataerrln("FAIL: createInstance - %s", u_errorName(ec));
return;
}
Transliterator *u = t->createInverse(ec);
}
delete t;
} else {
- errln((UnicodeString)"FAIL: " + id + " => " + transID + ", " +
+ dataerrln((UnicodeString)"FAIL: " + id + " => " + transID + ", " +
u_errorName(ec));
}
}
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance("Latin-Hiragana", UTRANS_FORWARD, pe, ec);
if (t == 0 || U_FAILURE(ec)) {
- errln("FAIL: createInstance Latin-Hiragana");
+ dataerrln("FAIL: createInstance Latin-Hiragana - %s", u_errorName(ec));
return;
}
// Katakana should be untouched
Transliterator* latinToDev=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status);
Transliterator* devToLatin=Transliterator::createInstance("Devanagari-Latin", UTRANS_FORWARD, parseError, status);
if(U_FAILURE(status)){
- errln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
- errln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
+ dataerrln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
+ dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
return;
}
UnicodeString gotResult;
Transliterator* latinToDev=Transliterator::createInstance("Latin-Telugu", UTRANS_FORWARD, parseError, status);
Transliterator* devToLatin=Transliterator::createInstance("Telugu-Latin", UTRANS_FORWARD, parseError, status);
if(U_FAILURE(status)){
- errln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
- errln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
+ dataerrln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
+ dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
return;
}
UnicodeString gotResult;
Transliterator* latinToDev=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status);
Transliterator* devToLatin=Transliterator::createInstance("Devanagari-Latin", UTRANS_FORWARD, parseError, status);
if(U_FAILURE(status)){
- errln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
- errln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
+ dataerrln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
+ dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
return;
}
UnicodeString gotResult;
Transliterator* latinToTelToLatin=Transliterator::createInstance("Latin-Telugu;Telugu-Latin", UTRANS_FORWARD, parseError, status);
if(U_FAILURE(status)){
- errln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
- errln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
+ dataerrln("FAIL: construction " + UnicodeString(" Error: ") + u_errorName(status));
+ dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
return;
}
UnicodeString gotResult;
UnicodeSetIterator nvIter(non_vowel);
Transliterator* trans = Transliterator::createInstance("Devanagari-Gurmukhi",UTRANS_FORWARD, parseError, status);
if(U_FAILURE(status)) {
- errln("Error creating transliterator %s", u_errorName(status));
+ dataerrln("Error creating transliterator %s", u_errorName(status));
delete trans;
return;
}
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance("ru_RU-Latin", UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
- errln("FAIL: createInstance(ru_RU-Latin)");
+ dataerrln("FAIL: createInstance(ru_RU-Latin) - %s", u_errorName(ec));
delete t;
return;
}
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createInstance(DATA[i], UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
- errln((UnicodeString)"FAIL: createInstance(" + DATA[i] + ")");
+ dataerrln((UnicodeString)"FAIL: createInstance(" + DATA[i] + ") - " + u_errorName(ec));
delete t;
continue;
}
if (!expValid) {
logln((UnicodeString)"Ok: getInstance(" + ID +") => " + u_errorName(ec));
} else {
- errln((UnicodeString)"FAIL: Couldn't create " + ID);
+ dataerrln((UnicodeString)"FAIL: Couldn't create " + ID + " - " + u_errorName(ec));
}
delete t;
continue;
if (U_FAILURE(ec)) {
delete t2;
delete t3;
- errln((UnicodeString)"FAIL: createFromRules => " + u_errorName(ec));
+ dataerrln((UnicodeString)"FAIL: createFromRules => " + u_errorName(ec));
return;
}
UnicodeString name;
Transliterator::getDisplayName(DATA[i], US, name);
if (name != DATA[i+1]) {
- errln((UnicodeString)"FAIL: " + DATA[i] + ".getDisplayName() => " +
+ dataerrln((UnicodeString)"FAIL: " + DATA[i] + ".getDisplayName() => " +
name + ", expected " + DATA[i+1]);
} else {
logln((UnicodeString)"Ok: " + DATA[i] + ".getDisplayName() => " + name);
Transliterator *t = Transliterator::createInstance(DATA[i], UTRANS_REVERSE, pe, ec);
if (U_FAILURE(ec)) {
delete t;
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(ec));
continue;
}
name = Transliterator::getDisplayName(t->getID(), US, name);
if (name != DATA[i+2]) {
- errln((UnicodeString)"FAIL: " + t->getID() + ".getDisplayName() => " +
+ dataerrln((UnicodeString)"FAIL: " + t->getID() + ".getDisplayName() => " +
name + ", expected " + DATA[i+2]);
} else {
logln((UnicodeString)"Ok: " + t->getID() + ".getDisplayName() => " + name);
Transliterator *t = Transliterator::createFromRules(registerRules[0+i],
registerRules[i+1], UTRANS_FORWARD, pos, status);
if (U_FAILURE(status)) {
- errln("Fails: Unable to create the transliterator from rules.");
+ dataerrln("Fails: Unable to create the transliterator from rules. - %s", u_errorName(status));
} else {
Transliterator::registerInstance(t);
}
const UnicodeString& name = testCases[i];
Transliterator *t = Transliterator::createInstance(name, UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
- errln((UnicodeString)"FAIL: Couldn't create " + name);
+ dataerrln((UnicodeString)"FAIL: Couldn't create " + name + " - " + u_errorName(ec));
delete t;
continue;
}
char buffer[20];
UChar buffer2[20];
UChar32 dee;
- UTF_GET_CHAR(DESERET_dee,0, 0, DESERET_dee.length(), dee);
+ U16_GET(DESERET_dee,0, 0, DESERET_dee.length(), dee);
UnicodeString DEE(u_totitle(dee));
if (DEE != DESERET_DEE) {
err("Fails titlecase of surrogates");
Transliterator *t = Transliterator::createInstance(id, UTRANS_FORWARD, err, status);
if (U_FAILURE(status)) {
- errln((UnicodeString)"FAIL: Could not create " + id);
+ dataerrln((UnicodeString)"FAIL: Could not create " + id);
delete t;
continue;
}
_trans(*t, test, rev);
Transliterator *inv = t->createInverse(status);
if (U_FAILURE(status)) {
- errln((UnicodeString)"FAIL: Could not create inverse of " + id);
+#if UCONFIG_NO_BREAK_ITERATION
+ // If UCONFIG_NO_BREAK_ITERATION is on, then only Thai should fail.
+ if (id.compare((UnicodeString)"Latin-Thai/") != 0)
+#endif
+ errln((UnicodeString)"FAIL: Could not create inverse of " + id);
+
delete t;
delete inv;
continue;
return;
}
UBool gotError = FALSE;
+ (void)gotError; // Suppress set but not used warning.
// we have a few special cases. Any-Remove (pos.start = 0, but also = limit) and U+XXXXX?X?
UErrorCode ec = U_ZERO_ERROR;
Transliterator *t = Transliterator::createFromRules("Test", rule, UTRANS_FORWARD, pe, ec);
if (t == NULL) {
- errln("FAIL: createFromRules failed");
+ dataerrln("FAIL: createFromRules failed - %s", u_errorName(ec));
return;
}
UNICODE_STRING_SIMPLE("'\\'u(..)(..) > '<img src=\"http://www.unicode.org/gifs/24/' $1 '/U' $1$2 '.gif\">';"),
UTRANS_FORWARD, pe, ec);
if (t == NULL || U_FAILURE(ec)) {
- errln((UnicodeString)"FAIL: createFromRules gif " + u_errorName(ec));
+ dataerrln((UnicodeString)"FAIL: createFromRules gif " + u_errorName(ec));
return;
}
_TUFReg("Any-gif", t, 0);
Transliterator* anyLatin =
Transliterator::createInstance("Any-Latin", UTRANS_FORWARD, parseError, status);
if (anyLatin==0) {
- errln("FAIL: createInstance returned NULL");
+ dataerrln("FAIL: createInstance returned NULL - %s", u_errorName(status));
delete anyLatin;
return;
}
delete anyLatin;
}
+/**
+ * Test Any-X transliterators with sample letters from all scripts.
+ */
+void TransliteratorTest::TestAny(void) {
+ UErrorCode status = U_ZERO_ERROR;
+ // Note: there is a lot of implict construction of UnicodeStrings from (char *) in
+ // function call parameters going on in this test.
+ UnicodeSet alphabetic("[:alphabetic:]", status);
+ if (U_FAILURE(status)) {
+ dataerrln("Failure: file %s, line %d, status = %s", __FILE__, __LINE__, u_errorName(status));
+ return;
+ }
+ alphabetic.freeze();
+
+ UnicodeString testString;
+ for (int32_t i = 0; i < USCRIPT_CODE_LIMIT; i++) {
+ const char *scriptName = uscript_getShortName((UScriptCode)i);
+ if (scriptName == NULL) {
+ errln("Failure: file %s, line %d: Script Code %d is invalid, ", __FILE__, __LINE__, i);
+ return;
+ }
+
+ UnicodeSet sample;
+ sample.applyPropertyAlias("script", scriptName, status);
+ if (U_FAILURE(status)) {
+ errln("Failure: file %s, line %d, status = %s", __FILE__, __LINE__, u_errorName(status));
+ return;
+ }
+ sample.retainAll(alphabetic);
+ for (int32_t count=0; count<5; count++) {
+ UChar32 c = sample.charAt(count);
+ if (c == -1) {
+ break;
+ }
+ testString.append(c);
+ }
+ }
+
+ UParseError parseError;
+ Transliterator* anyLatin =
+ Transliterator::createInstance("Any-Latin", UTRANS_FORWARD, parseError, status);
+ if (U_FAILURE(status)) {
+ dataerrln("Failure: file %s, line %d, status = %s", __FILE__, __LINE__, u_errorName(status));
+ return;
+ }
+
+ logln(UnicodeString("Sample set for Any-Latin: ") + testString);
+ anyLatin->transliterate(testString);
+ logln(UnicodeString("Sample result for Any-Latin: ") + testString);
+ delete anyLatin;
+}
+
+
/**
* Test the source and target set API. These are only implemented
* for RBT and CompoundTransliterator at this time.
}
/**
- * Test handling of rule whitespace, for both RBT and UnicodeSet.
+ * Test handling of Pattern_White_Space, for both RBT and UnicodeSet.
*/
-void TransliteratorTest::TestRuleWhitespace() {
+void TransliteratorTest::TestPatternWhiteSpace() {
// Rules
const char* r = "a > \\u200E b;";
for(uint32_t i = 0; i<=0x10ffff; i++){
code = uscript_getScript(i,&status);
if(code == USCRIPT_INVALID_CODE){
- errln("uscript_getScript for codepoint \\U%08X failed.\n", i);
+ dataerrln("uscript_getScript for codepoint \\U%08X failed.", i);
}
const char* myId = uscript_getName(code);
if(!myId) {
- errln("Valid script code returned NULL name. Check your data!");
+ dataerrln("Valid script code returned NULL name. Check your data!");
return;
}
uprv_strcpy(id,myId);
if(uprv_strcmp(newId,oldId)!=0){
Transliterator* t = Transliterator::createInstance(newId,UTRANS_FORWARD,pe,status);
if(t==NULL || U_FAILURE(status)){
- errln((UnicodeString)"FAIL: Could not create " + id);
+ dataerrln((UnicodeString)"FAIL: Could not create " + id + " - " + u_errorName(status));
}
delete t;
}
if(uprv_strcmp(newAbbrId,oldAbbrId)!=0){
Transliterator* t = Transliterator::createInstance(newAbbrId,UTRANS_FORWARD,pe,status);
if(t==NULL || U_FAILURE(status)){
- errln((UnicodeString)"FAIL: Could not create " + id);
+ dataerrln((UnicodeString)"FAIL: Could not create " + id + " - " + u_errorName(status));
}
delete t;
}
UErrorCode ec = U_ZERO_ERROR; \
Transliterator* t = Transliterator::createInstance(id, UTRANS_FORWARD, ec); \
if (U_FAILURE(ec)) { \
- errln("FAIL: Couldn't create " id); \
+ dataerrln("FAIL: Couldn't create %s - %s", id, u_errorName(ec)); \
} else { \
if (t->getDynamicClassID() != cls::getStaticClassID()) { \
errln("FAIL: " #cls " dynamic and static class ID mismatch"); \
"::Upper(Lower);"
"::([XYZ]);"
};
-static const int32_t BEGIN_END_RULES_length = (int32_t)(sizeof(BEGIN_END_RULES) / sizeof(BEGIN_END_RULES[0]));
/*
(This entire test is commented out below and will need some heavy revision when we re-add
err = U_ZERO_ERROR;
t1 = Transliterator::createInstance(realID, UTRANS_FORWARD, err);
if (U_FAILURE(err)) {
- errln("Failed to instantiate transliterator with real ID");
+ dataerrln("Failed to instantiate transliterator with real ID - %s", u_errorName(err));
Transliterator::unregister(realID);
return;
}
Transliterator* hf = Transliterator::createInstance("Halfwidth-Fullwidth", UTRANS_FORWARD, parseError, status);
Transliterator* fh = Transliterator::createInstance("Fullwidth-Halfwidth", UTRANS_FORWARD, parseError, status);
if (hf == 0 || fh == 0) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(status));
delete hf;
delete fh;
return;
* For now, test just confirms that C++ and Java give identical results.
*/
void TransliteratorTest::TestThai(void) {
+#if !UCONFIG_NO_BREAK_ITERATION
UParseError parseError;
UErrorCode status = U_ZERO_ERROR;
Transliterator* tr = Transliterator::createInstance("Any-Latin", UTRANS_FORWARD, parseError, status);
if (tr == 0) {
- errln("FAIL: createInstance failed");
+ dataerrln("FAIL: createInstance failed - %s", u_errorName(status));
return;
}
if (U_FAILURE(status)) {
expect(*tr, xlitText, expectedText);
delete tr;
+#endif
}
UParseError pe;
Transliterator *t = Transliterator::createInstance(id, UTRANS_FORWARD, pe, ec);
if (U_FAILURE(ec)) {
- errln((UnicodeString)"FAIL: Could not create " + id);
+ errln((UnicodeString)"FAIL: Could not create " + id + " - " + u_errorName(ec));
delete t;
return;
}
void TransliteratorTest::reportParseError(const UnicodeString& message,
const UParseError& parseError,
const UErrorCode& status) {
- errln(message +
+ dataerrln(message +
/*", parse error " + parseError.code +*/
", line " + parseError.line +
", offset " + parseError.offset +
if (pass) {
logln(UnicodeString("(")+tag+") " + prettify(summary));
} else {
- errln(UnicodeString("FAIL: (")+tag+") "
+ dataerrln(UnicodeString("FAIL: (")+tag+") "
+ prettify(summary)
+ ", expected " + prettify(expectedResult));
}