/*
********************************************************************************
-* Copyright (C) 1999-2010 International Business Machines Corporation and
+* Copyright (C) 1999-2014 International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************************
* Date Name Description
#include "unicode/uversion.h"
#include "hash.h"
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
dataerrln("fail in file \"%s\", line %d: \"%s\"", __FILE__, __LINE__, \
u_errorName(status));}}
// Script_Extensions, new in Unicode 6.0
"[:scx=Arab:]",
"\\u061E\\u061F\\u0620\\u0621\\u063F\\u0640\\u0650\\u065E\\uFDF1\\uFDF2\\uFDF3",
- "\\u061D\\u065F\\uFDEF\\uFDFE",
+ "\\u061D\\uFDEF\\uFDFE",
// U+FDF2 has Script=Arabic and also Arab in its Script_Extensions,
// so scx-sc is missing U+FDF2.
"[[:Script_Extensions=Arabic:]-[:Arab:]]",
- "\\u0640\\u064B\\u0650\\u0655\\uFDFD",
+ "\\u0640\\u064B\\u0650\\u0655",
"\\uFDF2"
};
const char exp[] =
"[\\u200A-\\u200E\\uFEFF\\U0001D173-\\U0001D17A\\U000F0000-\\U000FFFFD]";
// We test this with two passes; in the second pass we
- // pre-unescape the pattern. Since U+200E is rule whitespace,
+ // pre-unescape the pattern. Since U+200E is Pattern_White_Space,
// this fails -- which is what we expect.
for (int32_t pass=1; pass<=2; ++pass) {
UErrorCode ec = U_ZERO_ERROR;
b = set.contains(start, end);
b = set.containsNone(start, end);
b = set.containsSome(start, end);
+ (void)b; // Suppress set but not used warning.
/*int32_t index = set.indexOf(start);*/
Hashtable contents;
TokenSymbolTable(UErrorCode& ec) : contents(FALSE, ec) {
- contents.setValueDeleter(uhash_deleteUnicodeString);
+ contents.setValueDeleter(uprv_deleteUObject);
}
~TokenSymbolTable() {}
const UnicodeString *s;
char *s8=utf8;
int32_t length8, utf8Count=0;
- while(iter.nextRange() && stringsLength<LENGTHOF(strings)) {
+ while(iter.nextRange() && stringsLength<UPRV_LENGTHOF(strings)) {
if(iter.isString()) {
// Store the pointer to the set's string element
// which we happen to know is a stable pointer.
char utf8[1024];
int32_t utf8Lengths[20];
-
- int32_t nextStringIndex;
- int32_t nextUTF8Start;
};
class UnicodeSetWithStringsIterator {
UChar32 c;
int32_t start=0, prev;
while((prev=start)<length) {
- U8_NEXT(s, start, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_NEXT_OR_FFFD(s, start, length, c);
if(realSet.contains(c)!=spanCondition) {
break;
}
UChar32 c;
int32_t start, next;
for(start=next=0; start<length;) {
- U8_NEXT(s, next, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_NEXT_OR_FFFD(s, next, length, c);
if(realSet.contains(c)) {
break;
}
UChar32 c;
int32_t start, next, maxSpanLimit=0;
for(start=next=0; start<length;) {
- U8_NEXT(s, next, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_NEXT_OR_FFFD(s, next, length, c);
if(!realSet.contains(c)) {
next=start; // Do not span this single, not-contained code point.
}
UChar32 c;
int32_t prev=length;
do {
- U8_PREV(s, 0, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_PREV_OR_FFFD(s, 0, length, c);
if(realSet.contains(c)!=spanCondition) {
break;
}
UChar32 c;
int32_t prev=length;
do {
- U8_PREV(s, 0, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_PREV_OR_FFFD(s, 0, length, c);
if(realSet.contains(c)) {
break;
}
UChar32 c;
int32_t prev=length, minSpanStart=length;
do {
- U8_PREV(s, 0, length, c);
- if(c<0) {
- c=0xfffd;
- }
+ U8_PREV_OR_FFFD(s, 0, length, c);
if(!realSet.contains(c)) {
length=prev; // Do not span this single, not-contained code point.
}
s, length, isUTF16,
whichSpans,
type, typeName,
- limits, LENGTHOF(limits), expectCount);
+ limits, UPRV_LENGTHOF(limits), expectCount);
if(typeName[0]==0) {
break; // All types tried.
}
}
if(expectCount<0) {
expectCount=limitsCount;
- if(limitsCount>LENGTHOF(limits)) {
+ if(limitsCount>UPRV_LENGTHOF(limits)) {
errln("FAIL: %s[0x%lx].%s.%s span count=%ld > %ld capacity - too many spans",
- testName, (long)index, setNames[i], typeName, (long)limitsCount, (long)LENGTHOF(limits));
+ testName, (long)index, setNames[i], typeName, (long)limitsCount, (long)UPRV_LENGTHOF(limits));
return;
}
memcpy(expectLimits, limits, limitsCount*4);
UChar32 c, first;
for(first=c=0;; c=nextCodePoint(c)) {
- if(c>0x10ffff || length>(LENGTHOF(s)-U16_MAX_LENGTH)) {
+ if(c>0x10ffff || length>(UPRV_LENGTHOF(s)-U16_MAX_LENGTH)) {
localWhichSpans=whichSpans;
if(stringContainsUnpairedSurrogate(s, length) && inconsistentSurrogates) {
localWhichSpans&=~SPAN_UTF8;
return;
}
testSpan(sets, s, -1, TRUE, (whichSpans&~SPAN_UTF8), testName, 0);
- testSpan(sets, s, LENGTHOF(s)-1, TRUE, (whichSpans&~SPAN_UTF8), testName, 1);
+ testSpan(sets, s, UPRV_LENGTHOF(s)-1, TRUE, (whichSpans&~SPAN_UTF8), testName, 1);
}
void UnicodeSetTest::testSpanUTF8String(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName) {
return;
}
testSpan(sets, s, -1, FALSE, (whichSpans&~SPAN_UTF16), testName, 0);
- testSpan(sets, s, LENGTHOF(s)-1, FALSE, (whichSpans&~SPAN_UTF16), testName, 1);
+ testSpan(sets, s, UPRV_LENGTHOF(s)-1, FALSE, (whichSpans&~SPAN_UTF16), testName, 1);
}
// Take a set of span options and multiply them so that
char *testNameLimit=testName;
int32_t i, j;
- for(i=0; i<LENGTHOF(testdata); ++i) {
+ for(i=0; i<UPRV_LENGTHOF(testdata); ++i) {
const char *s=testdata[i];
if(s[0]=='[') {
// Create new test sets from this pattern.
string16=UNICODE_STRING_SIMPLE("byayaxya");
const UChar *s16=string16.getBuffer();
int32_t length16=string16.length();
+ (void)length16; // Suppress set but not used warning.
if( set.span(s16, 8, USET_SPAN_NOT_CONTAINED)!=4 ||
set.span(s16, 7, USET_SPAN_NOT_CONTAINED)!=4 ||
set.span(s16, 6, USET_SPAN_NOT_CONTAINED)!=4 ||