ICU-573 included stdlib.h and memory.h into files that need it for the utypes.h change
X-SVN-Rev: 2367
This commit is contained in:
parent
bd94ac5ec8
commit
9253fe4dd3
@ -30,6 +30,8 @@
|
||||
*/
|
||||
#ifndef INCLUDE_CALLCOLL_C
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -37,7 +39,6 @@
|
||||
#include "ccolltst.h"
|
||||
#include "callcoll.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include <string.h>
|
||||
|
||||
static UCollator *myCollation;
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
/* C API AND FUNCTIONALITY TEST FOR CALENDAR (ucol.h)*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucal.h"
|
||||
@ -21,8 +24,6 @@
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "ccaltst.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "cformtst.h"
|
||||
|
||||
|
||||
@ -156,7 +157,7 @@ void TestCalendar()
|
||||
}
|
||||
else{
|
||||
log_verbose("PASS: getting the time zone display name successful : %s, %d needed \n",
|
||||
u_errorName(status), resultlengthneeded);
|
||||
u_errorName(status), resultlengthneeded);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,12 +12,13 @@
|
||||
* Madhu Katragadda Creation
|
||||
*********************************************************************************
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "cintltst.h"
|
||||
#include "ccolltst.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include <string.h>
|
||||
#include "unicode/ustring.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void addCollAPITest(TestNode**);
|
||||
void addCurrencyTest(TestNode**);
|
||||
|
@ -13,6 +13,8 @@
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -101,11 +103,11 @@ void currTest()
|
||||
sortklen=ucol_getSortKey(c, source, u_strlen(source), NULL, 0);
|
||||
sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1));
|
||||
ucol_getSortKey(c, source, u_strlen(source), sortKey1, sortklen+1);
|
||||
|
||||
|
||||
sortklen=ucol_getSortKey(c, target, u_strlen(target), NULL, 0);
|
||||
sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1));
|
||||
ucol_getSortKey(c, target, u_strlen(target), sortKey2, sortklen+1);
|
||||
|
||||
|
||||
res = memcmp(sortKey1, sortKey2, sortklen);
|
||||
if (res < 0) keyResult = (UCollationResult)-1;
|
||||
else if (res > 0) keyResult = (UCollationResult)1;
|
||||
|
@ -18,6 +18,8 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -25,7 +27,6 @@
|
||||
#include "ccolltst.h"
|
||||
#include "cdantst.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include <string.h>
|
||||
|
||||
static UCollator *myCollation;
|
||||
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
/* C API TEST FOR DATE FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/udat.h"
|
||||
@ -23,8 +26,6 @@
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "cdattst.h"
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include "cformtst.h"
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -14,6 +14,9 @@
|
||||
*/
|
||||
/* INDEPTH TEST FOR DATE FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/udat.h"
|
||||
@ -23,8 +26,6 @@
|
||||
#include "cintltst.h"
|
||||
#include "cdtdptst.h"
|
||||
#include "cformtst.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void addDtFrDepTest(TestNode** root)
|
||||
{
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
/* REGRESSION TEST FOR DATE FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/udat.h"
|
||||
@ -23,8 +26,6 @@
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "cdtrgtst.h"
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
|
||||
void addDateForRgrTest(TestNode** root)
|
||||
|
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
/* FormatTest is a medium top level test for everything in the C FORMAT API */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "cintltst.h"
|
||||
#include "cformtst.h"
|
||||
|
||||
@ -29,17 +30,17 @@ void addDtFrDepTest(TestNode**);
|
||||
|
||||
void checkHeap()
|
||||
{
|
||||
int i;
|
||||
void *n[2048];
|
||||
int i;
|
||||
void *n[2048];
|
||||
|
||||
log_info("checkHeap...");
|
||||
log_info("checkHeap...");
|
||||
|
||||
|
||||
for(i=0;i<1;i++)
|
||||
|
||||
for(i=0;i<1;i++)
|
||||
{
|
||||
n[i]= malloc(i+15);
|
||||
n[i]= malloc(i+15);
|
||||
}
|
||||
|
||||
|
||||
/* for(i=0;i<2048;i++)
|
||||
{
|
||||
free(n[i]);
|
||||
@ -67,8 +68,8 @@ void addFormatTest(TestNode** root)
|
||||
addMsgForTest(root);
|
||||
addDateForRgrTest(root);
|
||||
addDtFrDepTest(root);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*INternal functions used*/
|
||||
|
||||
@ -78,7 +79,7 @@ UChar* myDateFormat(UDateFormat* dat, UDate d1)
|
||||
int32_t resultlength, resultlengthneeded;
|
||||
UFieldPosition pos;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
|
||||
resultlength=0;
|
||||
resultlengthneeded=udat_format(dat, d1, NULL, resultlength, &pos, &status);
|
||||
|
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -152,10 +153,10 @@ void doTest(UCollator* myCollation, const UChar source[], const UChar target[],
|
||||
|
||||
sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1));
|
||||
ucol_getSortKey(myCollation, source, u_strlen(source), sortKey1, sortklen1+1);
|
||||
|
||||
|
||||
sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1));
|
||||
ucol_getSortKey(myCollation, target, u_strlen(target), sortKey2, sortklen2+1);
|
||||
|
||||
|
||||
|
||||
temp= memcmp(sortKey1, sortKey2, sortklenmin);
|
||||
if(temp < 0) keyResult=UCOL_LESS;
|
||||
@ -168,7 +169,7 @@ void doTest(UCollator* myCollation, const UChar source[], const UChar target[],
|
||||
|
||||
void TestTertiary( )
|
||||
{
|
||||
|
||||
|
||||
int32_t i;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
myCollation = ucol_open("fr_FR", &status);
|
||||
|
@ -34,6 +34,9 @@
|
||||
* co-p
|
||||
* cop
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -41,8 +44,6 @@
|
||||
#include "cg7coll.h"
|
||||
#include "ccolltst.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
const char* locales[8] = {
|
||||
@ -162,9 +163,9 @@ void doTest(UCollator *myCollation, const UChar source[], const UChar target[],
|
||||
int32_t temp;
|
||||
UCollationResult compareResult, keyResult;
|
||||
uint8_t *sortKey1, *sortKey2;
|
||||
|
||||
|
||||
compareResult = ucol_strcoll(myCollation, source, u_strlen(source), target, u_strlen(target));
|
||||
|
||||
|
||||
sortklen1=ucol_getSortKey(myCollation, source, u_strlen(source), NULL, 0);
|
||||
sortklen2=ucol_getSortKey(myCollation, target, u_strlen(target), NULL, 0);
|
||||
|
||||
@ -173,10 +174,10 @@ void doTest(UCollator *myCollation, const UChar source[], const UChar target[],
|
||||
|
||||
sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1));
|
||||
ucol_getSortKey(myCollation, source, u_strlen(source), sortKey1, sortklen1+1);
|
||||
|
||||
|
||||
sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1));
|
||||
ucol_getSortKey(myCollation, target, u_strlen(target), sortKey2, sortklen2+1);
|
||||
|
||||
|
||||
|
||||
temp= memcmp(sortKey1, sortKey2, sortklenmin);
|
||||
if(temp < 0) keyResult=UCOL_LESS;
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
/*The main root for C API tests*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#include "cintltst.h"
|
||||
@ -22,8 +25,6 @@ U_CDECL_BEGIN
|
||||
#include "cucdtst.h"
|
||||
U_CDECL_END
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uchar.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/ucnv.h"
|
||||
|
@ -16,6 +16,8 @@
|
||||
* (Let me reiterate my position...)
|
||||
*/
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -31,14 +33,14 @@ UCollator *en_us=0;
|
||||
|
||||
void addCollIterTest(TestNode** root)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
addTest(root, &TestPrevious, "tscoll/citertst/TestPrevious");
|
||||
addTest(root, &TestOffset, "tscoll/citertst/TestOffset");
|
||||
addTest(root, &TestSetText, "tscoll/citertst/TestSetText");
|
||||
addTest(root, &TestMaxExpansion, "tscoll/citertst/TestMaxExpansion");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +62,7 @@ void TestPrevious()
|
||||
u_uastrcpy(test1, "What subset of all possible test cases?");
|
||||
u_uastrcpy(test2, "has the highest probability of detecting");
|
||||
en_us = ucol_open("en_US", &status);
|
||||
|
||||
|
||||
iter=ucol_openElements(en_us, test1, u_strlen(test1), &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n",
|
||||
@ -192,7 +194,7 @@ void TestOffset()
|
||||
{
|
||||
assertEqual(iter, pristine);
|
||||
}
|
||||
|
||||
|
||||
ucol_closeElements(pristine);
|
||||
ucol_closeElements(iter);
|
||||
free(orders);
|
||||
@ -290,7 +292,7 @@ void backAndForth(UCollationElements *iter)
|
||||
|
||||
if (index != 0)
|
||||
{
|
||||
|
||||
|
||||
log_err("Didn't get back to beginning - index is %d\n", index);
|
||||
|
||||
ucol_reset(iter);
|
||||
@ -336,17 +338,17 @@ void TestMaxExpansion()
|
||||
0x65, 2,
|
||||
0x66, 4
|
||||
};
|
||||
|
||||
|
||||
u_uastrcpy(rule1, "< a & ae = ");
|
||||
u_strcat(rule1, singleUChar);
|
||||
u_uastrcpy(temp, " < b < e");
|
||||
u_strcat(rule1, temp);
|
||||
verifyExpansion(rule1, test1, ARRAY_LENGTH(test1));
|
||||
|
||||
|
||||
/* Now a more complicated one:
|
||||
"a1" --> "ae"
|
||||
"z" --> "aeef" */
|
||||
|
||||
|
||||
u_uastrcpy(rule1, "");
|
||||
u_uastrcpy(rule1, "< a & ae = a1 & aeef = z < b < e < f");
|
||||
verifyExpansion(rule1, test2, ARRAY_LENGTH(test2));
|
||||
@ -387,8 +389,8 @@ void verifyExpansion(UChar* rules, const UChar expansionTests[], int32_t testCou
|
||||
/* First get the collation key that the test string expands to */
|
||||
UChar test[2] = { 0, 0} ;
|
||||
|
||||
test[0] = expansionTests[i+0];
|
||||
|
||||
test[0] = expansionTests[i+0];
|
||||
|
||||
ucol_setText(iter, test, u_strlen(test), &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("call to ucol_setText(iter, test, length) failed.");
|
||||
@ -400,15 +402,15 @@ void verifyExpansion(UChar* rules, const UChar expansionTests[], int32_t testCou
|
||||
log_err("call to iter->next() failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*if (order == UCOL_NULLORDER || ucol_next(iter, &status) != UCOL_NULLORDER) {
|
||||
ucol_reset(iter);
|
||||
log_err("verifyExpansion: \'%s\' has multiple orders\n", austrdup(test));
|
||||
}*/
|
||||
|
||||
|
||||
expansion = ucol_getMaxExpansion(iter, order);
|
||||
expect = expansionTests[i+1];
|
||||
|
||||
|
||||
if (expansion != expect) {
|
||||
log_err("Expansion for \'%s\' is wrong. Expected %d, Got %d\n", austrdup(test), expect, expansion);
|
||||
}
|
||||
@ -431,8 +433,8 @@ int32_t* getOrders(UCollationElements *iter, int32_t *orderLength)
|
||||
int32_t *orders =(int32_t*)malloc(sizeof(int32_t) * maxSize);
|
||||
status= U_ZERO_ERROR;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while ((order=ucol_next(iter, &status)) != UCOL_NULLORDER)
|
||||
{
|
||||
if (size == maxSize)
|
||||
@ -445,21 +447,21 @@ int32_t* getOrders(UCollationElements *iter, int32_t *orderLength)
|
||||
orders = temp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
orders[size++] = order;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (maxSize > size)
|
||||
{
|
||||
temp = (int32_t*)malloc(sizeof(int32_t) * size);
|
||||
|
||||
|
||||
memcpy(temp, orders, size * sizeof(int32_t));
|
||||
free(orders);
|
||||
orders = temp;
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* ucol_previous(iter, &status); */
|
||||
@ -478,7 +480,7 @@ void assertEqual(UCollationElements *i1, UCollationElements *i2)
|
||||
{
|
||||
c1 = ucol_next(i1, &status);
|
||||
c2 = ucol_next(i2, &status);
|
||||
|
||||
|
||||
if (c1 != c2)
|
||||
{
|
||||
log_err("Error in iteration %d assetEqual between\n %d and %d, they are not equal\n", count, c1, c2);
|
||||
|
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -12,12 +12,13 @@
|
||||
* Madhu Katragadda Ported for C API
|
||||
*********************************************************************************
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "cloctst.h"
|
||||
#include "unicode/uloc.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "ccolltst.h"
|
||||
|
@ -14,6 +14,9 @@
|
||||
*/
|
||||
/* C API TEST FOR MESSAGE FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/umsg.h"
|
||||
@ -22,8 +25,6 @@
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "cmsgtst.h"
|
||||
#include<stdio.h>
|
||||
#include <string.h>
|
||||
#include "cformtst.h"
|
||||
|
||||
static const char* txt_testCasePatterns[] = {
|
||||
|
@ -17,14 +17,15 @@
|
||||
|
||||
/* C DEPTH TEST FOR NUMBER FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/unum.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "cnmdptst.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CHECK(status,str) if (U_FAILURE(status)) { log_err("FAIL: %s\n", str); return; }
|
||||
|
||||
@ -64,38 +65,38 @@ void TestPatterns(void)
|
||||
u_uastrcpy(upat, pat[i]);
|
||||
fmt= unum_openPattern(upat, u_strlen(upat), "en_US", &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAIL: Number format constructor failed for pattern %s\n", pat[i]);
|
||||
continue;
|
||||
log_err("FAIL: Number format constructor failed for pattern %s\n", pat[i]);
|
||||
continue;
|
||||
}
|
||||
lneed=0;
|
||||
lneed=unum_toPattern(fmt, FALSE, NULL, lneed, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status= U_ZERO_ERROR;
|
||||
unewp=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_toPattern(fmt, FALSE, unewp, lneed+1, &status);
|
||||
status= U_ZERO_ERROR;
|
||||
unewp=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_toPattern(fmt, FALSE, unewp, lneed+1, &status);
|
||||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("FAIL: Number format extracting the pattern failed for %s\n", pat[i]);
|
||||
log_err("FAIL: Number format extracting the pattern failed for %s\n", pat[i]);
|
||||
}
|
||||
u_uastrcpy(unewpat, newpat[i]);
|
||||
if(u_strcmp(unewp, unewpat) != 0)
|
||||
log_err("FAIL: Pattern %s should be transmute to %s; %s seen instead\n", pat[i], newpat[i], austrdup(unewp) );
|
||||
|
||||
log_err("FAIL: Pattern %s should be transmute to %s; %s seen instead\n", pat[i], newpat[i], austrdup(unewp) );
|
||||
|
||||
lneed=0;
|
||||
lneed=unum_format(fmt, 0, NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_format(fmt, 0, str, lneed+1, &pos, &status);
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_format(fmt, 0, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
u_uastrcpy(unum, num[i]);
|
||||
if (u_strcmp(str, unum) != 0)
|
||||
{
|
||||
log_err("FAIL: Pattern %s should format zero as %s; %s Seen instead\n", pat[i], num[i], austrdup(str) );
|
||||
|
||||
log_err("FAIL: Pattern %s should format zero as %s; %s Seen instead\n", pat[i], num[i], austrdup(str) );
|
||||
|
||||
}
|
||||
free(unewp);
|
||||
free(str);
|
||||
@ -126,7 +127,7 @@ void TestQuotes(void)
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_format(fmt, 123, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
log_verbose("Pattern \"%s\" \n", austrdup(pat) );
|
||||
@ -137,12 +138,12 @@ void TestQuotes(void)
|
||||
|
||||
free(str);
|
||||
unum_close(fmt);
|
||||
|
||||
|
||||
|
||||
|
||||
u_uastrcpy(pat, "");
|
||||
u_uastrcpy(pat, "a''b#");
|
||||
|
||||
|
||||
|
||||
|
||||
fmt =unum_openPattern(pat, u_strlen(pat), "en_US", &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("Error in number format costruction using pattern \"a''b#\"\n");
|
||||
@ -154,7 +155,7 @@ void TestQuotes(void)
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_format(fmt, 123, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
log_verbose("Pattern \"%s\" \n", austrdup(pat) );
|
||||
@ -163,7 +164,7 @@ void TestQuotes(void)
|
||||
u_uastrcpy(res, "a'b123");
|
||||
if(u_strcmp(str, res) != 0)
|
||||
log_err("FAIL: Expected a'b123\n");
|
||||
|
||||
|
||||
free(str);
|
||||
unum_close(fmt);
|
||||
}
|
||||
@ -189,7 +190,7 @@ void TestExponential(void)
|
||||
#endif
|
||||
const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" };
|
||||
int32_t lval[] = { 0, -1, 1, 123456789 };
|
||||
|
||||
|
||||
const char* valFormat[] =
|
||||
{
|
||||
"1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271",
|
||||
@ -238,74 +239,74 @@ void TestExponential(void)
|
||||
u_uastrcpy(upat, pat[p]);
|
||||
fmt=unum_openPattern(upat, u_strlen(upat), "en_US", &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAIL: Bad status returned by Number format construction with pattern %s\n, pat[i]");
|
||||
continue;
|
||||
log_err("FAIL: Bad status returned by Number format construction with pattern %s\n, pat[i]");
|
||||
continue;
|
||||
}
|
||||
lneed= u_strlen(upat) + 1;
|
||||
unum_toPattern(fmt, FALSE, pattern, lneed, &status);
|
||||
log_verbose("Pattern \" %s \" -toPattern-> \" %s \" \n", upat, austrdup(pattern) );
|
||||
for (v=0; v<val_length; ++v)
|
||||
{
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, val[v], NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, val[v], str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
u_uastrcpy(uvalfor, valFormat[v+ival]);
|
||||
if(u_strcmp(str, uvalfor) != 0)
|
||||
log_verbose("FAIL: Expected %s ( %s )\n", valFormat[v+ival], austrdup(uvalfor) );
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, val[v], NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, val[v], str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
|
||||
/*parsing*/
|
||||
ppos=0;
|
||||
a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status);
|
||||
if (ppos== u_strlen(str)) {
|
||||
if (a != valParse[v+ival])
|
||||
printf("FAIL: Expected : %e\n", valParse[v+ival]);
|
||||
}
|
||||
else
|
||||
printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
|
||||
|
||||
free(str);
|
||||
}
|
||||
|
||||
|
||||
u_uastrcpy(uvalfor, valFormat[v+ival]);
|
||||
if(u_strcmp(str, uvalfor) != 0)
|
||||
log_verbose("FAIL: Expected %s ( %s )\n", valFormat[v+ival], austrdup(uvalfor) );
|
||||
|
||||
/*parsing*/
|
||||
ppos=0;
|
||||
a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status);
|
||||
if (ppos== u_strlen(str)) {
|
||||
if (a != valParse[v+ival])
|
||||
printf("FAIL: Expected : %e\n", valParse[v+ival]);
|
||||
}
|
||||
else
|
||||
printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
|
||||
|
||||
free(str);
|
||||
}
|
||||
for (v=0; v<lval_length; ++v)
|
||||
{
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, lval[v], NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, lval[v], str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
/*printf(" Format %e -> %s\n", lval[v], austrdup(str) );*/
|
||||
u_uastrcpy(ulvalfor, lvalFormat[v+ilval]);
|
||||
if(u_strcmp(str, ulvalfor) != 0)
|
||||
log_err("FAIL: Expected %s ( %s )\n", valFormat[v+ilval], austrdup(ulvalfor) );
|
||||
/*format*/
|
||||
lneed=0;
|
||||
lneed=unum_formatDouble(fmt, lval[v], NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, lval[v], str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
/*printf(" Format %e -> %s\n", lval[v], austrdup(str) );*/
|
||||
u_uastrcpy(ulvalfor, lvalFormat[v+ilval]);
|
||||
if(u_strcmp(str, ulvalfor) != 0)
|
||||
log_err("FAIL: Expected %s ( %s )\n", valFormat[v+ilval], austrdup(ulvalfor) );
|
||||
|
||||
/*parsing*/
|
||||
ppos=0;
|
||||
a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status);
|
||||
if (ppos== u_strlen(str)) {
|
||||
/*printf(" Parse -> %e\n", a);*/
|
||||
if (a != lvalParse[v+ilval])
|
||||
printf("FAIL: Expected : %e\n", valParse[v+ival]);
|
||||
}
|
||||
else
|
||||
printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
|
||||
|
||||
free(str);
|
||||
/*parsing*/
|
||||
ppos=0;
|
||||
a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status);
|
||||
if (ppos== u_strlen(str)) {
|
||||
/*printf(" Parse -> %e\n", a);*/
|
||||
if (a != lvalParse[v+ilval])
|
||||
printf("FAIL: Expected : %e\n", valParse[v+ival]);
|
||||
}
|
||||
else
|
||||
printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a);
|
||||
|
||||
free(str);
|
||||
|
||||
}
|
||||
ival += val_length;
|
||||
@ -342,7 +343,7 @@ void TestCurrencySign(void)
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, 1234.56, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
lneed=0;
|
||||
@ -354,7 +355,7 @@ void TestCurrencySign(void)
|
||||
}
|
||||
log_verbose("Pattern \" %s \" \n", austrdup(pat));
|
||||
log_verbose("Format 1234.56 -> %s\n", austrdup(str) );
|
||||
|
||||
|
||||
res=(UChar*)malloc(sizeof(UChar) * (strlen("$1,234.56")+1) );
|
||||
u_uastrcpy(res, "$1,234.56");
|
||||
if (u_strcmp(str, res) !=0) log_err("FAIL: Expected $1,234.56\n");
|
||||
@ -369,7 +370,7 @@ void TestCurrencySign(void)
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(fmt, -1234.56, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
res=(UChar*)malloc(sizeof(UChar) * (strlen("-$1,234.56")+1) );
|
||||
@ -397,18 +398,19 @@ void TestCurrency(void)
|
||||
for(i=0; i < 3; i++)
|
||||
{
|
||||
currencyFmt = unum_open(UNUM_CURRENCY, locale[i], &status);
|
||||
if(U_FAILURE(status)){log_err("Error in the construction of number format with style currency:\n%s\n",
|
||||
myErrorName(status));
|
||||
if(U_FAILURE(status)){
|
||||
log_err("Error in the construction of number format with style currency:\n%s\n",
|
||||
myErrorName(status));
|
||||
}
|
||||
lneed=0;
|
||||
lneed= unum_formatDouble(currencyFmt, 1.50, NULL, lneed, &pos, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status);
|
||||
status=U_ZERO_ERROR;
|
||||
str=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) );
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
res=(UChar*)malloc(sizeof(UChar) * (strlen(result[i])+1) );
|
||||
u_uastrcpy(res, result[i]);
|
||||
@ -460,7 +462,7 @@ void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits, const
|
||||
out=(UChar*)malloc(sizeof(UChar) * (lneed+1) );
|
||||
unum_formatDouble(nf, x, out, lneed+1, &pos, &status);
|
||||
}
|
||||
if(U_FAILURE(status)) {
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) );
|
||||
}
|
||||
/*Need to use log_verbose here. Problem with the float*/
|
||||
@ -478,27 +480,27 @@ void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits, const
|
||||
*/
|
||||
void TestDoubleAttribute(void)
|
||||
{
|
||||
double mydata[] = { 1.11, 22.22, 333.33, 4444.44, 55555.55, 666666.66, 7777777.77, 88888888.88, 999999999.99};
|
||||
double dvalue;
|
||||
int i;
|
||||
UErrorCode status=U_ZERO_ERROR;
|
||||
UNumberFormatAttribute attr;
|
||||
UNumberFormatStyle style= UNUM_DEFAULT;
|
||||
UNumberFormat *def;
|
||||
def=unum_open(style, NULL, &status);
|
||||
double mydata[] = { 1.11, 22.22, 333.33, 4444.44, 55555.55, 666666.66, 7777777.77, 88888888.88, 999999999.99};
|
||||
double dvalue;
|
||||
int i;
|
||||
UErrorCode status=U_ZERO_ERROR;
|
||||
UNumberFormatAttribute attr;
|
||||
UNumberFormatStyle style= UNUM_DEFAULT;
|
||||
UNumberFormat *def;
|
||||
def=unum_open(style, NULL, &status);
|
||||
log_verbose("\nTesting get and set DoubleAttributes\n");
|
||||
attr=UNUM_ROUNDING_INCREMENT;
|
||||
dvalue=unum_getDoubleAttribute(def, attr);
|
||||
for (i = 0; i<9 ; i++)
|
||||
{
|
||||
dvalue = mydata[i];
|
||||
unum_setDoubleAttribute(def, attr, dvalue);
|
||||
if(unum_getDoubleAttribute(def,attr)!=mydata[i])
|
||||
log_err("Fail: error in setting and getting double attributes for UNUM_ROUNDING_INCREMENT\n");
|
||||
else
|
||||
log_verbose("Pass: setting and getting double attributes for UNUM_ROUNDING_INCREMENT works fine\n");
|
||||
}
|
||||
unum_close(def);
|
||||
{
|
||||
dvalue = mydata[i];
|
||||
unum_setDoubleAttribute(def, attr, dvalue);
|
||||
if(unum_getDoubleAttribute(def,attr)!=mydata[i])
|
||||
log_err("Fail: error in setting and getting double attributes for UNUM_ROUNDING_INCREMENT\n");
|
||||
else
|
||||
log_verbose("Pass: setting and getting double attributes for UNUM_ROUNDING_INCREMENT works fine\n");
|
||||
}
|
||||
unum_close(def);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@
|
||||
* Madhu Katragadda Ported for C API
|
||||
*********************************************************************************/
|
||||
/*tests for u_normalization*/
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -123,8 +124,9 @@ void TestDecomp()
|
||||
assertEqual(result, CharsToUChars(canonTests[x][1]), x);
|
||||
free(result);
|
||||
}
|
||||
ucol_close(myCollation);
|
||||
ucol_close(myCollation);
|
||||
}
|
||||
|
||||
void TestCompatDecomp()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
/* C API TEST FOR NUMBER FORMAT */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/unum.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "cintltst.h"
|
||||
#include "cnumtst.h"
|
||||
#include<stdio.h>
|
||||
|
||||
/* ### remove this include after the number format test is fixed with jitterbug 411, applyPattern() */
|
||||
#include "cstring.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
/* C FUNCTIONALITY AND REGRESSION TEST FOR BREAKITERATOR */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -15,13 +15,14 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cintltst.h"
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "string.h"
|
||||
#include "cstring.h"
|
||||
#include <time.h>
|
||||
|
||||
#define RESTEST_HEAP_CHECK 0
|
||||
|
||||
@ -289,329 +290,327 @@ UBool testTag(const char* frag,
|
||||
UBool in_te,
|
||||
UBool in_te_IN)
|
||||
{
|
||||
UBool pass=TRUE;
|
||||
UBool pass=TRUE;
|
||||
|
||||
/* Make array from input params */
|
||||
/* Make array from input params */
|
||||
|
||||
UBool is_in[3];
|
||||
const char *NAME[] = { "ROOT", "TE", "TE_IN" };
|
||||
UBool is_in[3];
|
||||
const char *NAME[] = { "ROOT", "TE", "TE_IN" };
|
||||
|
||||
/* Now try to load the desired items */
|
||||
UResourceBundle* theBundle = NULL;
|
||||
char tag[99];
|
||||
char action[256];
|
||||
UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR;
|
||||
UChar* base = NULL;
|
||||
UChar* expected_string = NULL;
|
||||
const UChar* string = NULL;
|
||||
char buf[5];
|
||||
char item_tag[10];
|
||||
int32_t i,j,k,row,col;
|
||||
int32_t actual_bundle;
|
||||
int32_t count = 0;
|
||||
int32_t row_count=0;
|
||||
int32_t column_count=0;
|
||||
int32_t index = 0;
|
||||
char testdatapath[256];
|
||||
/* Now try to load the desired items */
|
||||
UResourceBundle* theBundle = NULL;
|
||||
char tag[99];
|
||||
char action[256];
|
||||
UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR;
|
||||
UChar* base = NULL;
|
||||
UChar* expected_string = NULL;
|
||||
const UChar* string = NULL;
|
||||
char buf[5];
|
||||
char item_tag[10];
|
||||
int32_t i,j,k,row,col;
|
||||
int32_t actual_bundle;
|
||||
int32_t count = 0;
|
||||
int32_t row_count=0;
|
||||
int32_t column_count=0;
|
||||
int32_t index = 0;
|
||||
char testdatapath[256];
|
||||
|
||||
const char* directory = ctest_getTestDirectory();
|
||||
const char* directory = ctest_getTestDirectory();
|
||||
|
||||
uprv_strcpy(testdatapath, directory);
|
||||
uprv_strcat(testdatapath, "testdata");
|
||||
uprv_strcpy(testdatapath, directory);
|
||||
uprv_strcat(testdatapath, "testdata");
|
||||
|
||||
is_in[0] = in_Root;
|
||||
is_in[1] = in_te;
|
||||
is_in[2] = in_te_IN;
|
||||
is_in[0] = in_Root;
|
||||
is_in[1] = in_te;
|
||||
is_in[2] = in_te_IN;
|
||||
|
||||
strcpy(item_tag, "tag");
|
||||
strcpy(item_tag, "tag");
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
theBundle = ures_open(testdatapath, "root", &status);
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
ures_close(theBundle);
|
||||
log_err("Couldn't open root bundle in %s", testdatapath);
|
||||
return FALSE;
|
||||
}
|
||||
ures_close(theBundle);
|
||||
theBundle = NULL;
|
||||
|
||||
|
||||
for (i=0; i<bundles_count; ++i)
|
||||
status = U_ZERO_ERROR;
|
||||
theBundle = ures_open(testdatapath, "root", &status);
|
||||
if(U_FAILURE(status))
|
||||
{
|
||||
strcpy(action,"construction for");
|
||||
strcat(action, param[i].name);
|
||||
ures_close(theBundle);
|
||||
log_err("Couldn't open root bundle in %s", testdatapath);
|
||||
return FALSE;
|
||||
}
|
||||
ures_close(theBundle);
|
||||
theBundle = NULL;
|
||||
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
theBundle = ures_open(testdatapath, param[i].name, &status);
|
||||
/*theBundle = ures_open("c:\\icu\\icu\\source\\test\\testdata\\testdata", param[i].name, &status);*/
|
||||
|
||||
CONFIRM_ErrorCode(status,param[i].expected_constructor_status);
|
||||
|
||||
|
||||
|
||||
if(i == 5)
|
||||
actual_bundle = 0; /* ne -> default */
|
||||
else if(i == 3)
|
||||
actual_bundle = 1; /* te_NE -> te */
|
||||
else if(i == 4)
|
||||
actual_bundle = 2; /* te_IN_NE -> te_IN */
|
||||
else
|
||||
actual_bundle = i;
|
||||
|
||||
expected_resource_status = U_MISSING_RESOURCE_ERROR;
|
||||
for (j=e_te_IN; j>=e_Root; --j)
|
||||
{
|
||||
if (is_in[j] && param[i].inherits[j])
|
||||
{
|
||||
|
||||
if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */
|
||||
expected_resource_status = U_ZERO_ERROR;
|
||||
else if(j == 0)
|
||||
expected_resource_status = U_USING_DEFAULT_ERROR;
|
||||
else
|
||||
expected_resource_status = U_USING_FALLBACK_ERROR;
|
||||
|
||||
log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n",
|
||||
param[i].name,
|
||||
i,
|
||||
frag,
|
||||
j,
|
||||
is_in[j]?"Yes":"No",
|
||||
j,
|
||||
param[i].inherits[j]?"Yes":"No",
|
||||
param[actual_bundle].name);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=param[i].where; j>=0; --j)
|
||||
{
|
||||
if (is_in[j])
|
||||
{
|
||||
if(base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
|
||||
base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1));
|
||||
u_uastrcpy(base,NAME[j]);
|
||||
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if(base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
base = (UChar*) malloc(sizeof(UChar) * 1);
|
||||
*base = 0x0000;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* string */
|
||||
|
||||
strcpy(tag,"string_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".ures_get(" );
|
||||
strcat(action,tag);
|
||||
strcat(action, ")");
|
||||
|
||||
string= kERROR;
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
ures_get(theBundle, tag, &status);
|
||||
if(U_SUCCESS(status))
|
||||
{
|
||||
status = U_ZERO_ERROR;
|
||||
string=ures_get(theBundle, tag, &status);
|
||||
}
|
||||
|
||||
log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status);
|
||||
|
||||
CONFIRM_ErrorCode(status, expected_resource_status);
|
||||
|
||||
|
||||
if(U_SUCCESS(status)){
|
||||
expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 3));
|
||||
u_strcpy(expected_string,base);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
for (i=0; i<bundles_count; ++i)
|
||||
{
|
||||
expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1));
|
||||
u_strcpy(expected_string,kERROR);
|
||||
strcpy(action,"construction for");
|
||||
strcat(action, param[i].name);
|
||||
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
theBundle = ures_open(testdatapath, param[i].name, &status);
|
||||
/*theBundle = ures_open("c:\\icu\\icu\\source\\test\\testdata\\testdata", param[i].name, &status);*/
|
||||
|
||||
CONFIRM_ErrorCode(status,param[i].expected_constructor_status);
|
||||
|
||||
|
||||
|
||||
CONFIRM_EQ(string, expected_string);
|
||||
if(i == 5)
|
||||
actual_bundle = 0; /* ne -> default */
|
||||
else if(i == 3)
|
||||
actual_bundle = 1; /* te_NE -> te */
|
||||
else if(i == 4)
|
||||
actual_bundle = 2; /* te_IN_NE -> te_IN */
|
||||
else
|
||||
actual_bundle = i;
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* arrayItem */
|
||||
|
||||
strcpy(tag,"array_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".ures_getArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
count=ures_countArrayItems(theBundle, tag, &status);
|
||||
|
||||
|
||||
for(j = 0; j < count; j++)
|
||||
expected_resource_status = U_MISSING_RESOURCE_ERROR;
|
||||
for (j=e_te_IN; j>=e_Root; --j)
|
||||
{
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
|
||||
index=j;
|
||||
ures_getArrayItem(theBundle, tag,index , &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getArrayItem(theBundle, tag, index, &status);
|
||||
|
||||
|
||||
/* how could 'index==j' ever be >= count ? */
|
||||
expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
log_verbose("Status for %s was %d, expected %d\n", action, status, expected_status);
|
||||
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
if (is_in[j] && param[i].inherits[j])
|
||||
{
|
||||
UChar element[3];
|
||||
|
||||
u_uastrcpy(element, itoa1(index,buf));
|
||||
|
||||
u_strcpy(expected_string,base);
|
||||
u_strcat(expected_string,element);
|
||||
if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */
|
||||
expected_resource_status = U_ZERO_ERROR;
|
||||
else if(j == 0)
|
||||
expected_resource_status = U_USING_DEFAULT_ERROR;
|
||||
else
|
||||
expected_resource_status = U_USING_FALLBACK_ERROR;
|
||||
|
||||
log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n",
|
||||
param[i].name,
|
||||
i,
|
||||
frag,
|
||||
j,
|
||||
is_in[j]?"Yes":"No",
|
||||
j,
|
||||
param[i].inherits[j]?"Yes":"No",
|
||||
param[actual_bundle].name);
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
for (j=param[i].where; j>=0; --j)
|
||||
{
|
||||
if (is_in[j])
|
||||
{
|
||||
u_strcpy(expected_string,kERROR);
|
||||
if(base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
|
||||
base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1));
|
||||
u_uastrcpy(base,NAME[j]);
|
||||
|
||||
break;
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
else {
|
||||
if(base != NULL) {
|
||||
free(base);
|
||||
base = NULL;
|
||||
}
|
||||
base = (UChar*) malloc(sizeof(UChar) * 1);
|
||||
*base = 0x0000;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* string */
|
||||
|
||||
strcpy(tag,"string_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".ures_get(" );
|
||||
strcat(action,tag);
|
||||
strcat(action, ")");
|
||||
|
||||
string= kERROR;
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
ures_get(theBundle, tag, &status);
|
||||
if(U_SUCCESS(status))
|
||||
{
|
||||
status = U_ZERO_ERROR;
|
||||
string=ures_get(theBundle, tag, &status);
|
||||
}
|
||||
|
||||
log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status);
|
||||
|
||||
CONFIRM_ErrorCode(status, expected_resource_status);
|
||||
|
||||
|
||||
if(U_SUCCESS(status)){
|
||||
expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 3));
|
||||
u_strcpy(expected_string,base);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1));
|
||||
u_strcpy(expected_string,kERROR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* 2dArrayItem */
|
||||
|
||||
strcpy(tag,"array_2d_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".get2dArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
row_count=ures_countArrayItems(theBundle, tag, &status);
|
||||
column_count=2;
|
||||
|
||||
for(k=0;k<row_count;k++){
|
||||
for (j=0; j<column_count; ++j){
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
row=k;
|
||||
col=j;
|
||||
ures_get2dArrayItem( theBundle, tag, row, col, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_get2dArrayItem(theBundle, tag, row, col, &status);
|
||||
|
||||
|
||||
expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ?
|
||||
expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
UChar element[3];
|
||||
u_strcpy(expected_string,base);
|
||||
u_uastrcpy(element,itoa1(row,buf));
|
||||
u_strcat(expected_string, element);
|
||||
u_uastrcpy(element,itoa1(col,buf));
|
||||
u_strcat(expected_string, element);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
u_strcpy(expected_string,kERROR);
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
CONFIRM_EQ(string, expected_string);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* taggedArrayItem */
|
||||
/*-------------------------------------------------------------------- */
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* arrayItem */
|
||||
|
||||
strcpy(tag,"tagged_array_");
|
||||
strcat(tag,frag);
|
||||
strcpy(tag,"array_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action,".getTaggedArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action,")");
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".ures_getArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
count=ures_countArrayItems(theBundle, tag, &status);
|
||||
|
||||
count = 0;
|
||||
for (index=-20; index<20; ++index)
|
||||
|
||||
for(j = 0; j < count; j++)
|
||||
{
|
||||
strcpy(item_tag, "tag");
|
||||
strcat(item_tag, itoa1(index,buf));
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
|
||||
index=j;
|
||||
ures_getArrayItem(theBundle, tag,index , &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getArrayItem(theBundle, tag, index, &status);
|
||||
|
||||
|
||||
ures_getTaggedArrayItem( theBundle, tag, item_tag, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getTaggedArrayItem(theBundle, tag, item_tag, &status);
|
||||
/* how could 'index==j' ever be >= count ? */
|
||||
expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
log_verbose("Status for %s was %d, expected %d\n", action, status, expected_status);
|
||||
|
||||
if (index < 0)
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
CONFIRM_ErrorCode(status,U_MISSING_RESOURCE_ERROR);
|
||||
UChar element[3];
|
||||
|
||||
u_uastrcpy(element, itoa1(index,buf));
|
||||
|
||||
u_strcpy(expected_string,base);
|
||||
u_strcat(expected_string,element);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
UChar* element;
|
||||
if (strcmp(myErrorName(status),"U_MISSING_RESOURCE_ERROR")!=0) {
|
||||
count++;
|
||||
u_strcpy(expected_string,base);
|
||||
element=(UChar*)malloc(sizeof(UChar) * (strlen(buf)+1));
|
||||
u_uastrcpy(element,buf);
|
||||
u_strcat(expected_string,element);
|
||||
free(element);
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
u_strcpy(expected_string,kERROR);
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
|
||||
free(expected_string);
|
||||
ures_close(theBundle);
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* 2dArrayItem */
|
||||
|
||||
strcpy(tag,"array_2d_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".get2dArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
row_count=ures_countArrayItems(theBundle, tag, &status);
|
||||
column_count=2;
|
||||
|
||||
for(k=0;k<row_count;k++){
|
||||
for (j=0; j<column_count; ++j){
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
row=k;
|
||||
col=j;
|
||||
ures_get2dArrayItem( theBundle, tag, row, col, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_get2dArrayItem(theBundle, tag, row, col, &status);
|
||||
|
||||
|
||||
expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ?
|
||||
expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
UChar element[3];
|
||||
u_strcpy(expected_string,base);
|
||||
u_uastrcpy(element,itoa1(row,buf));
|
||||
u_strcat(expected_string, element);
|
||||
u_uastrcpy(element,itoa1(col,buf));
|
||||
u_strcat(expected_string, element);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
u_strcpy(expected_string,kERROR);
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* taggedArrayItem */
|
||||
|
||||
strcpy(tag,"tagged_array_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action,".getTaggedArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action,")");
|
||||
|
||||
count = 0;
|
||||
for (index=-20; index<20; ++index)
|
||||
{
|
||||
strcpy(item_tag, "tag");
|
||||
strcat(item_tag, itoa1(index,buf));
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
|
||||
|
||||
ures_getTaggedArrayItem( theBundle, tag, item_tag, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getTaggedArrayItem(theBundle, tag, item_tag, &status);
|
||||
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
CONFIRM_ErrorCode(status,U_MISSING_RESOURCE_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
UChar* element;
|
||||
if (strcmp(myErrorName(status),"U_MISSING_RESOURCE_ERROR")!=0) {
|
||||
count++;
|
||||
u_strcpy(expected_string,base);
|
||||
element=(UChar*)malloc(sizeof(UChar) * (strlen(buf)+1));
|
||||
u_uastrcpy(element,buf);
|
||||
u_strcat(expected_string,element);
|
||||
free(element);
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free(expected_string);
|
||||
ures_close(theBundle);
|
||||
}
|
||||
free(base);
|
||||
return pass;
|
||||
free(base);
|
||||
return pass;
|
||||
}
|
||||
|
||||
void record_pass()
|
||||
@ -634,7 +633,7 @@ void TestFallback()
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UResourceBundle *fr_FR = NULL;
|
||||
const UChar *junk; /* ignored */
|
||||
|
||||
|
||||
log_verbose("Opening fr_FR..");
|
||||
fr_FR = ures_open(NULL, "fr_FR", &status);
|
||||
if(U_FAILURE(status))
|
||||
@ -659,9 +658,9 @@ void TestFallback()
|
||||
if(status != U_USING_DEFAULT_ERROR)
|
||||
{
|
||||
log_err("Expected U_USING_DEFAULT_ERROR when trying to get Version from fr_FR, got %d\n",
|
||||
status);
|
||||
status);
|
||||
}
|
||||
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
/* and this is a Fallback, to fr */
|
||||
@ -669,10 +668,10 @@ void TestFallback()
|
||||
if(status != U_USING_FALLBACK_ERROR)
|
||||
{
|
||||
log_err("Expected U_USING_FALLBACK_ERROR when trying to get ShortLanguage from fr_FR, got %d\n",
|
||||
status);
|
||||
status);
|
||||
}
|
||||
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
ures_close(fr_FR);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/uchar.h"
|
||||
|
@ -18,6 +18,8 @@
|
||||
* collation rules as its sorting sequence.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/uloc.h"
|
||||
@ -25,7 +27,6 @@
|
||||
#include "encoll.h"
|
||||
#include "ccolltst.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include <string.h>
|
||||
|
||||
static UCollator *myCollation = NULL;
|
||||
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
|
||||
|
@ -13,10 +13,11 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cintltst.h"
|
||||
#include "umemstrm.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void TestMemoryStreamAPI();
|
||||
static void printUSeqErr(const uint8_t *a, int len);
|
||||
|
@ -13,12 +13,13 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "cintltst.h"
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void TestPUtilAPI();
|
||||
void testIEEEremainder();
|
||||
|
Loading…
Reference in New Issue
Block a user