Index: source/test/intltest/ucdtest.cpp |
diff --git a/source/test/intltest/ucdtest.cpp b/source/test/intltest/ucdtest.cpp |
index 9a7745d43fca9e38cfbe3df164c6c34650b8a415..a63e71291d56ba09a25fd919f907d6130b135f00 100644 |
--- a/source/test/intltest/ucdtest.cpp |
+++ b/source/test/intltest/ucdtest.cpp |
@@ -1,6 +1,6 @@ |
/******************************************************************** |
* COPYRIGHT: |
- * Copyright (c) 1997-2013, International Business Machines Corporation and |
+ * Copyright (c) 1997-2014, International Business Machines Corporation and |
* others. All Rights Reserved. |
********************************************************************/ |
@@ -16,8 +16,6 @@ |
#include "uparse.h" |
#include "ucdtest.h" |
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0])) |
- |
static const char *ignorePropNames[]={ |
"FC_NFKC", |
"NFD_QC", |
@@ -40,7 +38,7 @@ UnicodeTest::UnicodeTest() |
unknownPropertyNames=NULL; |
} |
// Ignore some property names altogether. |
- for(int32_t i=0; i<LENGTHOF(ignorePropNames); ++i) { |
+ for(int32_t i=0; i<UPRV_LENGTHOF(ignorePropNames); ++i) { |
unknownPropertyNames->puti(UnicodeString(ignorePropNames[i], -1, US_INV), 1, errorCode); |
} |
} |
@@ -150,7 +148,7 @@ derivedPropsIndex[]={ |
UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED |
}; |
-static int32_t numErrors[LENGTHOF(derivedPropsIndex)]={ 0 }; |
+static int32_t numErrors[UPRV_LENGTHOF(derivedPropsIndex)]={ 0 }; |
enum { MAX_ERRORS=50 }; |
@@ -170,7 +168,7 @@ derivedPropsLineFn(void *context, |
} |
/* parse derived binary property name, ignore unknown names */ |
- i=getTokenIndex(derivedPropsNames, LENGTHOF(derivedPropsNames), fields[1][0]); |
+ i=getTokenIndex(derivedPropsNames, UPRV_LENGTHOF(derivedPropsNames), fields[1][0]); |
if(i<0) { |
UnicodeString propName(fields[1][0], (int32_t)(fields[1][1]-fields[1][0])); |
propName.trim(); |
@@ -188,49 +186,32 @@ derivedPropsLineFn(void *context, |
void UnicodeTest::TestAdditionalProperties() { |
#if !UCONFIG_NO_NORMALIZATION |
// test DerivedCoreProperties.txt and DerivedNormalizationProps.txt |
- if(LENGTHOF(derivedProps)<LENGTHOF(derivedPropsNames)) { |
+ if(UPRV_LENGTHOF(derivedProps)<UPRV_LENGTHOF(derivedPropsNames)) { |
errln("error: UnicodeTest::derivedProps[] too short, need at least %d UnicodeSets\n", |
- LENGTHOF(derivedPropsNames)); |
+ UPRV_LENGTHOF(derivedPropsNames)); |
return; |
} |
- if(LENGTHOF(derivedPropsIndex)!=LENGTHOF(derivedPropsNames)) { |
- errln("error in ucdtest.cpp: LENGTHOF(derivedPropsIndex)!=LENGTHOF(derivedPropsNames)\n"); |
+ if(UPRV_LENGTHOF(derivedPropsIndex)!=UPRV_LENGTHOF(derivedPropsNames)) { |
+ errln("error in ucdtest.cpp: UPRV_LENGTHOF(derivedPropsIndex)!=UPRV_LENGTHOF(derivedPropsNames)\n"); |
return; |
} |
- char newPath[256]; |
- char backupPath[256]; |
+ char path[500]; |
+ if(getUnidataPath(path) == NULL) { |
+ errln("unable to find path to source/data/unidata/"); |
+ return; |
+ } |
+ char *basename=strchr(path, 0); |
+ strcpy(basename, "DerivedCoreProperties.txt"); |
+ |
char *fields[2][2]; |
UErrorCode errorCode=U_ZERO_ERROR; |
- |
- /* Look inside ICU_DATA first */ |
- strcpy(newPath, pathToDataDirectory()); |
- strcat(newPath, "unidata" U_FILE_SEP_STRING "DerivedCoreProperties.txt"); |
- |
- // As a fallback, try to guess where the source data was located |
- // at the time ICU was built, and look there. |
-# ifdef U_TOPSRCDIR |
- strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING "data"); |
-# else |
- strcpy(backupPath, loadTestData(errorCode)); |
- strcat(backupPath, U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data"); |
-# endif |
- strcat(backupPath, U_FILE_SEP_STRING); |
- strcat(backupPath, "unidata" U_FILE_SEP_STRING "DerivedCoreProperties.txt"); |
- |
- char *path=newPath; |
- u_parseDelimitedFile(newPath, ';', fields, 2, derivedPropsLineFn, this, &errorCode); |
- |
- if(errorCode==U_FILE_ACCESS_ERROR) { |
- errorCode=U_ZERO_ERROR; |
- path=backupPath; |
- u_parseDelimitedFile(backupPath, ';', fields, 2, derivedPropsLineFn, this, &errorCode); |
- } |
+ u_parseDelimitedFile(path, ';', fields, 2, derivedPropsLineFn, this, &errorCode); |
if(U_FAILURE(errorCode)) { |
errln("error parsing DerivedCoreProperties.txt: %s\n", u_errorName(errorCode)); |
return; |
} |
- char *basename=path+strlen(path)-strlen("DerivedCoreProperties.txt"); |
+ |
strcpy(basename, "DerivedNormalizationProps.txt"); |
u_parseDelimitedFile(path, ';', fields, 2, derivedPropsLineFn, this, &errorCode); |
if(U_FAILURE(errorCode)) { |
@@ -245,7 +226,7 @@ void UnicodeTest::TestAdditionalProperties() { |
UChar32 start, end; |
// test all TRUE properties |
- for(i=0; i<LENGTHOF(derivedPropsNames); ++i) { |
+ for(i=0; i<UPRV_LENGTHOF(derivedPropsNames); ++i) { |
rangeCount=derivedProps[i].getRangeCount(); |
for(range=0; range<rangeCount && numErrors[i]<MAX_ERRORS; ++range) { |
start=derivedProps[i].getRangeStart(range); |
@@ -263,12 +244,12 @@ void UnicodeTest::TestAdditionalProperties() { |
} |
// invert all properties |
- for(i=0; i<LENGTHOF(derivedPropsNames); ++i) { |
+ for(i=0; i<UPRV_LENGTHOF(derivedPropsNames); ++i) { |
derivedProps[i].complement(); |
} |
// test all FALSE properties |
- for(i=0; i<LENGTHOF(derivedPropsNames); ++i) { |
+ for(i=0; i<UPRV_LENGTHOF(derivedPropsNames); ++i) { |
rangeCount=derivedProps[i].getRangeCount(); |
for(range=0; range<rangeCount && numErrors[i]<MAX_ERRORS; ++range) { |
start=derivedProps[i].getRangeStart(range); |
@@ -302,7 +283,7 @@ void UnicodeTest::TestBinaryValues() { |
static const char *const falseValues[]={ "N", "No", "F", "False" }; |
static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; |
int32_t i; |
- for(i=0; i<LENGTHOF(falseValues); ++i) { |
+ for(i=0; i<UPRV_LENGTHOF(falseValues); ++i) { |
UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]"); |
pattern.insert(pattern.length()-2, UnicodeString(falseValues[i], -1, US_INV)); |
errorCode=U_ZERO_ERROR; |
@@ -316,7 +297,7 @@ void UnicodeTest::TestBinaryValues() { |
errln("UnicodeSet([:Alphabetic=%s:]).complement()!=UnicodeSet([:Alphabetic:])\n", falseValues[i]); |
} |
} |
- for(i=0; i<LENGTHOF(trueValues); ++i) { |
+ for(i=0; i<UPRV_LENGTHOF(trueValues); ++i) { |
UnicodeString pattern=UNICODE_STRING_SIMPLE("[:Alphabetic=:]"); |
pattern.insert(pattern.length()-2, UnicodeString(trueValues[i], -1, US_INV)); |
errorCode=U_ZERO_ERROR; |