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:
George Rhoten 2000-08-28 21:43:03 +00:00
parent bd94ac5ec8
commit 9253fe4dd3
30 changed files with 1079 additions and 1047 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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**);

View File

@ -13,6 +13,8 @@
*********************************************************************************
*/
#include <memory.h>
#include <stdlib.h>
#include "unicode/utypes.h"
#include "unicode/ucol.h"
#include "unicode/uloc.h"

View File

@ -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] = {

View File

@ -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"

View File

@ -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"

View File

@ -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)
{

View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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,15 +30,15 @@ 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++)

View File

@ -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"

View File

@ -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] = {

View File

@ -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"

View File

@ -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"
@ -387,7 +389,7 @@ 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)) {

View File

@ -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"

View File

@ -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"

View File

@ -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[] = {

View File

@ -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,37 +65,37 @@ 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);
@ -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) );
@ -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) );
@ -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) );
}
/*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) );
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);
/*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);
}
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);
/*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);
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;
@ -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);
}
/**

View File

@ -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"
@ -125,6 +126,7 @@ void TestDecomp()
}
ucol_close(myCollation);
}
void TestCompatDecomp()
{
UErrorCode status = U_ZERO_ERROR;

View File

@ -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"

View File

@ -15,6 +15,7 @@
/* C FUNCTIONALITY AND REGRESSION TEST FOR BREAKITERATOR */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unicode/uloc.h"

View File

@ -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
{
u_strcpy(expected_string,kERROR);
}
CONFIRM_EQ(string,expected_string);
}
/*-------------------------------------------------------------------- */
/* 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);
}
}
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(expected_string);
ures_close(theBundle);
}
free(base);
return pass;
free(base);
return pass;
}
void record_pass()
@ -659,7 +658,7 @@ 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;
@ -669,7 +668,7 @@ 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;

File diff suppressed because it is too large Load Diff

View File

@ -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"

View File

@ -13,6 +13,7 @@
*********************************************************************************
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unicode/uchar.h"

View File

@ -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] = {

View File

@ -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);

View File

@ -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();