ICU-7482 z issues - cintltest passes!

X-SVN-Rev: 27754
This commit is contained in:
Steven R. Loomis 2010-03-03 01:47:00 +00:00
parent 1aa08c9bfe
commit 99998611d9
6 changed files with 163 additions and 72 deletions

View file

@ -13,6 +13,7 @@
#include "cmemory.h"
#include "cstring.h"
#include "putilimp.h"
#include "uinvchar.h"
/* struct holding a single variant */
typedef struct VariantListEntry {
@ -429,7 +430,7 @@ _addVariantToList(VariantListEntry **first, VariantListEntry *var) {
var->next = NULL;
break;
}
cmp = uprv_strcmp(var->variant, cur->variant);
cmp = uprv_compareInvCharsAsAscii(var->variant, cur->variant);
if (cmp < 0) {
if (prev == NULL) {
*first = var;
@ -495,10 +496,10 @@ _addExtensionToList(ExtensionListEntry **first, ExtensionListEntry *ext, UBool l
} else if (curlen == 1) {
cmp = LDMLEXT - *(cur->key);
} else {
cmp = uprv_strcmp(ext->key, cur->key);
cmp = uprv_compareInvCharsAsAscii(ext->key, cur->key);
}
} else {
cmp = uprv_strcmp(ext->key, cur->key);
cmp = uprv_compareInvCharsAsAscii(ext->key, cur->key);
}
if (cmp < 0) {
if (prev == NULL) {
@ -662,7 +663,7 @@ _bcp47ToLDMLKey(const char* bcpKey, int32_t bcpKeyLen,
}
u_UCharsToChars(uBcpKey, tmpBcpKeyBuf, tmpBcpKeyLen);
tmpBcpKeyBuf[tmpBcpKeyLen] = 0;
if (uprv_strcmp(bcpKeyBuf, tmpBcpKeyBuf) == 0) {
if (uprv_compareInvCharsAsAscii(bcpKeyBuf, tmpBcpKeyBuf) == 0) {
/* found a matching BCP47 key */
resKey = ures_getKey(mapData);
resultLen = (int32_t)uprv_strlen(resKey);
@ -720,7 +721,7 @@ _ldmlTypeToBCP47(const char* key, int32_t keyLen,
for (i = 0; i < keyLen; i++) {
keyBuf[i] = uprv_tolower(keyBuf[i]);
}
if (uprv_strcmp(keyBuf, "timezone") == 0) {
if (uprv_compareInvCharsAsAscii(keyBuf, "timezone") == 0) {
isTimezone = TRUE;
}
@ -877,7 +878,7 @@ _bcp47ToLDMLType(const char* key, int32_t keyLen,
}
u_UCharsToChars(uBcpType, tmpBcpTypeBuf, tmpBcpTypeLen);
tmpBcpTypeBuf[tmpBcpTypeLen] = 0;
if (uprv_strcmp(bcpTypeBuf, tmpBcpTypeBuf) == 0) {
if (uprv_compareInvCharsAsAscii(bcpTypeBuf, tmpBcpTypeBuf) == 0) {
/* found a matching BCP47 type */
resType = ures_getKey(mapData);
resultLen = (int32_t)uprv_strlen(resType);
@ -904,7 +905,7 @@ _bcp47ToLDMLType(const char* key, int32_t keyLen,
copyLen = uprv_min(resultLen, typeCapacity);
uprv_memcpy(type, resType, copyLen);
if (uprv_strcmp(keyBuf, "timezone") == 0) {
if (uprv_compareInvCharsAsAscii(keyBuf, "timezone") == 0) {
for (i = 0; i < copyLen; i++) {
if (*(type + i) == ':') {
*(type + i) = '/';
@ -955,7 +956,7 @@ _appendLanguageToLanguageTag(const char* localeID, char* appendAt, int32_t capac
} else {
/* resolve deprecated */
for (i = 0; DEPRECATEDLANGS[i] != NULL; i += 2) {
if (uprv_strcmp(buf, DEPRECATEDLANGS[i]) == 0) {
if (uprv_compareInvCharsAsAscii(buf, DEPRECATEDLANGS[i]) == 0) {
uprv_strcpy(buf, DEPRECATEDLANGS[i + 1]);
len = (int32_t)uprv_strlen(buf);
break;
@ -2005,7 +2006,7 @@ static const char*
ultag_getJDKLanguage(const ULanguageTag* langtag) {
int32_t i;
for (i = 0; DEPRECATEDLANGS[i] != NULL; i += 2) {
if (uprv_strcmp(DEPRECATEDLANGS[i], langtag->language) == 0) {
if (uprv_compareInvCharsAsAscii(DEPRECATEDLANGS[i], langtag->language) == 0) {
return DEPRECATEDLANGS[i + 1];
}
}
@ -2190,7 +2191,7 @@ uloc_forLanguageTag(const char* langtag,
/* language */
subtag = ultag_getExtlangSize(lt) > 0 ? ultag_getExtlang(lt, 0) : ultag_getLanguage(lt);
if (uprv_strcmp(subtag, LANG_UND) != 0) {
if (uprv_compareInvCharsAsAscii(subtag, LANG_UND) != 0) {
len = (int32_t)uprv_strlen(subtag);
if (len > 0) {
if (reslen < localeIDCapacity) {

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2009, International Business Machines
* Copyright (C) 1996-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: ucol_res.cpp
@ -748,6 +748,8 @@ static const UEnumeration defaultKeywordValues = {
ulist_reset_keyword_values_iterator
};
#include <stdio.h>
U_CAPI UEnumeration* U_EXPORT2
ucol_getKeywordValuesForLocale(const char* /*key*/, const char* locale,
UBool /*commonlyUsed*/, UErrorCode* status) {
@ -800,7 +802,21 @@ ucol_getKeywordValuesForLocale(const char* /*key*/, const char* locale,
int32_t defcollLength = ULOC_KEYWORDS_CAPACITY;
ures_getNextResource(&collres, &defres, status);
#if U_CHARSET_FAMILY==U_ASCII_FAMILY
/* optimize - use the utf-8 string */
ures_getUTF8String(&defres, defcoll, &defcollLength, TRUE, status);
#else
{
const UChar* defString = ures_getString(&defres, &defcollLength, status);
if(U_SUCCESS(*status)) {
if(defcollLength+1 > ULOC_KEYWORDS_CAPACITY) {
*status = U_BUFFER_OVERFLOW_ERROR;
} else {
u_UCharsToChars(defString, defcoll, defcollLength+1);
}
}
}
#endif
ulist_addItemBeginList(results, defcoll, TRUE, status);
}

View file

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2009, International Business Machines
* Copyright (c) 2002-2010, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
@ -2170,7 +2170,23 @@ U_CAPI UEnumeration *U_EXPORT2 ucurr_getKeywordValuesForLocale(const char *key,
*status = U_MEMORY_ALLOCATION_ERROR;
break;
}
#if U_CHARSET_FAMILY==U_ASCII_FAMILY
ures_getUTF8StringByKey(&curbndl, "id", curID, &curIDLength, TRUE, status);
/* optimize - use the utf-8 string */
#else
{
const UChar* defString = ures_getStringByKey(&curbndl, "id", &curIDLength, status);
if(U_SUCCESS(*status)) {
if(curIDLength+1 > ULOC_KEYWORDS_CAPACITY) {
*status = U_BUFFER_OVERFLOW_ERROR;
} else {
u_UCharsToChars(defString, curID, curIDLength+1);
}
}
}
#endif
if (U_FAILURE(*status)) {
break;
}

View file

@ -5464,12 +5464,9 @@ static void TestSameStrengthList(void)
UParseError error;
UErrorCode status = U_ZERO_ERROR;
UCollator *myCollation;
char srules[500] = "&a<*bcd &b<<*klm &k<<<*xyz &a=*123";
UChar rules[500];
uint32_t length = 0;
UChar rules[] = { 0x26, 0x61, 0x3c, 0x2a, 0x62, 0x63, 0x64, 0x20, 0x26, 0x62, 0x3c, 0x3c, 0x2a, 0x6b, 0x6c, 0x6d, 0x20, 0x26, 0x6b, 0x3c, 0x3c, 0x3c, 0x2a, 0x78, 0x79, 0x7a, 0x20, 0x26, 0x61, 0x3d, 0x2a, 0x31, 0x32, 0x33, 0x00 }; /* &a<*bcd &b<<*klm &k<<<*xyz &a=*123 */
u_strFromUTF8(rules, 500, &length, srules, strlen(srules), &status);
myCollation = ucol_openRules(rules, length, UCOL_ON, UCOL_TERTIARY, &error, &status);
myCollation = ucol_openRules(rules, u_strlen(rules), UCOL_ON, UCOL_TERTIARY, &error, &status);
if(U_FAILURE(status)){
log_err_status(status, "ERROR: in creation of rule based collator: %s\n", myErrorName(status));
return;

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2009, International Business Machines Corporation
* Copyright (c) 1997-2010, International Business Machines Corporation
* and others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
@ -919,6 +919,8 @@ static void TestGetKeywordValuesForLocale(void) {
for (j = 0; j < size; j++) {
if ((value = uenum_next(pref, &valueLength, &status)) != NULL && U_SUCCESS(status)) {
if (uprv_strcmp(value, PREFERRED[i][j+1]) != 0) {
log_err("ERROR: locale %s got keywords #%d %s expected %s\n", loc, j, value, PREFERRED[i][j+1]);
matchPref = FALSE;
break;
}
@ -928,6 +930,8 @@ static void TestGetKeywordValuesForLocale(void) {
break;
}
}
} else {
log_err("FAIL: size of locale \"%s\" %d does not match expected size %d\n", loc, size, EXPECTED_SIZE[i]);
}
if (!matchPref) {
@ -956,9 +960,15 @@ static void TestGetKeywordValuesForLocale(void) {
break;
}
}
}
if (!matchAll) {
if (!matchAll) {
log_err("FAIL: All values for locale \"%s\" does not match expected.\n", loc);
}
} else {
if(U_FAILURE(status)) {
log_err("ERROR: %s\n", u_errorName(status));
} else if(size!=uenum_count(ALL, &status)) {
log_err("ERROR: got size of %d, wanted %d\n", size, uenum_count(ALL, &status));
}
}
uenum_close(all);

View file

@ -65,6 +65,9 @@ log_data_err("Test Failure at file %s, line %d (Are you missing data?)\n", __FIL
}
/**
* @param expected utf-8 array of bytes to be expected
*/
static void test_assert_string(const char *expected, const UChar *actual, UBool nulTerm, const char *file, int line) {
char buf_inside_macro[120];
int32_t len = (int32_t)strlen(expected);
@ -163,7 +166,7 @@ static void TestRegexCAPI(void) {
u_uastrncpy(pat, "abc*", sizeof(pat)/2);
re = uregex_open(pat, -1, 0, 0, &status);
if (U_FAILURE(status)) {
log_data_err("Failed to open regular expression, line %d, error is \"%s\" (Are you missing data?)\n", __LINE__, u_errorName(status));
log_data_err("Failed to open regular expression, %s:%d, error is \"%s\" (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));
return;
}
uregex_close(re);
@ -1357,12 +1360,13 @@ static void TestUTextAPI(void) {
URegularExpression *re;
UText patternText = UTEXT_INITIALIZER;
UChar pat[200];
const char patternTextUTF8[5] = { 0x61, 0x62, 0x63, 0x2a, 0x00 };
/* Mimimalist open/close */
utext_openUTF8(&patternText, "abc*", -1, &status);
utext_openUTF8(&patternText, patternTextUTF8, -1, &status);
re = uregex_openUText(&patternText, 0, 0, &status);
if (U_FAILURE(status)) {
log_data_err("Failed to open regular expression, line %d, error is \"%s\" (Are you missing data?)\n", __LINE__, u_errorName(status));
log_data_err("Failed to open regular expression, %s:%d, error is \"%s\" (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));
utext_close(&patternText);
return;
}
@ -1451,10 +1455,12 @@ static void TestUTextAPI(void) {
const UChar *resultPat;
int32_t resultLen;
UText *resultText;
const char str_hello[] = { 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00 }; /* hello */
const char str_hel[] = { 0x68, 0x65, 0x6c, 0x00 }; /* hel */
u_uastrncpy(pat, "hello", sizeof(pat)/2); /* for comparison */
status = U_ZERO_ERROR;
utext_openUTF8(&patternText, "hello", -1, &status);
utext_openUTF8(&patternText, str_hello, -1, &status);
re = uregex_open(pat, -1, 0, NULL, &status);
resultPat = uregex_pattern(re, &resultLen, &status);
TEST_ASSERT_SUCCESS(status);
@ -1467,7 +1473,7 @@ static void TestUTextAPI(void) {
resultText = uregex_patternUText(re, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("hello", resultText);
TEST_ASSERT_UTEXT(str_hello, resultText);
uregex_close(re);
@ -1485,7 +1491,7 @@ static void TestUTextAPI(void) {
resultText = uregex_patternUText(re, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("hel", resultText);
TEST_ASSERT_UTEXT(str_hel, resultText);
uregex_close(re);
}
@ -1497,12 +1503,14 @@ static void TestUTextAPI(void) {
UText text1 = UTEXT_INITIALIZER;
UText text2 = UTEXT_INITIALIZER;
UBool result;
const char str_abcccd[] = { 0x62, 0x63, 0x64, 0x64, 0x64, 0x65, 0x00 }; /* abcccd */
const char str_abcccxd[] = { 0x62, 0x63, 0x64, 0x64, 0x64, 0x79, 0x65, 0x00 }; /* abcccxd */
const char str_abcd[] = { 0x62, 0x63, 0x64, 0x2b, 0x65, 0x00 }; /* abc*d */
status = U_ZERO_ERROR;
utext_openUTF8(&text1, "abcccd", -1, &status);
utext_openUTF8(&text2, "abcccxd", -1, &status);
utext_openUTF8(&text1, str_abcccd, -1, &status);
utext_openUTF8(&text2, str_abcccxd, -1, &status);
utext_openUTF8(&patternText, "abc*d", -1, &status);
utext_openUTF8(&patternText, str_abcd, -1, &status);
re = uregex_openUText(&patternText, 0, NULL, &status);
TEST_ASSERT_SUCCESS(status);
@ -1545,13 +1553,17 @@ static void TestUTextAPI(void) {
UText *resultText;
const UChar *result;
int32_t textLength;
const char str_abcccd[] = { 0x62, 0x63, 0x64, 0x64, 0x64, 0x65, 0x00 }; /* abcccd */
const char str_abcccxd[] = { 0x62, 0x63, 0x64, 0x64, 0x64, 0x79, 0x65, 0x00 }; /* abcccxd */
const char str_abcd[] = { 0x62, 0x63, 0x64, 0x2b, 0x65, 0x00 }; /* abc*d */
status = U_ZERO_ERROR;
utext_openUTF8(&text1, "abcccd", -1, &status);
u_uastrncpy(text2Chars, "abcccxd", sizeof(text2)/2);
utext_openUTF8(&text1, str_abcccd, -1, &status);
u_uastrncpy(text2Chars, str_abcccxd, sizeof(text2)/2);
utext_openUChars(&text2, text2Chars, -1, &status);
utext_openUTF8(&patternText, "abc*d", -1, &status);
utext_openUTF8(&patternText, str_abcd, -1, &status);
re = uregex_openUText(&patternText, 0, NULL, &status);
/* First set a UText */
@ -1597,10 +1609,12 @@ static void TestUTextAPI(void) {
UText text1 = UTEXT_INITIALIZER;
UBool result;
UText nullText = UTEXT_INITIALIZER;
const char str_abcccde[] = { 0x61, 0x62, 0x63, 0x63, 0x63, 0x64, 0x65, 0x00 }; /* abcccde */
const char str_abcd[] = { 0x61, 0x62, 0x63, 0x2a, 0x64, 0x00 }; /* abc*d */
status = U_ZERO_ERROR;
utext_openUTF8(&text1, "abcccde", -1, &status);
utext_openUTF8(&patternText, "abc*d", -1, &status);
utext_openUTF8(&text1, str_abcccde, -1, &status);
utext_openUTF8(&patternText, str_abcd, -1, &status);
re = uregex_openUText(&patternText, 0, NULL, &status);
uregex_setUText(re, &text1, &status);
@ -1700,6 +1714,11 @@ static void TestUTextAPI(void) {
UChar text1[80];
UText *actual;
UBool result;
const char str_abcinteriordef[] = { 0x61, 0x62, 0x63, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x69, 0x6f, 0x72, 0x20, 0x64, 0x65, 0x66, 0x00 }; /* abc interior def */
const char str_interior[] = { 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x69, 0x6f, 0x72, 0x20, 0x00 }; /* ' interior ' */
u_uastrncpy(text1, "noise abc interior def, and this is off the end", sizeof(text1)/2);
status = U_ZERO_ERROR;
@ -1714,14 +1733,14 @@ static void TestUTextAPI(void) {
status = U_ZERO_ERROR;
actual = uregex_groupUText(re, 0, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("abc interior def", actual);
TEST_ASSERT_UTEXT(str_abcinteriordef, actual);
utext_close(actual);
/* Capture group #1. Should succeed. */
status = U_ZERO_ERROR;
actual = uregex_groupUText(re, 1, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT(" interior ", actual);
TEST_ASSERT_UTEXT(str_interior, actual);
utext_close(actual);
/* Capture group out of range. Error. */
@ -1743,11 +1762,15 @@ static void TestUTextAPI(void) {
UChar text2[80];
UText replText = UTEXT_INITIALIZER;
UText *result;
const char str_Replxxx[] = { 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3c, 0x61, 0x61, 0x3e, 0x20, 0x78, 0x31, 0x78, 0x20, 0x78, 0x2e, 0x2e, 0x2e, 0x78, 0x2e, 0x00 }; /* Replace <aa> x1x x...x. */
const char str_Nomatchhere[] = { 0x4e, 0x6f, 0x20, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2e, 0x00 }; /* No match here. */
const char str_u00411U00000042a[] = { 0x5c, 0x5c, 0x5c, 0x75, 0x30, 0x30, 0x34, 0x31, 0x24, 0x31, 0x5c, 0x55, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x32, 0x24, 0x5c, 0x61, 0x00 }; /* \\\u0041$1\U00000042$\a */
const char str_1x[] = { 0x3c, 0x24, 0x31, 0x3e, 0x00 }; /* <$1> */
const char str_ReplaceAaaBax1xxx[] = { 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x5c, 0x41, 0x61, 0x61, 0x42, 0x24, 0x61, 0x20, 0x78, 0x31, 0x78, 0x20, 0x78, 0x2e, 0x2e, 0x2e, 0x78, 0x2e, 0x00 }; /* Replace \AaaB$a x1x x...x. */
status = U_ZERO_ERROR;
u_uastrncpy(text1, "Replace xaax x1x x...x.", sizeof(text1)/2);
u_uastrncpy(text2, "No match here.", sizeof(text2)/2);
utext_openUTF8(&replText, "<$1>", -1, &status);
utext_openUTF8(&replText, str_1x, -1, &status);
re = uregex_openC("x(.*?)x", 0, NULL, &status);
TEST_ASSERT_SUCCESS(status);
@ -1756,22 +1779,22 @@ static void TestUTextAPI(void) {
uregex_setText(re, text1, -1, &status);
result = uregex_replaceFirstUText(re, &replText, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("Replace <aa> x1x x...x.", result);
TEST_ASSERT_UTEXT(str_Replxxx, result);
utext_close(result);
/* No match. Text should copy to output with no changes. */
uregex_setText(re, text2, -1, &status);
result = uregex_replaceFirstUText(re, &replText, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("No match here.", result);
TEST_ASSERT_UTEXT(str_Nomatchhere, result);
utext_close(result);
/* Unicode escapes */
uregex_setText(re, text1, -1, &status);
utext_openUTF8(&replText, "\\\\\\u0041$1\\U00000042$\\a", -1, &status);
utext_openUTF8(&replText, str_u00411U00000042a, -1, &status);
result = uregex_replaceFirstUText(re, &replText, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("Replace \\AaaB$a x1x x...x.", result);
TEST_ASSERT_UTEXT(str_ReplaceAaaBax1xxx, result);
utext_close(result);
uregex_close(re);
@ -1787,11 +1810,13 @@ static void TestUTextAPI(void) {
UChar text2[80];
UText replText = UTEXT_INITIALIZER;
UText *result;
const char str_1[] = { 0x3c, 0x24, 0x31, 0x3e, 0x00 }; /* <$1> */
const char str_Replaceaa1[] = { 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3c, 0x61, 0x61, 0x3e, 0x20, 0x3c, 0x31, 0x3e, 0x20, 0x3c, 0x2e, 0x2e, 0x2e, 0x3e, 0x2e, 0x00 }; /* Replace <aa> <1> <...>. */
const char str_Nomatchhere[] = { 0x4e, 0x6f, 0x20, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2e, 0x00 }; /* No match here. */
status = U_ZERO_ERROR;
u_uastrncpy(text1, "Replace xaax x1x x...x.", sizeof(text1)/2);
u_uastrncpy(text2, "No match here.", sizeof(text2)/2);
utext_openUTF8(&replText, "<$1>", -1, &status);
utext_openUTF8(&replText, str_1, -1, &status);
re = uregex_openC("x(.*?)x", 0, NULL, &status);
TEST_ASSERT_SUCCESS(status);
@ -1800,14 +1825,14 @@ static void TestUTextAPI(void) {
uregex_setText(re, text1, -1, &status);
result = uregex_replaceAllUText(re, &replText, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("Replace <aa> <1> <...>.", result);
TEST_ASSERT_UTEXT(str_Replaceaa1, result);
utext_close(result);
/* No match. Text should copy to output with no changes. */
uregex_setText(re, text2, -1, &status);
result = uregex_replaceAllUText(re, &replText, NULL, &status);
TEST_ASSERT_SUCCESS(status);
TEST_ASSERT_UTEXT("No match here.", result);
TEST_ASSERT_UTEXT(str_Nomatchhere, result);
utext_close(result);
uregex_close(re);
@ -1825,7 +1850,6 @@ static void TestUTextAPI(void) {
UChar *bufPtr;
int32_t bufCap;
status = U_ZERO_ERROR;
re = uregex_openC(".*", 0, 0, &status);
TEST_ASSERT_SUCCESS(status);
@ -1891,10 +1915,13 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* 'first ' */
const char str_second[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x00 }; /* ' second' */
const char str_third[] = { 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* ' third' */
TEST_ASSERT(numFields == 3);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT(" second", fields[1]);
TEST_ASSERT_UTEXT(" third", fields[2]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_second, fields[1]);
TEST_ASSERT_UTEXT(str_third, fields[2]);
TEST_ASSERT(fields[3] == NULL);
}
for(i = 0; i < numFields; i++) {
@ -1921,9 +1948,11 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_secondthird[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x3a, 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* second: third */
TEST_ASSERT(numFields == 2);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT(" second: third", fields[1]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_secondthird, fields[1]);
TEST_ASSERT(fields[2] == &patternText);
}
for(i = 0; i < numFields; i++) {
@ -1958,12 +1987,18 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_taga[] = { 0x74, 0x61, 0x67, 0x2d, 0x61, 0x00 }; /* tag-a */
const char str_second[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x00 }; /* second */
const char str_tagb[] = { 0x74, 0x61, 0x67, 0x2d, 0x62, 0x00 }; /* tag-b */
const char str_third[] = { 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* third */
TEST_ASSERT(numFields == 5);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT("tag-a", fields[1]);
TEST_ASSERT_UTEXT(" second", fields[2]);
TEST_ASSERT_UTEXT("tag-b", fields[3]);
TEST_ASSERT_UTEXT(" third", fields[4]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_taga, fields[1]);
TEST_ASSERT_UTEXT(str_second, fields[2]);
TEST_ASSERT_UTEXT(str_tagb, fields[3]);
TEST_ASSERT_UTEXT(str_third, fields[4]);
TEST_ASSERT(fields[5] == NULL);
}
for(i = 0; i < numFields; i++) {
@ -1981,9 +2016,11 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_secondtagbthird[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x3c, 0x74, 0x61, 0x67, 0x2d, 0x62, 0x3e, 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* second<tag-b> third */
TEST_ASSERT(numFields == 2);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT(" second<tag-b> third", fields[1]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_secondtagbthird, fields[1]);
TEST_ASSERT(fields[2] == &patternText);
}
for(i = 0; i < numFields; i++) {
@ -2002,10 +2039,13 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_taga[] = { 0x74, 0x61, 0x67, 0x2d, 0x61, 0x00 }; /* tag-a */
const char str_secondtagbthird[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x3c, 0x74, 0x61, 0x67, 0x2d, 0x62, 0x3e, 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* second<tag-b> third */
TEST_ASSERT(numFields == 3);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT("tag-a", fields[1]);
TEST_ASSERT_UTEXT(" second<tag-b> third", fields[2]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_taga, fields[1]);
TEST_ASSERT_UTEXT(str_secondtagbthird, fields[2]);
TEST_ASSERT(fields[3] == &patternText);
}
for(i = 0; i < numFields; i++) {
@ -2025,12 +2065,18 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_taga[] = { 0x74, 0x61, 0x67, 0x2d, 0x61, 0x00 }; /* tag-a */
const char str_second[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x00 }; /* second */
const char str_tagb[] = { 0x74, 0x61, 0x67, 0x2d, 0x62, 0x00 }; /* tag-b */
const char str_third[] = { 0x20, 0x20, 0x74, 0x68, 0x69, 0x72, 0x64, 0x00 }; /* third */
TEST_ASSERT(numFields == 5);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT("tag-a", fields[1]);
TEST_ASSERT_UTEXT(" second", fields[2]);
TEST_ASSERT_UTEXT("tag-b", fields[3]);
TEST_ASSERT_UTEXT(" third", fields[4]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_taga, fields[1]);
TEST_ASSERT_UTEXT(str_second, fields[2]);
TEST_ASSERT_UTEXT(str_tagb, fields[3]);
TEST_ASSERT_UTEXT(str_third, fields[4]);
TEST_ASSERT(fields[5] == &patternText);
}
for(i = 0; i < numFields; i++) {
@ -2051,11 +2097,16 @@ static void TestUTextAPI(void) {
/* The TEST_ASSERT_SUCCESS call above should change too... */
if(U_SUCCESS(status)) {
const char str_first[] = { 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x00 }; /* first */
const char str_taga[] = { 0x74, 0x61, 0x67, 0x2d, 0x61, 0x00 }; /* tag-a */
const char str_second[] = { 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x00 }; /* second */
const char str_tagb[] = { 0x74, 0x61, 0x67, 0x2d, 0x62, 0x00 }; /* tag-b */
TEST_ASSERT(numFields == 4);
TEST_ASSERT_UTEXT("first ", fields[0]);
TEST_ASSERT_UTEXT("tag-a", fields[1]);
TEST_ASSERT_UTEXT(" second", fields[2]);
TEST_ASSERT_UTEXT("tag-b", fields[3]);
TEST_ASSERT_UTEXT(str_first, fields[0]);
TEST_ASSERT_UTEXT(str_taga, fields[1]);
TEST_ASSERT_UTEXT(str_second, fields[2]);
TEST_ASSERT_UTEXT(str_tagb, fields[3]);
TEST_ASSERT(fields[4] == NULL);
TEST_ASSERT(fields[8] == NULL);
TEST_ASSERT(fields[9] == &patternText);