+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/************************************************************************
* COPYRIGHT:
- * Copyright (c) 2000-2008, International Business Machines Corporation
+ * Copyright (c) 2000-2016, International Business Machines Corporation
* and others. All Rights Reserved.
************************************************************************/
/************************************************************************
#include "unicode/translit.h"
#include "unicode/unifilt.h"
#include "cpdtrans.h"
+#include "cmemory.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
UErrorCode status = U_ZERO_ERROR;
Transliterator* t= Transliterator::createInstance(trans, UTRANS_FORWARD, parseError, status);
if(t==0 || U_FAILURE(status)){
- errln("FAIL: construction of Latin-Greek");
+ dataerrln("FAIL: construction of Latin-Greek - %s",u_errorName(status));
return;
}else{
ID= t->getID();
Transliterator* t2 = Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status);
Transliterator* invt2 = Transliterator::createInstance("Devanagari-Latin", UTRANS_FORWARD, parseError, status);
if(t1 == 0 || invt1 == 0 || t2 == 0 || invt2 == 0) {
- errln("FAIL: in instantiation");
+ dataerrln("FAIL: in instantiation - %s", u_errorName(status));
return;
}
"Any-Hex",
"Hex-Any"
};
- for(uint32_t i=0; i<sizeof(TransID)/sizeof(TransID[0]); i=i+2){
+ for(uint32_t i=0; i<UPRV_LENGTHOF(TransID); i=i+2){
Transliterator *trans1=Transliterator::createInstance(TransID[i], UTRANS_FORWARD, parseError, status);
if(t1 == 0){
errln("FAIL: in instantiation for" + TransID[i]);
t1=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status);
t2=Transliterator::createInstance("Latin-Greek", UTRANS_FORWARD, parseError, status);
if(t1 == 0 || t2 == 0){
- errln("FAIL: construction");
+ dataerrln("FAIL: construction - %s", u_errorName(status));
return;
}
t3=t1->clone();
return;
#else
- for (uint32_t i=0; i<sizeof(dispNames)/sizeof(dispNames[0]); i=i+2 ) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(dispNames); i=i+2 ) {
t = Transliterator::createInstance(dispNames[i+0], UTRANS_FORWARD, parseError, status);
if(t==0){
- errln("FAIL: construction: " + dispNames[i+0]);
+ dataerrln("FAIL: construction: " + dispNames[i+0] + " - " + u_errorName(status));
status = U_ZERO_ERROR;
continue;
}
UErrorCode status = U_ZERO_ERROR;
UParseError parseError;
- for(uint32_t i=0;i<sizeof(Data)/sizeof(Data[0]); i=i+3){
+ for(uint32_t i=0;i<UPRV_LENGTHOF(Data); i=i+3){
t=Transliterator::createInstance(Data[i+0], UTRANS_FORWARD, parseError, status);
if(t==0){
- errln("FAIL: construction: " + Data[i+0] + " Error: " + u_errorName(status));
- errln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
+ dataerrln("FAIL: construction: " + Data[i+0] + " Error: " + u_errorName(status));
+ dataerrln("PreContext: " + prettify(parseError.preContext) + " PostContext: " + prettify( parseError.postContext) );
status = U_ZERO_ERROR;
continue;
}
UErrorCode status = U_ZERO_ERROR;
UParseError parseError;
- for(uint32_t i=0; i<sizeof(Data2)/sizeof(Data2[0]); i=i+6){
+ for(uint32_t i=0; i<UPRV_LENGTHOF(Data2); i=i+6){
t=Transliterator::createInstance(Data2[i+0], UTRANS_FORWARD, parseError, status);
if(t==0){
- errln("FAIL: construction: " + prettify(Data2[i+0]));
+ dataerrln("FAIL: construction: " + prettify(Data2[i+0]) + " - " + u_errorName(status));
continue;
}
start=getInt(Data2[i+2]);
if(t == 0)
errln("FAIL : construction");
- for(uint32_t i=0; i<sizeof(Data)/sizeof(Data[0]); i=i+3){
+ for(uint32_t i=0; i<UPRV_LENGTHOF(Data); i=i+3){
start=getInt(Data[i+0]);
limit=getInt(Data[i+1]);
t->transliterate(rs, start, limit);
{-1, 16, 14, 16}, //invalid since START<0
{3, 50, 2, 50} //invalid since LIMIT>text.length()
};
- for(uint32_t i=0; i<sizeof(index1)/sizeof(index1[0]); i++){
+ for(uint32_t i=0; i<UPRV_LENGTHOF(index1); i++){
status=U_ZERO_ERROR;
t->transliterate(rs, index1[i], insertion, status);
if(status == U_ILLEGAL_ARGUMENT_ERROR)
status=U_ZERO_ERROR;
index.contextStart = index.contextLimit = index.start = index.limit = 0;
logln("Testing transliterate(Replaceable, int32_t, UChar, UErrorCode)");
- for(i=10; i<sizeof(Data)/sizeof(Data[0]); i=i+2){
+ for(i=10; i<UPRV_LENGTHOF(Data); i=i+2){
UnicodeString log;
if (Data[i+0] != "") {
log = s + " + " + Data[i+0] + " -> ";
rs="Initial String: add--";
t=Transliterator::createInstance("Any-Hex", UTRANS_FORWARD, parseError, status);
if(t == 0)
- errln("FAIL : construction");
+ dataerrln("FAIL : construction - %s", u_errorName(status));
else {
keyboardAux(t, Data, rs, 0, 20);
delete t;
rs="Hindi --";
t=Transliterator::createInstance("Latin-Devanagari", UTRANS_FORWARD, parseError, status);
if(t == 0)
- errln("FAIL : construction");
+ dataerrln("FAIL : construction - %s", u_errorName(status));
else
keyboardAux(t, Data, rs, 20, 40);
delete t;
return;
}
- for(uint32_t i=0; i<sizeof(Data)/sizeof(Data[0]); i=i+4){
+ for(uint32_t i=0; i<UPRV_LENGTHOF(Data); i=i+4){
UnicodeString log;
index.contextStart=getInt(Data[i+0]);
index.contextLimit=index.limit=getInt(Data[i+1]);
if (prettify(result) == prettify(expected))
logln((UnicodeString)"Ok: " + prettify(message) + " passed \"" + prettify(expected) + "\"");
else
- errln((UnicodeString)"FAIL:" + message + " failed Got-->" + prettify(result)+ ", Expected--> " + prettify(expected) );
+ dataerrln((UnicodeString)"FAIL:" + message + " failed Got-->" + prettify(result)+ ", Expected--> " + prettify(expected) );
}