ICU-12012 Replace all sizeof p / sizeof T with UPRV_LENGTHOF().

R=markus.icu@gmail.com

Review URL: https://codereview.appspot.com/288320043 .

X-SVN-Rev: 38347
This commit is contained in:
Fredrik Roubert 2016-02-24 21:48:56 +00:00
parent f2186b6d33
commit ebc0f5b22a
24 changed files with 78 additions and 76 deletions

View file

@ -908,7 +908,7 @@ static const ILcidPosixMap gPosixIDmap[] = {
ILCID_POSIX_MAP(zu), /* zu Zulu 0x35 */
};
static const uint32_t gLocaleCount = sizeof(gPosixIDmap)/sizeof(ILcidPosixMap);
static const uint32_t gLocaleCount = UPRV_LENGTHOF(gPosixIDmap);
/**
* Do not call this function. It is called by hostID.

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 1998-2015, International Business Machines
* Copyright (C) 1998-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -2646,7 +2646,7 @@ static const UAmbiguousConverter *ucnv_getAmbiguous(const UConverter *cnv)
return NULL;
}
for(i=0; i<(int32_t)(sizeof(ambiguousConverters)/sizeof(UAmbiguousConverter)); ++i)
for(i=0; i<UPRV_LENGTHOF(ambiguousConverters); ++i)
{
if(0==uprv_strcmp(name, ambiguousConverters[i].name))
{

View file

@ -3,8 +3,8 @@
//
/*
***************************************************************************
* Copyright (C) 2002-2015 International Business Machines Corporation *
* and others. All rights reserved. *
* Copyright (C) 2002-2016 International Business Machines Corporation
* and others. All rights reserved.
***************************************************************************
*/
@ -14,6 +14,7 @@
#include "unicode/regex.h"
#include "unicode/uclean.h"
#include "cmemory.h"
#include "cstr.h"
#include "uassert.h"
#include "uhash.h"
@ -690,7 +691,7 @@ void RegexPattern::dumpOp(int32_t index) const {
int32_t val = URX_VAL(op);
int32_t type = URX_TYPE(op);
int32_t pinnedType = type;
if ((uint32_t)pinnedType >= sizeof(opNames)/sizeof(char *)) {
if ((uint32_t)pinnedType >= UPRV_LENGTHOF(opNames)) {
pinnedType = 0;
}

View file

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2008-2015, International Business Machines
* Copyright (C) 2008-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
@ -356,7 +356,7 @@ const char * SpoofImpl::getAllowedLocales(UErrorCode &/*status*/) {
void SpoofImpl::addScriptChars(const char *locale, UnicodeSet *allowedChars, UErrorCode &status) {
UScriptCode scripts[30];
int32_t numScripts = uscript_getCode(locale, scripts, sizeof(scripts)/sizeof(UScriptCode), &status);
int32_t numScripts = uscript_getCode(locale, scripts, UPRV_LENGTHOF(scripts), &status);
if (U_FAILURE(status)) {
return;
}

View file

@ -215,7 +215,7 @@ u_printf_string_handler(const u_printf_stream_handler *handler,
}
else {
s = ufmt_defaultCPToUnicode(arg, argSize, buffer,
sizeof(buffer)/sizeof(UChar));
UPRV_LENGTHOF(buffer));
}
}
else {
@ -251,7 +251,7 @@ u_printf_char_handler(const u_printf_stream_handler *handler,
unsigned char arg = (unsigned char)(args[0].int64Value);
/* convert from default codepage to Unicode */
ufmt_defaultCPToUnicode((const char *)&arg, 2, s, sizeof(s)/sizeof(UChar));
ufmt_defaultCPToUnicode((const char *)&arg, 2, s, UPRV_LENGTHOF(s));
/* Remember that this may be an MBCS character */
if (arg != 0) {

View file

@ -264,7 +264,7 @@ static void TestCalendar()
/*Testing ucal_getCanonicalTimeZoneID*/
status = U_ZERO_ERROR;
resultlength = ucal_getCanonicalTimeZoneID(PST, -1,
canonicalID, sizeof(canonicalID)/sizeof(UChar), &isSystemID, &status);
canonicalID, UPRV_LENGTHOF(canonicalID), &isSystemID, &status);
if (U_FAILURE(status)) {
log_data_err("FAIL: error in ucal_getCanonicalTimeZoneID : %s\n", u_errorName(status));
} else {

View file

@ -1893,7 +1893,7 @@ static void TestCCSID() {
int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
int32_t i, ccsid;
for(i=0; i<(int32_t)(sizeof(ccsids)/sizeof(int32_t)); ++i) {
for(i=0; i<UPRV_LENGTHOF(ccsids); ++i) {
ccsid=ccsids[i];
errorCode=U_ZERO_ERROR;

View file

@ -3211,7 +3211,7 @@ static void TestGetLocaleForLCID() {
status = U_ZERO_ERROR;
}
length = uloc_getLocaleForLCID(lcid, temp2, sizeof(temp2)/sizeof(char), &status);
length = uloc_getLocaleForLCID(lcid, temp2, UPRV_LENGTHOF(temp2), &status);
if (U_FAILURE(status)) {
log_err(" unexpected result from uloc_getLocaleForLCID(0x0409): %s\n", u_errorName(status));
status = U_ZERO_ERROR;
@ -3221,7 +3221,7 @@ static void TestGetLocaleForLCID() {
log_err(" uloc_getLocaleForLCID(0x0409): returned length %d does not match preflight length %d\n", length, lengthPre);
}
length = uloc_getLocaleForLCID(0x12345, temp2, sizeof(temp2)/sizeof(char), &status);
length = uloc_getLocaleForLCID(0x12345, temp2, UPRV_LENGTHOF(temp2), &status);
if (U_SUCCESS(status)) {
log_err(" unexpected result from uloc_getLocaleForLCID(0x12345): %s, status %s\n", temp2, u_errorName(status));
}
@ -3235,7 +3235,7 @@ static void TestGetLocaleForLCID() {
log_verbose("Testing %s ......\n", testLocale);
sscanf(rawData2[LCID][i], "%x", &lcid);
length = uloc_getLocaleForLCID(lcid, temp2, sizeof(temp2)/sizeof(char), &status);
length = uloc_getLocaleForLCID(lcid, temp2, UPRV_LENGTHOF(temp2), &status);
if (U_FAILURE(status)) {
log_err(" unexpected failure of uloc_getLocaleForLCID(%#04x), status %s\n", lcid, u_errorName(status));
status = U_ZERO_ERROR;
@ -3247,7 +3247,7 @@ static void TestGetLocaleForLCID() {
}
/* Compare language, country, script */
length = uloc_getLanguage(temp2, temp3, sizeof(temp3)/sizeof(char), &status);
length = uloc_getLanguage(temp2, temp3, UPRV_LENGTHOF(temp3), &status);
if (U_FAILURE(status)) {
log_err(" couldn't get language in uloc_getLocaleForLCID(%#04x) = %s, status %s\n", lcid, temp2, u_errorName(status));
status = U_ZERO_ERROR;
@ -3256,7 +3256,7 @@ static void TestGetLocaleForLCID() {
log_err(" language doesn't match expected %s in in uloc_getLocaleForLCID(%#04x) = %s\n", rawData2[LANG][i], lcid, temp2);
}
length = uloc_getScript(temp2, temp3, sizeof(temp3)/sizeof(char), &status);
length = uloc_getScript(temp2, temp3, UPRV_LENGTHOF(temp3), &status);
if (U_FAILURE(status)) {
log_err(" couldn't get script in uloc_getLocaleForLCID(%#04x) = %s, status %s\n", lcid, temp2, u_errorName(status));
status = U_ZERO_ERROR;
@ -3265,7 +3265,7 @@ static void TestGetLocaleForLCID() {
log_err(" script doesn't match expected %s in in uloc_getLocaleForLCID(%#04x) = %s\n", rawData2[SCRIPT][i], lcid, temp2);
}
length = uloc_getCountry(temp2, temp3, sizeof(temp3)/sizeof(char), &status);
length = uloc_getCountry(temp2, temp3, UPRV_LENGTHOF(temp3), &status);
if (U_FAILURE(status)) {
log_err(" couldn't get country in uloc_getLocaleForLCID(%#04x) = %s, status %s\n", lcid, temp2, u_errorName(status));
status = U_ZERO_ERROR;

View file

@ -1,5 +1,5 @@
/********************************************************************
* Copyright (c) 1997-2015, International Business Machines
* Copyright (c) 1997-2016, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************/
@ -125,11 +125,11 @@ void TestUScriptCodeAPI(){
err = U_ZERO_ERROR;
capacity = 10;
num = uscript_getCode("ja",script,capacity, &err);
if(num!=(sizeof(jaCode)/sizeof(UScriptCode))){
if(num!=UPRV_LENGTHOF(jaCode)){
log_err("Errors uscript_getScriptCode() for Japanese locale: num=%d, expected %d \n",
num, (sizeof(jaCode)/sizeof(UScriptCode)));
num, UPRV_LENGTHOF(jaCode));
}
for(j=0;j<sizeof(jaCode)/sizeof(UScriptCode);j++) {
for(j=0;j<UPRV_LENGTHOF(jaCode);j++) {
if(script[j]!=jaCode[j]) {
log_err("Japanese locale: code #%d was %d (%s) but expected %d (%s)\n", j,
script[j], uscript_getName(script[j]),
@ -204,7 +204,7 @@ void TestUScriptCodeAPI(){
NULL
};
i=0;
while(i<sizeof(testAbbr)/sizeof(UScriptCode)){
while(i<UPRV_LENGTHOF(testAbbr)){
const char* name = uscript_getName(testAbbr[i]);
if(name == NULL) {
log_data_err("Couldn't get script name\n");
@ -243,7 +243,7 @@ void TestUScriptCodeAPI(){
NULL
};
i=0;
while(i<sizeof(testAbbr)/sizeof(UScriptCode)){
while(i<UPRV_LENGTHOF(testAbbr)){
const char* name = uscript_getShortName(testAbbr[i]);
numErrors=0;
if(strcmp(expectedAbbr[i],name)!=0){

View file

@ -230,7 +230,7 @@ static void TestStringFunctions()
if(temp[k] != 0xa4)
log_err("something threw an error in u_strncpy()\n");
u_memset(temp, 0x3F, (sizeof(temp) / sizeof(UChar)) - 1);
u_memset(temp, 0x3F, UPRV_LENGTHOF(temp) - 1);
u_uastrncpy(temp, raw[i][j], k-1);
if(u_strncmp(temp, dataTable[i][j],k-1)!=0)
log_err("something threw an error in u_uastrncpy(k-1)\n");
@ -238,7 +238,7 @@ static void TestStringFunctions()
if(temp[k-1] != 0x3F)
log_err("something threw an error in u_uastrncpy(k-1)\n");
u_memset(temp, 0x3F, (sizeof(temp) / sizeof(UChar)) - 1);
u_memset(temp, 0x3F, UPRV_LENGTHOF(temp) - 1);
u_uastrncpy(temp, raw[i][j], k+1);
if(u_strcmp(temp, dataTable[i][j])!=0)
log_err("something threw an error in u_uastrncpy(k+1)\n");
@ -246,7 +246,7 @@ static void TestStringFunctions()
if(temp[k] != 0)
log_err("something threw an error in u_uastrncpy(k+1)\n");
u_memset(temp, 0x3F, (sizeof(temp) / sizeof(UChar)) - 1);
u_memset(temp, 0x3F, UPRV_LENGTHOF(temp) - 1);
u_uastrncpy(temp, raw[i][j], k);
if(u_strncmp(temp, dataTable[i][j], k)!=0)
log_err("something threw an error in u_uastrncpy(k)\n");

View file

@ -1663,7 +1663,7 @@ TestSignatureDetection(){
int32_t signatureLength = -1;
const char* source = NULL;
const char* enc = NULL;
for( ; i<sizeof(data)/sizeof(char*); i++){
for( ; i<UPRV_LENGTHOF(data); i++){
err = U_ZERO_ERROR;
source = data[i];
enc = ucnv_detectUnicodeSignature(source, -1 , &signatureLength, &err);
@ -1776,7 +1776,7 @@ TestSignatureDetection(){
int32_t sourceLength=-1;
const char* source = NULL;
const char* enc = NULL;
for( ; i<sizeof(data)/sizeof(char*); i++){
for( ; i<UPRV_LENGTHOF(data); i++){
err = U_ZERO_ERROR;
source = data[i];
sourceLength = len[i];
@ -4908,7 +4908,7 @@ TestLMBCS() {
UChar Out [sizeof(pszUnicode) + 1];
UChar * pOut = Out;
UChar * OutLimit = Out + sizeof(pszUnicode)/sizeof(UChar);
UChar * OutLimit = Out + UPRV_LENGTHOF(pszUnicode);
int32_t off [sizeof(offsets)];
@ -5078,7 +5078,7 @@ TestLMBCS() {
UChar Out [sizeof(pszUnicode) + 1];
UChar * pOut = Out;
UChar * OutLimit = Out + sizeof(pszUnicode)/sizeof(UChar);
UChar * OutLimit = Out + UPRV_LENGTHOF(pszUnicode);
cnv = ucnv_open(NAME_LMBCS_1, &errorCode);
@ -5187,7 +5187,7 @@ TestLMBCS() {
/* running out of target room : U_BUFFER_OVERFLOW_ERROR */
pUIn = pszUnicode;
ucnv_fromUnicode(cnv, &pLOut,pLOut+offsets[4],&pUIn,pUIn+sizeof(pszUnicode)/sizeof(UChar),off,FALSE, &errorCode);
ucnv_fromUnicode(cnv, &pLOut,pLOut+offsets[4],&pUIn,pUIn+UPRV_LENGTHOF(pszUnicode),off,FALSE, &errorCode);
if (errorCode != U_BUFFER_OVERFLOW_ERROR || pLOut != LOut + offsets[4] || pUIn != pszUnicode+4 )
{
log_err("Unexpected results on out of target room to ucnv_fromUnicode\n");
@ -5215,7 +5215,7 @@ TestLMBCS() {
pUOut = UOut;
ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 5)
{
log_err("Unexpected results on chopped low surrogate\n");
@ -5229,7 +5229,7 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
pUOut = UOut;
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+3),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+3),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || U_FAILURE(errorCode) || pUOut != UOut + 1 || pLIn != LIn + 3)
{
log_err("Unexpected results on chopped at surrogate boundary \n");
@ -5246,7 +5246,7 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
pUOut = UOut;
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+6),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+6),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || UOut[1] != 0xC9D0 || U_FAILURE(errorCode) || pUOut != UOut + 2 || pLIn != LIn + 6)
{
log_err("Unexpected results after unpaired surrogate plus valid Unichar \n");
@ -5263,7 +5263,7 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
pUOut = UOut;
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 5)
{
log_err("Unexpected results after unpaired surrogate plus chopped Unichar \n");
@ -5280,7 +5280,7 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
pUOut = UOut;
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || UOut[1] != 0x1B || U_FAILURE(errorCode) || pUOut != UOut + 2 || pLIn != LIn + 5)
{
log_err("Unexpected results after unpaired surrogate plus valid non-Unichar\n");
@ -5296,7 +5296,7 @@ TestLMBCS() {
errorCode = U_ZERO_ERROR;
pUOut = UOut;
ucnv_toUnicode(cnv, &pUOut,pUOut+sizeof(UOut)/sizeof(UChar),(const char **)&pLIn,(const char *)(pLIn+4),off,TRUE, &errorCode);
ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+4),off,TRUE, &errorCode);
if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 4)
{

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 2009-2015, International Business Machines Corporation and
* COPYRIGHT:
* Copyright (c) 2009-2016, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@ -27,6 +27,7 @@
#include "unicode/ustring.h"
#include "unicode/uset.h"
#include "cintltst.h"
#include "cmemory.h"
#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \
log_err_status(status, "Failure at file %s, line %d, error = %s\n", __FILE__, __LINE__, u_errorName(status));}}
@ -521,13 +522,13 @@ static void TestUSpoofCAPI(void) {
UChar dest[100];
int32_t skelLength;
skelLength = uspoof_getSkeleton(sc, USPOOF_ANY_CASE, lll_Latin_a, -1, dest, sizeof(dest)/sizeof(UChar), &status);
skelLength = uspoof_getSkeleton(sc, USPOOF_ANY_CASE, lll_Latin_a, -1, dest, UPRV_LENGTHOF(dest), &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_EQ(0, u_strcmp(lll_Skel, dest));
TEST_ASSERT_EQ(u_strlen(lll_Skel), skelLength);
skelLength = uspoof_getSkeletonUTF8(sc, USPOOF_ANY_CASE, goodLatinUTF8, -1, (char*)dest,
sizeof(dest)/sizeof(UChar), &status);
UPRV_LENGTHOF(dest), &status);
TEST_ASSERT_SUCCESS(status);
skelLength = uspoof_getSkeleton(sc, USPOOF_ANY_CASE, lll_Latin_a, -1, NULL, 0, &status);

View file

@ -1,5 +1,5 @@
/********************************************************************
* Copyright (c) 2001-2011,2015,2016 International Business Machines
* Copyright (c) 2001-2016 International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************
* File usrchtst.c
@ -2896,8 +2896,8 @@ static void TestPCEBuffer_100df(void) {
{ 0x0020, 0x0020, 0x00df, 0x0020, 0x0041, 0x00df, 0x0020, 0x0061, 0x00df, 0x0020, 0x00c5, 0x00df, 0x0020, 0x212b, 0x00df, 0x0020, 0x0041, 0x030a, 0x00df, 0x0020, 0x00e5, 0x00df, 0x0020, 0x0061, 0x02da, 0x00df, 0x0020, 0x0061, 0x030a, 0x00df, 0x0020, 0xd8fa, 0xdeae, 0x00df, 0x0020, 0x2027, 0x00df }; /* 38 cp, 9 of them unpaired surrogates */
UChar source[] =
{ 0x0020, 0x0020, 0x00df, 0x0020, 0x0041, 0x00df, 0x0020, 0x0061, 0x00df, 0x0020, 0x00c5, 0x00df, 0x0020, 0x212b, 0x00df, 0x0020, 0x0041, 0x030a, 0x00df, 0x0020, 0x00e5, 0x00df, 0x0020, 0x0061, 0x02da, 0x00df, 0x0020, 0x0061, 0x030a, 0x00df, 0x0020, 0xd8fa, 0xdeae, 0x00df, 0x0020, 0x2027, 0x00df };
uint32_t searchLen = sizeof(search)/sizeof(UChar);
uint32_t sourceLen = sizeof(source)/sizeof(UChar);
uint32_t searchLen = UPRV_LENGTHOF(search);
uint32_t sourceLen = UPRV_LENGTHOF(source);
TestPCEBuffer_with(search,searchLen,source,sourceLen);
}
@ -2907,8 +2907,8 @@ static void TestPCEBuffer_2surr(void) {
{ 0x0020, 0x0020, 0xdfff, 0x0020, 0x0041, 0xdfff, 0x0020, 0x0061, 0xdfff, 0x0020, 0x00c5, 0xdfff, 0x0020, 0x212b, 0xdfff, 0x0020, 0x0041, 0x030a, 0xdfff, 0x0020, 0x00e5, 0xdfff, 0x0020, 0x0061, 0x02da, 0xdfff, 0x0020, 0x0061, 0x030a, 0xdfff, 0x0020, 0xd8fa, 0xdeae, 0xdfff, 0x0020, 0x2027, 0xdfff }; /* 38 cp, 9 of them unpaired surrogates */
UChar source[] =
{ 0x0020, 0x0020, 0xdfff, 0x0020, 0x0041, 0xdfff, 0x0020, 0x0061, 0xdfff, 0x0020, 0x00c5, 0xdfff, 0x0020, 0x212b, 0xdfff, 0x0020, 0x0041, 0x030a, 0xdfff, 0x0020, 0x00e5, 0xdfff, 0x0020, 0x0061, 0x02da, 0xdfff, 0x0020, 0x0061, 0x030a, 0xdfff, 0x0020, 0xd8fa, 0xdeae, 0xdfff, 0x0020, 0x2027, 0xdfff };
uint32_t searchLen = sizeof(search)/sizeof(UChar);
uint32_t sourceLen = sizeof(source)/sizeof(UChar);
uint32_t searchLen = UPRV_LENGTHOF(search);
uint32_t sourceLen = UPRV_LENGTHOF(source);
TestPCEBuffer_with(search,searchLen,source,sourceLen);
}
@ -2927,8 +2927,8 @@ static void TestMatchFollowedByIgnorables(void) {
int32_t matchLength = 0;
const int32_t expectedMatchLength = 1;
searchLen = sizeof(search)/sizeof(UChar);
sourceLen = sizeof(source)/sizeof(UChar);
searchLen = UPRV_LENGTHOF(search);
sourceLen = UPRV_LENGTHOF(source);
coll = ucol_openFromShortString("LHR_AN_CX_EX_FX_HX_NX_S3",
FALSE,

View file

@ -672,7 +672,7 @@ ICUServiceTest::testAPI_Two()
"en_US_SURFER_GAL",
"en_US_SURFER_DUDE"
};
int32_t count = sizeof(xids)/sizeof(UnicodeString);
int32_t count = UPRV_LENGTHOF(xids);
ICUServiceFactory* f = new TestMultipleKeyStringFactory(xids, count, "Later");
service.registerFactory(f, status);
@ -730,7 +730,7 @@ ICUServiceTest::testAPI_Two()
"en_US_SILICON",
"en_US_SILICON_GEEK",
};
int32_t count = sizeof(xids)/sizeof(UnicodeString);
int32_t count = UPRV_LENGTHOF(xids);
ICUServiceFactory* f = new TestMultipleKeyStringFactory(xids, count, "Rad dude");
service.registerFactory(f, status);

View file

@ -1896,7 +1896,7 @@ IntlTestRBNF::TestAllLocales()
continue;
}
#if !UCONFIG_NO_COLLATION
for (unsigned int numidx = 0; numidx < sizeof(numbers)/sizeof(double); numidx++) {
for (unsigned int numidx = 0; numidx < UPRV_LENGTHOF(numbers); numidx++) {
double n = numbers[numidx];
UnicodeString str;
f->format(n, str);

View file

@ -2417,7 +2417,7 @@ void NumberFormatTest::TestSymbolsWithBadLocale(void) {
}; // expect U_USING_DEFAULT_WARNING for both
unsigned int i;
for (i = 0; i < sizeof(badLocales) / sizeof(char*); i++) {
for (i = 0; i < UPRV_LENGTHOF(badLocales); i++) {
const char *localeName = badLocales[i];
Locale locBad(localeName);
UErrorCode status = U_ZERO_ERROR;
@ -7555,7 +7555,7 @@ void NumberFormatTest::TestSignificantDigits(void) {
UnicodeString result;
UnicodeString expectedResult;
for (unsigned int i = 0; i < sizeof(input)/sizeof(double); ++i) {
for (unsigned int i = 0; i < UPRV_LENGTHOF(input); ++i) {
numberFormat->format(input[i], result);
UnicodeString expectedResult(expected[i]);
if (result != expectedResult) {

View file

@ -3732,7 +3732,7 @@ void RBBITest::TestWordBreaks(void)
errcheckln(status, "Creation of break iterator failed %s", u_errorName(status));
return;
}
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
for (loop = 0; loop < UPRV_LENGTHOF(strlist); loop ++) {
// printf("looping %d\n", loop);
UnicodeString ustr = CharsToUnicodeString(strlist[loop]);
// RBBICharMonkey monkey;
@ -3798,7 +3798,7 @@ void RBBITest::TestWordBoundary(void)
errcheckln(status, "Creation of break iterator failed %s", u_errorName(status));
return;
}
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
for (loop = 0; loop < UPRV_LENGTHOF(strlist); loop ++) {
// printf("looping %d\n", loop);
u_unescape(strlist[loop], str, 20);
UnicodeString ustr(str);
@ -3896,7 +3896,7 @@ void RBBITest::TestLineBreaks(void)
if (U_FAILURE(status)) {
return;
}
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
for (loop = 0; loop < UPRV_LENGTHOF(strlist); loop ++) {
// printf("looping %d\n", loop);
int32_t t = u_unescape(strlist[loop], str, STRSIZE);
if (t >= STRSIZE) {
@ -3966,7 +3966,7 @@ void RBBITest::TestSentBreaks(void)
errcheckln(status, "Creation of break iterator failed %s", u_errorName(status));
return;
}
for (loop = 0; loop < (int)(sizeof(strlist) / sizeof(char *)); loop ++) {
for (loop = 0; loop < UPRV_LENGTHOF(strlist); loop ++) {
u_unescape(strlist[loop], str, UPRV_LENGTHOF(str));
UnicodeString ustr(str);

View file

@ -1,7 +1,6 @@
/***********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2014, International Business Machines Corporation
* COPYRIGHT:
* Copyright (c) 1997-2016, International Business Machines Corporation
* and others. All Rights Reserved.
***********************************************************************/
@ -83,7 +82,7 @@ void test_FieldPosition_example( void )
//***** this test is for compiler checks and visual verification only.
double doubleNum[] = { 123456789.0, -12345678.9, 1234567.89, -123456.789,
12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
int32_t dNumSize = (int32_t)(sizeof(doubleNum)/sizeof(double));
int32_t dNumSize = UPRV_LENGTHOF(doubleNum);
UErrorCode status = U_ZERO_ERROR;
DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
@ -315,8 +314,8 @@ void test_Formattable( void )
const Formattable ftarr1[] = { Formattable( (int32_t)1 ), Formattable( (int32_t)2 ) };
const Formattable ftarr2[] = { Formattable( (int32_t)3 ), Formattable( (int32_t)4 ) };
const int32_t ftarr1_cnt = (int32_t)(sizeof(ftarr1) / sizeof(Formattable));
const int32_t ftarr2_cnt = (int32_t)(sizeof(ftarr2) / sizeof(Formattable));
const int32_t ftarr1_cnt = UPRV_LENGTHOF(ftarr1);
const int32_t ftarr2_cnt = UPRV_LENGTHOF(ftarr2);
ft_arr.setArray( ftarr1, ftarr1_cnt );
if ((ft_arr[0].getType() == Formattable::kLong) && (ft_arr[0].getLong() == (int32_t)1)) {

View file

@ -1058,7 +1058,7 @@ void TestMessageFormat::testFormat()
{
Formattable( UDate(8.71068e+011), Formattable::kIsDate )
};
const int32_t ft_cnt = sizeof(ftarray) / sizeof(Formattable);
const int32_t ft_cnt = UPRV_LENGTHOF(ftarray);
Formattable ft_arr( ftarray, ft_cnt );
Formattable* fmt = new Formattable(UDate(8.71068e+011), Formattable::kIsDate);

View file

@ -373,7 +373,7 @@ void TimeUnitTest::testGreekWithFallback() {
Locale l = Locale::createFromName(locales[locIndex]);
for ( unsigned int numberIndex = 0;
numberIndex < sizeof(numbers)/sizeof(int);
numberIndex < UPRV_LENGTHOF(numbers);
++numberIndex ) {
for ( unsigned int styleIndex = 0;

View file

@ -1111,7 +1111,7 @@ TimeZoneRuleTest::TestGetSimpleRules(void) {
getUTCMillis(2005, UCAL_JULY, 1),
getUTCMillis(2010, UCAL_NOVEMBER, 1),
};
int32_t numTimes = sizeof(testTimes)/sizeof(UDate);
int32_t numTimes = UPRV_LENGTHOF(testTimes);
UErrorCode status = U_ZERO_ERROR;
TestZIDEnumeration tzenum(!quick);
InitialTimeZoneRule *initial;

View file

@ -1015,7 +1015,7 @@ void UTextTest::ErrorTest()
// Check setIndex
int32_t i;
int32_t startMapLimit = sizeof(startMap) / sizeof(int32_t);
int32_t startMapLimit = UPRV_LENGTHOF(startMap);
for (i=0; i<startMapLimit; i++) {
utext_setNativeIndex(ut, i);
int64_t cpIndex = utext_getNativeIndex(ut);
@ -1086,7 +1086,7 @@ void UTextTest::ErrorTest()
UText *ut = utext_openUnicodeString(NULL, &u16str, &status);
TEST_SUCCESS(status);
int32_t startMapLimit = sizeof(startMap) / sizeof(int32_t);
int32_t startMapLimit = UPRV_LENGTHOF(startMap);
int i;
for (i=0; i<startMapLimit; i++) {
utext_setNativeIndex(ut, i);
@ -1154,7 +1154,7 @@ void UTextTest::ErrorTest()
UText *ut = utext_openReplaceable(NULL, &u16str, &status);
TEST_SUCCESS(status);
int32_t startMapLimit = sizeof(startMap) / sizeof(int32_t);
int32_t startMapLimit = UPRV_LENGTHOF(startMap);
int i;
for (i=0; i<startMapLimit; i++) {
utext_setNativeIndex(ut, i);

View file

@ -152,7 +152,7 @@ static void U_CALLCONV TestStream(void)
ostrstream outLargeStream(testLargeStreamBuf, sizeof(testLargeStreamBuf));
#endif
UChar large_array[200];
int32_t large_array_length = sizeof(large_array)/sizeof(UChar);
int32_t large_array_length = UPRV_LENGTHOF(large_array);
for (int32_t i = 0; i < large_array_length; i++) {
large_array[i] = 0x41;
}

View file

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2010-2011,International Business Machines
* Copyright (c) 2010-2016,International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
**********************************************************************
@ -18,6 +18,7 @@
#include "unicode/smpdtfmt.h"
#include "unicode/uchar.h"
#include "unicode/basictz.h"
#include "cmemory.h"
#include "cstring.h"
#include "unicode/uperf.h"
@ -29,7 +30,7 @@
#include "util.h"
static const char* PATTERNS[] = {"z", "zzzz", "Z", "ZZZZ", "v", "vvvv", "V", "VVVV"};
static const int NUM_PATTERNS = sizeof(PATTERNS)/sizeof(const char*);
static const int NUM_PATTERNS = UPRV_LENGTHOF(PATTERNS);
#include <iostream>
#include <stdlib.h>
@ -98,8 +99,8 @@ public:
}
// Set up test dates
UDate DATES[(sizeof(testDateData)/sizeof(int32_t))/3];
const int32_t nDates = (sizeof(testDateData)/sizeof(int32_t))/3;
UDate DATES[UPRV_LENGTHOF(testDateData)/3];
const int32_t nDates = UPRV_LENGTHOF(testDateData)/3;
cal->clear();
for (int32_t i = 0; i < nDates; i++) {
cal->set(testDateData[i][0], testDateData[i][1], testDateData[i][2]);
@ -228,4 +229,4 @@ public:
};
#endif // DateTimeRoundTripPerfTest
#endif // DateTimeRoundTripPerfTest