+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/************************************************************************
* COPYRIGHT:
- * Copyright (c) 2000-2009, 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>
"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]);
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){
dataerrln("FAIL: construction: " + dispNames[i+0] + " - " + u_errorName(status));
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){
dataerrln("FAIL: construction: " + Data[i+0] + " Error: " + u_errorName(status));
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){
dataerrln("FAIL: construction: " + prettify(Data2[i+0]) + " - " + u_errorName(status));
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] + " -> ";
- UChar c=Data[i+0].charAt(0);
- t->transliterate(s, index, c, status);
- if(U_FAILURE(status))
+ if (Data[i+0] != "") {
+ log = s + " + " + Data[i+0] + " -> ";
+ UChar c=Data[i+0].charAt(0);
+ t->transliterate(s, index, c, status);
+ if(U_FAILURE(status)) {
errln("FAIL: " + t->getID()+ ".transliterate(Replaceable, int32_t[], UChar, UErrorCode)-->" + (UnicodeString)u_errorName(status));
continue;
- }else {
+ }
+ } else {
log = s + " => ";
t->finishTransliteration(s, index);
- }
+ }
// Show the start index '{' and the cursor '|'
displayOutput(s, Data[i+1], log, index);
}
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]);
*/
class TestFilter1 : public UnicodeFilter {
UClassID getDynamicClassID()const { return &gTestFilter1ClassID; }
- virtual UnicodeFunctor* clone() const {
+ virtual TestFilter1* clone() const {
return new TestFilter1(*this);
}
virtual UBool contains(UChar32 c) const {
};
class TestFilter2 : public UnicodeFilter {
UClassID getDynamicClassID()const { return &gTestFilter2ClassID; }
- virtual UnicodeFunctor* clone() const {
+ virtual TestFilter2* clone() const {
return new TestFilter2(*this);
}
virtual UBool contains(UChar32 c) const {
};
class TestFilter3 : public UnicodeFilter {
UClassID getDynamicClassID()const { return &gTestFilter3ClassID; }
- virtual UnicodeFunctor* clone() const {
+ virtual TestFilter3* clone() const {
return new TestFilter3(*this);
}
virtual UBool contains(UChar32 c) const {
// transliterator, just to verify that they don't fail in some
// destructive way.
//
-#define CEASSERT(a) {if (!(a)) { \
-errln("FAIL at line %d from line %d: %s", __LINE__, line, #a); return; }}
+#define CEASSERT(a) UPRV_BLOCK_MACRO_BEGIN { \
+ if (!(a)) { \
+ errln("FAIL at line %d from line %d: %s", __LINE__, line, #a); \
+ return; \
+ } \
+} UPRV_BLOCK_MACRO_END
void TransliteratorAPITest::callEverything(const Transliterator *tr, int line) {
Transliterator *clonedTR = tr->clone();
public:
virtual UnicodeFunctor* clone() const {return NULL;}
static UClassID getStaticClassID(void) {return (UClassID)&MyUnicodeFunctorTestClassID;}
- virtual UClassID getDynamicClassID(void) const {return getStaticClassID();};
+ virtual UClassID getDynamicClassID(void) const {return getStaticClassID();}
virtual void setData(const TransliterationRuleData*) {}
};