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.
/*
******************************************************************************
*
-* Copyright (C) 1998-2015, International Business Machines
+* Copyright (C) 1998-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
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))
{
//
/*
***************************************************************************
-* 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.
***************************************************************************
*/
#include "unicode/regex.h"
#include "unicode/uclean.h"
+#include "cmemory.h"
#include "cstr.h"
#include "uassert.h"
#include "uhash.h"
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;
}
/*
**********************************************************************
-* Copyright (C) 2008-2015, International Business Machines
+* Copyright (C) 2008-2016, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
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;
}
}
else {
s = ufmt_defaultCPToUnicode(arg, argSize, buffer,
- sizeof(buffer)/sizeof(UChar));
+ UPRV_LENGTHOF(buffer));
}
}
else {
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) {
/*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 {
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;
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;
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));
}
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;
}
/* 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;
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;
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;
/********************************************************************
- * Copyright (c) 1997-2015, International Business Machines
+ * Copyright (c) 1997-2016, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************/
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]),
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");
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){
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");
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");
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");
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);
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];
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)];
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);
/* 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");
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");
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");
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");
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");
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");
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)
{
/********************************************************************
- * COPYRIGHT:
- * Copyright (c) 2009-2015, International Business Machines Corporation and
+ * COPYRIGHT:
+ * Copyright (c) 2009-2016, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
#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));}}
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);
/********************************************************************
- * 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
{ 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);
}
{ 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);
}
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,
"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);
"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);
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);
}; // 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;
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) {
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;
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);
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) {
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);
-
/***********************************************************************
- * COPYRIGHT:
- * Copyright (c) 1997-2014, International Business Machines Corporation
+ * COPYRIGHT:
+ * Copyright (c) 1997-2016, International Business Machines Corporation
* and others. All Rights Reserved.
***********************************************************************/
//***** 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);
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)) {
{
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);
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;
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;
// 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);
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);
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);
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;
}
/*
**********************************************************************
-* Copyright (c) 2010-2011,International Business Machines
+* Copyright (c) 2010-2016,International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
**********************************************************************
#include "unicode/smpdtfmt.h"
#include "unicode/uchar.h"
#include "unicode/basictz.h"
+#include "cmemory.h"
#include "cstring.h"
#include "unicode/uperf.h"
#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>
}
// 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]);
};
-#endif // DateTimeRoundTripPerfTest
\ No newline at end of file
+#endif // DateTimeRoundTripPerfTest