/* ********************************************************************** * * Copyright (C) 2000-2004, X.Net, Inc. Lafayette, California, USA * * Open source license http://www.opensource.org/licenses/xnet.html * * File Utest.c/Xtest.c * * Modification History: * * Date Name Description * 04/03/00 Carl Brown New * 04/20/00 Carl Brown Solaris test * 04/27/00 Carl Brown Linux test * 05/15/00 Carl Brown New xiua curr_date * 06/02/00 Carl Brown ScanDir test * 06/05/00 Carl Brown New collate test * 06/09/00 Carl Brown Browser locale test * 11/09/00 Carl Brown UTF-8/UTF-16/Codepage Multimode support * 08/02/01 brown xIUA 3.0 initial testing complete * 10/10/01 brown xIUA 3.1 complete * 12/06/01 brown xIUA 3.2 complete * 10/03/02 brown xIUA 3.3 complete * 12/17/02 brown xIUA 3.4 complete * 06/24/03 brown xIUA 3.5 complete (ICU 2.6 support) * 02/05/04 brown xIUA 3.6 complete (ICU 2.8 support) * 02/22/04 brown Filter times zones and build tz offset table * * Test main routine * ******************************************************************************* */ #include #include #include #include #if defined(WIN32) # include # include #endif #include "xiua.h" #include "unicode/utypes.h" #include "unicode/putil.h" #include "unicode/uloc.h" #include "unicode/ustring.h" static UErrorCode * icu_err; static int line; static XIUA_Locale * Default; static XIUA_Locale * Current; static XIUA_Locale * LocJP_u2; static XIUA_Locale * LocJP_u4; static XIUA_Locale * LocJP_u8; static XIUA_Locale * LocJP_win; static XIUA_Locale * LocJP_unix; static XIUA_Locale ** LocJP_list[5]; static char LocJPWin[] = "ja_JP.Shift_JIS"; static char LocJPUnix[] = "ja_JP.EUC-JP"; static char LocJP2022[] = "ja_JP.ISO-2022-JP"; static char LocCN[] = "zh_CN.gb18030"; static char LocFR[] = "fr_FR.iso-8859-1"; static char LocSA[] = "ar_SA.cp1256"; static char LocBR[] = "pt_BR.utf-8"; #if defined(WIN32) static char LocUS[] = "en_US.cp1252"; static char LocTR[] = "tr_TR.cp1254"; static char LocCH[] = "de_CH.cp1252"; #else static char LocUS[] = "en_US.iso-8859-15"; static char LocTR[] = "tr_TR.iso-8859-9"; static char LocCH[] = "de_CH.iso-8859-15"; #endif typedef struct Loc_list { char *dfmt; } Loc_list; Loc_list Loc_DataFormat[] = { "UTF-16", "UTF-32", "UTF-8", "Shift_JIS", "EUC-JP" }; static char test_buff[256]; static char data_buff[256]; static UChar work_ubuff[256]; static char p1_buff[1024]; static char p2_buff[1024]; static char r1_buff[1024]; static char * p1_addr; static char * p2_addr; static char * r1_addr; static UChar r1_ubuff[256]; static char *big_buff1; static char *big_buff2; static char *big_buff3; static int big_size; static int big_sizes[5] = {9758, 19516, 12971, 8925, 8925}; static unsigned char grchars[]= {0x21, 0x7D, 0xA1, 0xDF, 0x20, 0x09, 0x41, 0x61, 0x1B, 0xA0, 0x00}; /* Greeking test chars */ static unsigned char grchars1[]="7frq"; /* Greeking test line */ static unsigned char grline[]="Mixed char & 1234567890 number test line "; /* Greeking test line */ static unsigned char grline1[]=" This is a - strtok test "; /* Greeking test line */ static int32_t GreekedText(char * dst, size_t dsize,char *src, UChar * wrk); static void runTesta(char * name, int * line); static void runTestb(char * name, int * line); static void runTestc(char * name, int * line); static void runTestd(char * name, int * line); #if 0 static int32_t ToAsciiHex(char *target, /* ASCII hex output area must be 2*sourceLen long */ void * source, /* input source data */ int32_t sourceLen); /* number of bytes to process */ static int32_t ToEbcdicHex (char *target, /* EBCDIC hex output area must be 2*sourceLen long */ void * source, /* input source data */ int32_t sourceLen); /* number of bytes to process */ static unsigned char asciihex[16] = {0x30,0x31,0x32,0x33,0x34, 0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46}; static unsigned char ebchex[16] = {0xF0,0xF1,0xF2,0xF3,0xF4, 0xF5,0xF6,0xF7,0xF8,0xF9,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6}; static unsigned char hextab[256]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY #define ToHex(t,s,l) ToEbcdicHex(t,s,l) #else #define ToHex(t,s,l) ToAsciiHex(t,s,l) #endif #endif int main(int argc, char **argv); int main(int argc, char **argv) { double MyFlt = 1234567.89; int32_t MyNum = 123456789; UBool TestA; int ch; double a; int32_t i, j, k, l, m; int32_t numCnt, totCnt, maxCnt, avgCnt; uint32_t maxSize; char *arg; char **addr_list; time_t currtime = 0; int32_t dirLevel = 0; /* index level of locale in directory */ char date_fmt[]="'Test date\\u003A' yyyy-MM-dd HH:mm:ss z"; /* custom format */ char ucline[]="weiskopf - tHis lInE SHOULD *be* in caps"; /* UC line */ char uclinex[]="WEISSKOPF - THIS LINE SHOULD *BE* IN CAPS"; /* UC line test*/ char ucliney[]="WEISKOPF - THIS LINE SHOULD *BE* IN CAPS"; /* UC line test*/ char lcline[]="loWER_CAse line TEST "; /* LC line */ UChar eurolineU16[]= {0x0045, 0x0075, 0x0072, 0x006F, 0x003D, 0x20AC, 0x0020, 0x0000}; /* Euro= */ CpCharU eurolineGB[]={0x45, 0x75, 0x72, 0x6F, 0x3D, 0xA2, 0xE3, 0x20, 0x00}; /* Euro= results test */ char eurolineICU[]="Euro=%U20AC "; /* Euro= results test */ char eurolineJAVA[]="Euro=\\u20AC "; /* Euro= results test */ char eurolineC[]="Euro=\\u20AC "; /* Euro= results test */ char eurolineDEC[]="Euro=€ "; /* Euro= results test */ char eurolineHEX[]="Euro=€ "; /* Euro= results test */ char eurolineSKIP[]="Euro= "; /* Euro= results test */ /* char lclinex[]="lower_case line test "; ** LC line */ UChar arnumU16[]= {0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0x0000}; /* Arabic indic digits 123456789 */ UChar iilineU16[]= {0x0069, 0x0130, 0x0131, 0x0049, 0x0000}; /* Turkish locale in UTF-16 */ UChar iitesttU16[]= {0x0130, 0x0130, 0x0049, 0x0049, 0x00000, 0x0069, 0x0069, 0x0131, 0x0131, 0x0000}; UChar8U iilineU8[]= {0x69, 0xC4, 0xB0, 0xC4, 0xB1, 0x49, 0x00}; /* other locale in UTF-8 */ #if (XIUA_ICU_LEVEL < 4) /* Other locale in UTF-16 */ /* UChar iitestoU16[]= {0x0049, 0x0130, 0x0049, 0x0049, 0x00000, 0x0069, 0x0069, 0x0131, 0x0069, 0x0000}; */ UChar8U iitestoU8[]= {0x49, 0xC4, 0xB0, 0x49, 0x49, 0x00, 0x69, 0x69, 0xC4, 0xB1, 0x69, 0x00}; #else /* Other locale in UTF-16 */ /* UChar iitestoU16[]= {0x0049, 0x0130, 0x0049, 0x0049, 0x00000, 0x0069, 0x0069, 0x0307, 0x0131, 0x0069, 0x0000}; */ UChar8U iitestoU8[]= {0x49, 0xC4, 0xB0, 0x49, 0x49, 0x00, 0x69, 0x69, 0xCC, 0x87, 0xC4, 0xB1, 0x69, 0x00}; #endif UChar8U badlineU8[]= {0xF6, 0xAC, 0xAE, 0xBC, 0x00}; /* bad UTF-8 */ /* CpCharU iiline[]= {0x69, 0xDD, 0xFD, 0x49, 0x00}; ** Turkish eyes */ /* CpCharU iitestt[]= {0xDD, 0xDD, 0x49, 0x49, 0x00, 0x69, 0x69, 0xFD, 0xFD, 0x00}; ** Turkish locale */ /* CpCharU iitesto[]= {0x49, 0xDD, 0x49, 0x49, 0x00, 0x69, 0x69, 0xFD, 0x69, 0x00}; ** other locale */ char coll_stra[7][20] = {{"Blackbird Accent"}, {"Blackbird Accent"}, {"black-bird accent"}, {"Blackbird Accent"}, {"Blackbird Accent"}, {"Blackbird Accent"}, {"Blackbird Accent"}}; char coll_strb[7][20] = {{"Black-bird accent"}, {"Blackbird Áccent"}, {"Black-Bird Accent"}, {"Blackbird accent"}, {"Blackbird áccent"}, {"blackbird accent"}, {"Blackbird Accent "}}; char coll_comp[7][3] = {"==","<=",">=","!="," <"," >","=="}; char coll_option[4] = "==?"; char coll_opt[4][2] = {"?", " ", ":","#"}; int32_t coll_test[4][7] = { {1,1,1,0,0,0,1}, {0,1,0,1,1,1,0}, {0,1,1,0,1,0,0}, {0,1,0,1,1,1,0} }; UChar32 sglineU32[]= {0x0010FFFF, 0x00010000, 0x0000FFFF, 0x000007FF, 0x0000007F, 0x00000000}; /* UTF-32 codes */ char user_locale[XIUA_MAXFULLLOCALESIZE]="en_US"; /* Default */ char brow_locale[XIUA_MAXLOCALESIZE]; char list_locale[XIUA_MAXLOCALESIZE]; char samp_dir[]="D:\\test\\en_us\\sample\\dir\\test.php3"; /* test prog */ char accept_lang[]="pt-br-euro,ko;q=0.4,en,de;q=0.5"; /* browser accept language */ char accept_charset[]="iso-8859-15,iso-8859-1,euc-jp;q=0.4,shift_jis;q=0.8,*;q=0.2"; /* browser accept charset */ /* char gmttzone[]="Africa/Casablanca"; ** GMT time zone */ char psttzone[]="America/Los_Angeles"; /* PST time zone */ char list_tzone[XIUA_MAXTIMEZONESIZE]; addr_list = argv; /* xiua_init(); */ line = 21; xiua_SetTZone(NULL,psttzone); xiua_GetLocaleName (user_locale,64,NULL); printf("System locale: %s \n",user_locale); line--; icu_err = xiua_CurrentStatus(); if (U_FAILURE(*icu_err)) { printf("Err:%d Build System locale \n",*icu_err); line--; } if (argc > 1) { /* parse the options */ for(i = 1; i < argc; i++) { arg = argv[i]; dirLevel = xiua_ScanDir (brow_locale, arg); } } TestA = xiua_ChkLocale(brow_locale,"de--phonebook",XLOC_MATCH_LANG); TestA = (UBool)(TestA && *icu_err == U_ZERO_ERROR); TestA = (UBool)(TestA && xiua_ChkLocale(brow_locale,"de-phonebook",XLOC_MATCH_LANG)); TestA = (UBool)(TestA && *icu_err == U_USING_FALLBACK_WARNING); TestA = (UBool)(TestA && xiua_ChkLocale(brow_locale,"en-us-euro",XLOC_MATCH_LANG)); TestA = (UBool)(TestA && *icu_err == U_USING_FALLBACK_WARNING); TestA = (UBool)(TestA && xiua_ChkLocale(brow_locale,"en-mx",XLOC_MATCH_LANG)); TestA = (UBool)(TestA && *icu_err == U_USING_FALLBACK_WARNING); if (TestA) { printf("Passed - xiua_ChkLocale test\n"); } else { printf("Failed - xiua_ChkLocale test\n"); } line--; dirLevel = xiua_ScanDir(brow_locale, samp_dir); printf("xiua_ScanDir: %s Level=%d %s\n",brow_locale,dirLevel,samp_dir); line--; xiua_AcceptLanguage((char *)r1_buff, accept_lang); xiua_FindLocaleFromLang (brow_locale, (char *)r1_buff); printf("xiua_AcceptLanguage: %s (%s) %s\n",brow_locale,r1_buff,accept_lang); line--; printf("accept-charset: %s\n",accept_charset); line--; xiua_AcceptCharset((char *)r1_buff, brow_locale, accept_charset); printf("xiua_AcceptCharset: %s (%s)\n",r1_buff,brow_locale); line--; xiua_AcceptCharset((char *)r1_buff, "ja_JP", accept_charset); printf("xiua_AcceptCharset: %s (%s)\n",r1_buff,"ja_JP"); line--; xiua_AcceptCharset((char *)r1_buff, "zh_HK", accept_charset); printf("xiua_AcceptCharset: %s (%s)\n",r1_buff,"zh_HK"); line--; xiua_OpenLocale(LocUS,XDFCODEPAGE); Current = xiua_SetLocaleHdl(NULL); Default = xiua_SetLocaleClassHdl(Current,XLCDEFAULT); xiua_OpenLocale(LocJPWin,XDFUTF16); GreekedText(data_buff, 256, (char *)grline1, work_ubuff); xiua_CloseLocale(LocJPWin,XDFUTF16,XLCNONE); Current = xiua_OpenLocale(LocJPWin,XDFCODEPAGE); xiua_UTF16toChar(p1_buff,1024,(UChar *)data_buff,-1); xiua_RomanDigitStr(p1_buff); TestA = (UBool)(strcmp((const char *)grline1,p1_buff) == 0); /* xiua_SetLocaleInvalidCharHdl(Current,XICNO_FALLBACK); xiua_UTF16toChar(p1_buff,1024,(UChar *)data_buff,-1); xiua_RomanDigitStr(p1_buff); TestA = (UBool)(TestA && (strcmp((const char *)grline1,p1_buff) != 0)); */ xiua_CloseLocale(LocJPWin,XDFCODEPAGE,XLCNONE); xiua_OpenLocale(LocCN,XDFCODEPAGE); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp((const char *)eurolineGB,r1_buff) == 0)); xiua_CloseLocale(LocCN,XDFCODEPAGE,XLCNONE); Current = xiua_OpenLocale(LocFR,XDFCODEPAGE); xiua_SetLocaleInvalidCharHdl(Current,XICFROM_U_ESCAPE_ICU); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineICU,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICFROM_U_ESCAPE_JAVA); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineJAVA,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICFROM_U_ESCAPE_C); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineC,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICFROM_U_ESCAPE_XML_DEC); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineDEC,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICFROM_U_ESCAPE_XML_HEX); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineHEX,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICSKIP); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (strcmp(eurolineSKIP,r1_buff) == 0)); xiua_SetLocaleInvalidCharHdl(Current,XICSTOP); xiua_UTF16toChar(r1_buff,1024,eurolineU16,-1); TestA = (UBool)(TestA && (U_FAILURE(*icu_err))); xiua_CloseLocale(LocFR,XDFCODEPAGE,XLCNONE); xiua_OpenLocale(LocBR,XDFCODEPAGE); xiua_UTF8toChar(r1_buff,1024,(char *)iilineU8,-1); TestA = (UBool)(TestA && (strcmp((const char *)iilineU8,r1_buff) == 0)); xiua_ChartoUTF8(r1_buff,1024,(char *)iilineU8,-1); TestA = (UBool)(TestA && (strcmp((const char *)iilineU8,r1_buff) == 0)); Current = xiua_CloseLocale(LocBR,XDFCODEPAGE,XLCNONE); if (TestA) { printf("Passed - Basic converter tests\n"); } else { printf("Failed - Basic converter tests\n"); } line--; xiua_OpenLocale(LocJP2022,XDFCODEPAGE); *icu_err = 0; i = xiua_CharLen(lcline); TestA = (UBool)(*icu_err > 0); *icu_err = 0; i = xiua_CharCnt(lcline,10); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_CharNext(lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_CharPrev(lcline+8,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_ValidateStr(lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_FixStr(lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_strncpyEx(r1_buff,lcline,10); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_strncatEx(r1_buff,lcline,10); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_strchrEx(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_strstr(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_strpbrk(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_strspn(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; i = xiua_strcspn(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); *icu_err = 0; p1_addr = xiua_strtok(lcline,lcline); TestA = (UBool)(TestA && (*icu_err > 0)); if (TestA) { printf("Passed - ISO-2022 screening test\n"); } else { printf("Failed - ISO-2022 screening test\n"); } line--; strcpy((char *)p1_buff,(const char *)iilineU8); strcat((char *)p1_buff,(const char *)badlineU8); i = xiu8_ValidateStr((UChar8 *)p1_buff); xiua_CloseLocale(LocJP2022,XDFCODEPAGE,XLCDEFAULT); xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPWin,XDFUTF16),XLCDATABASE); LocJP_u2 = xiua_GetLocaleClassHdl(XLCDATABASE); LocJP_list[0] = &LocJP_u2; xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPWin,XDFUTF32),XLCSECONDARY); LocJP_u4 = xiua_GetLocaleClassHdl(XLCSECONDARY); LocJP_list[1] = &LocJP_u4; xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPWin,XDFUTF8),XLCSQL); LocJP_u8 = xiua_GetLocaleClassHdl(XLCSQL); LocJP_list[2] = &LocJP_u8; xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPWin,XDFCPWIN),XLCBROWSER); LocJP_win = xiua_GetLocaleClassHdl(XLCBROWSER); LocJP_list[3] = &LocJP_win; xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPUnix,XDFCPUNIX),XLCHTML); LocJP_unix = xiua_GetLocaleClassHdl(XLCHTML); LocJP_list[4] = &LocJP_unix; xiua_SetLocaleClassHdl(xiua_OpenLocale(LocJPWin,XDFCODEPAGE),XLCPRIMARY); for (j=0;j<4;j++) { xiua_SetLocaleHdl(*LocJP_list[j]); strcpy(test_buff,"Roman Test "); strcat(test_buff,Loc_DataFormat[j].dfmt); runTesta(test_buff, &line); } for (j=0;j<4;j++) { xiua_SetLocaleHdl(*LocJP_list[j]); strcpy(test_buff,"String Test "); strcat(test_buff,Loc_DataFormat[j].dfmt); runTestb(test_buff, &line); } for (j=0;j<4;j++) { xiua_SetLocaleHdl(*LocJP_list[j]); strcpy(test_buff,"Token Test "); strcat(test_buff,Loc_DataFormat[j].dfmt); runTestc(test_buff, &line); } while (line >= 0) { printf(" \n"); line--; } ch = getchar(); line = 23; xiua_SetLocaleHdl(Default); for (i=0;i<4;i++) { sprintf((char *)data_buff,"collate test:%i ",i+1); for (j=0;j<7;j++) { strcpy(coll_option,coll_comp[j]); strcat(coll_option,coll_opt[i]); k = xiua_Collate (coll_stra[j], coll_option, coll_strb[j]); if (U_FAILURE(*icu_err)) { sprintf("%s Err(%d) ",coll_option,*icu_err); } else { if (k == coll_test[i][j]) { sprintf((char *)r1_buff,"%s Pass ",coll_option); } else { sprintf((char *)r1_buff,"%s Fail(%i) ",coll_option,k); } } strcat((char *)data_buff,(const char *)r1_buff); if (j == 2) { printf("%s\n",data_buff); line--; strcpy((char *)data_buff," "); } } printf("%s\n",data_buff); line--; } xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCDATABASE)); GreekedText(data_buff, 256, (char *)grline, work_ubuff); big_buff1 = malloc(60000); big_buff2 = big_buff1 + 20000; big_buff3 = big_buff2 + 20000; xiua_strncpyEx(big_buff1,data_buff,-1); /* string 1 */ xiua_strncpyEx(big_buff2,data_buff,-1); /* string 1 */ while (xiua_strncatEx(big_buff1,data_buff,-1) < 9700); big_size = xiua_strlen(big_buff1); /* string 1 */ strcpy(test_buff,"Big translate Test "); strcat(test_buff,Loc_DataFormat[0].dfmt); runTestd(test_buff, &line); xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCSECONDARY)); big_size = (4*(xiua_UTF16toUTF32((UChar32 *)big_buff1,5000,(UChar16 *)big_buff3,-1))); xiua_UTF16toUTF32((UChar32 *)big_buff2,5000,(UChar16 *)data_buff,-1); strcpy(test_buff,"Big translate Test "); strcat(test_buff,Loc_DataFormat[1].dfmt); runTestd(test_buff, &line); xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCSQL)); big_size = xiua_UTF32toUTF8(big_buff1,20000,(UChar32 *)big_buff3,-1); xiua_UTF16toUTF8(big_buff2,20000,(UChar16 *)data_buff,-1); strcpy(test_buff,"Big translate Test "); strcat(test_buff,Loc_DataFormat[2].dfmt); runTestd(test_buff, &line); xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCPRIMARY)); big_size = xiua_UTF8toChar(big_buff1,20000,big_buff3,-1); xiua_UTF16toChar(big_buff2,20000,(UChar16 *)data_buff,-1); strcpy(test_buff,"Big translate Test "); strcat(test_buff,Loc_DataFormat[3].dfmt); runTestd(test_buff, &line); i = xiua_UTF32toUTF16((UChar *)p1_buff,512,sglineU32,-1); j = 5; k = xiua_UTF32toUTF8(p2_buff,1024,sglineU32,-1); xiua_UTF16toUTF32((UChar32 *)r1_buff,j+1,(UChar16 *)p1_buff,-1); TestA = (UBool)(*icu_err == 0); TestA = (UBool)(TestA && (xiu4_MatchStr((UChar32 *)r1_buff,sglineU32,-1) < 0)); xiua_UTF16toUTF8(r1_buff,k+1,(UChar16 *)p1_buff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu8_MatchStr((UChar8 *)r1_buff,(UChar8 *)p2_buff,-1) < 0)); xiua_UTF32toUTF16((UChar16 *)r1_buff,i+1,sglineU32,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu2_MatchStr((UChar16 *)r1_buff,(UChar16 *)p1_buff,-1) < 0)); xiua_UTF32toUTF8(r1_buff,k+1,sglineU32,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu8_MatchStr((UChar8 *)r1_buff,(UChar8 *)p2_buff,-1) < 0)); xiua_UTF8toUTF16((UChar16 *)r1_buff,i+1,p2_buff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu2_MatchStr((UChar16 *)r1_buff,(UChar16 *)p1_buff,-1) < 0)); xiua_UTF8toUTF32((UChar32 *)r1_buff,j+1,p2_buff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu4_MatchStr((UChar32 *)r1_buff,sglineU32,-1) < 0)); i = xiua_ChartoUTF16(r1_ubuff,256,"Test ",-1); TestA = (UBool)(TestA && (*icu_err == 0)); j = xiua_ChartoUTF32((UChar32 *)p1_buff,256,"Test ",-1); TestA = (UBool)(TestA && (*icu_err == 0)); k = xiua_ChartoUTF8(p2_buff,1024,"Test ",-1); TestA = (UBool)(TestA && (*icu_err == 0)); xiua_UTF16toChar(r1_buff,6,r1_ubuff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); xiua_UTF32toChar(r1_buff,6,(UChar32 *)p1_buff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); xiua_UTF8toChar(r1_buff,6,p2_buff,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); if (TestA) { printf("Passed - Converter string length\n"); } else { printf("Failed - Converter string length\n"); } line--; i = xiua_UTF32toUTF16((UChar *)p1_buff,512,sglineU32,-1); j = 5; k = xiua_UTF32toUTF8(p2_buff,1024,sglineU32,-1); xiua_UTF16toUTF32((UChar32 *)r1_buff,j+1,(UChar16 *)p1_buff,i); TestA = (UBool)(*icu_err == 0); TestA = (UBool)(TestA && (xiu4_MatchStr((UChar32 *)r1_buff,sglineU32,-1) < 0)); xiua_UTF16toUTF8(r1_buff,k+1,(UChar16 *)p1_buff,i); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu8_MatchStr((UChar8 *)r1_buff,(UChar8 *)p2_buff,-1) < 0)); xiua_UTF32toUTF16((UChar16 *)r1_buff,i+1,sglineU32,j); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu2_MatchStr((UChar16 *)r1_buff,(UChar16 *)p1_buff,j) < 0)); xiua_UTF32toUTF8(r1_buff,k+1,sglineU32,j); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu8_MatchStr((UChar8 *)r1_buff,(UChar8 *)p2_buff,-1) < 0)); xiua_UTF8toUTF16((UChar16 *)r1_buff,i+1,p2_buff,k); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu2_MatchStr((UChar16 *)r1_buff,(UChar16 *)p1_buff,-1) < 0)); xiua_UTF8toUTF32((UChar32 *)r1_buff,j+1,p2_buff,k); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xiu4_MatchStr((UChar32 *)r1_buff,sglineU32,-1) < 0)); i = xiua_ChartoUTF16(r1_ubuff,256,"Test ",5); TestA = (UBool)(TestA && (*icu_err == 0)); j = xiua_ChartoUTF32((UChar32 *)p1_buff,256,"Test ",5); TestA = (UBool)(TestA && (*icu_err == 0)); k = xiua_ChartoUTF8(p2_buff,1024,"Test ",5); TestA = (UBool)(TestA && (*icu_err == 0)); xiua_UTF16toChar(r1_buff,6,r1_ubuff,i); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); xiua_UTF32toChar(r1_buff,6,(UChar32 *)p1_buff,j); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); xiua_UTF8toChar(r1_buff,6,p2_buff,k); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); xiua_UTF8toCharEx(r1_buff,6,p2_buff,5,-1); TestA = (UBool)(TestA && (*icu_err == 0)); TestA = (UBool)(TestA && (xicp_MatchStr((CpChar *)r1_buff,(CpChar *)"Test ",-1) < 0)); if (TestA) { printf("Passed - Converter source length\n"); } else { printf("Failed - Converter source length\n"); } line--; xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCPRIMARY)); GreekedText(data_buff, 256, "X ", work_ubuff); memcpy(data_buff+4,data_buff,4); i = xiua_ChartoUTF16((UChar *)r1_ubuff,512,data_buff,8); j = xiua_ChartoUTF32((UChar32 *)p1_buff,256,data_buff,8); k = xiua_ChartoUTF8(p2_buff,1024,data_buff,8); i -=2; j -=2; k -=2; l = 6; m = xiua_UTF16toUTF32((UChar32 *)r1_buff,j,(UChar16 *)r1_ubuff,i); TestA = (UBool)(*icu_err < 0); m = xiua_UTF16toUTF8(r1_buff,k,(UChar16 *)r1_ubuff,i); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF32toUTF16((UChar16 *)r1_buff,i,(UChar32 *)p1_buff,j); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF32toUTF8(r1_buff,k,(UChar32 *)p1_buff,j); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF8toUTF16((UChar16 *)r1_buff,i,p2_buff,k); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF8toUTF32((UChar32 *)r1_buff,j,p2_buff,k); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF16toChar(r1_buff,l,r1_ubuff,i); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF32toChar(r1_buff,l,(UChar32 *)p1_buff,j); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_UTF8toChar(r1_buff,l,p2_buff,k); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_ChartoUTF16(r1_ubuff,i,data_buff,l); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_ChartoUTF32((UChar32 *)p1_buff,j,data_buff,l); TestA = (UBool)(TestA && (*icu_err < 0)); m = xiua_ChartoUTF8(p2_buff,k,data_buff,l); TestA = (UBool)(TestA && (*icu_err < 0)); if (TestA) { printf("Passed - Converter null in data, no length for null\n"); } else { printf("Failed - Converter null in data, no length for null\n"); } line--; xiua_SetLocaleHdl(Default); xiua_OpenLocale(LocTR,XDFUTF16); xiua_strtoupper(data_buff, /* converted string */ 256, /* converted string buffer length */ (char *)iilineU16, /* source string */ -1); /* source string length or -1 */ if (U_FAILURE(*icu_err)) { printf("Err:%d convcase tr1-U \n",*icu_err); line--; } xiua_strtolower(data_buff+10, 246, (char *)iilineU16, -1); if (U_FAILURE(*icu_err)) { printf("Err:%d convcase tr1-L \n",*icu_err); line--; } if (memcmp(data_buff,iitesttU16,20) != 0) { xiua_UTF16toChar ((char *)r1_buff, 10, (UChar *)data_buff, 4); xiua_UTF16toChar ((char *)r1_buff+5, 5, (UChar *)data_buff+5, 4); printf("Failed - Turkish eyes (tr_TR) - UC: %s LC: %s \n",r1_buff,r1_buff+5); } else { printf("Passed - Turkish eyes (tr_TR) test\n"); } line--; xiua_OpenLocale(LocUS,XDFUTF8); xiua_strtoupper(data_buff, 256, (char *)iilineU8, -1); if (U_FAILURE(*icu_err)) { printf("Err:%d convcase tr2-U \n",*icu_err); line--; } /* This test changed for ICU 2.2 bug #2344 tolower adds combining dot above*/ xiua_strtolower(data_buff+6, 250, (char *)iilineU8, -1); if (U_FAILURE(*icu_err)) { printf("Err:%d convcase tr2-L \n",*icu_err); line--; } xiua_OpenLocale(LocTR,XDFUTF16); if (memcmp(data_buff,iitestoU8,12) != 0) { xiua_UTF8toChar ((char *)r1_buff, 5, data_buff, -1); xiua_UTF8toChar ((char *)r1_buff+5, 5, data_buff+5, -1); printf("Failed - Turkish eyes (en_US) - UC: %s LC: %s \n",r1_buff,r1_buff+5); } else { printf("Passed - Turkish eyes (en_US) test\n"); } line--; xiua_CloseLocale(LocUS,XDFUTF8,XLCNONE); xiua_CloseLocale(LocTR,XDFUTF16,XLCDEFAULT); ucline[3] = (unsigned char) 0xDF; /* change s to Sharp s */ xiua_strtoupper(data_buff, 256, (char *)ucline, -1); if (U_FAILURE(*icu_err)) { printf("Err:%d convcase gr1-U \n",*icu_err); line--; } if (strcmp(data_buff,uclinex) != 0) { printf("Failed - special caseing\n"); printf(" Before: %s\n",ucline); printf(" After: %s\n",data_buff); line -= 3; } else { printf("Passed - special caseing test\n"); line--; } ucliney[3] = (unsigned char) 0xDF; /* change S to Sharp s */ xiua_strcpy(data_buff,ucline); xiua_strtoupperInplace(data_buff); if (U_FAILURE(*icu_err)) { printf("Err:%d convcase gr2-U \n",*icu_err); line--; } if (strcmp(data_buff,ucliney) != 0) { printf("Failed - no special caseing\n"); printf(" Before: %s\n",ucline); printf(" After: %s\n",data_buff); line -= 3; } else { printf("Passed - no special caseing test\n"); line--; } currtime = 949749999; /* currtime = 1009843200; 1/1/2002 GMT for EURO */ xiua_BuildDateFormat(work_ubuff, 256, date_fmt); xiu8_DateFormat((UChar8 *)r1_buff,1024,currtime,XDTFULL,XDTFULL,work_ubuff); if (U_FAILURE(*icu_err)) { printf("xiua_DateFormat Error:%d \n",*icu_err); line--; } printf("%s\n",r1_buff); line--; xiua_ConvStrftimeFormat(work_ubuff, 256, XDTLONG, XDTLONG, "%x %X"); xiua_DateFormat(r1_buff,1024,currtime,XDTNONE,XDTNONE,work_ubuff); if (U_FAILURE(*icu_err)) { printf("xiua_DateFormat Error:%d \n",*icu_err); line--; } i = xiua_DateParse(r1_buff,XDTNONE,XDTNONE,work_ubuff); if (U_FAILURE(*icu_err)) { printf("xiua_DateParse Error:%d \n",*icu_err); line--; } currtime = xiua_DateParse(r1_buff,XDTANY,XDTANY,NULL); if (U_FAILURE(*icu_err)) { printf("xiua_DateParse Error:%d \n",*icu_err); line--; } if (currtime != i) { printf("Date parse error \n"); line--; } xiua_DateFormat(r1_buff,1024,currtime,XDTFULL,XDTFULL,NULL); if (U_FAILURE(*icu_err)) { printf("xiua_DateFormat Error:%d \n",*icu_err); line--; } currtime = xiua_DateParse(r1_buff,XDTANY,XDTANY,work_ubuff); if (U_FAILURE(*icu_err)) { printf("xiua_DateParse Error:%d \n",*icu_err); line--; } if (currtime == 949749999) { printf("Passed - date/time tests\n"); } else { printf("Failed - date/time tests\n"); } line--; xiua_SetLocaleHdl(xiua_GetLocaleClassHdl(XLCPRIMARY)); xiua_IntFormat(r1_buff,1024,MyNum,XNFDECIMAL); GreekedText(data_buff, 256,r1_buff, work_ubuff); i = xiua_IntParse(r1_buff,XNFDECIMAL); j = xiua_IntParse(data_buff,XNFDECIMAL); TestA = (UBool)(j != i); xiua_RomanDigitStr(data_buff); j = xiua_IntParse(data_buff,XNFDECIMAL); TestA = (UBool)(TestA && (j == i)); xiua_OpenLocale(LocSA,XDFUTF16); xiua_IntFormat(r1_buff,1024,MyNum,XNFDECIMAL); i = xiua_IntParse((char *)arnumU16,XNFDECIMAL); TestA = (UBool)(TestA && (MyNum == i)); xiua_strcpy(data_buff,(char *)arnumU16); xiua_RomanDigitStr(data_buff); i = xiua_IntParse(data_buff,XNFDECIMAL); TestA = (UBool)(TestA && (MyNum == i)); xiua_CloseLocale(LocSA,XDFUTF16,XLCDEFAULT); xiua_IntFormat(r1_buff,1024,MyNum,XNFDECIMAL); i = xiua_IntParse(r1_buff,XNFDECIMAL); TestA = (UBool)(TestA && (MyNum == i)); i = xiua_IntParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyNum == i)); xiua_IntFormat(r1_buff,1024,MyNum,XNFCURRENCY); i = xiua_IntParse(r1_buff,XNFCURRENCY); TestA = (UBool)(TestA && (MyNum == i)); i = xiua_IntParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyNum == i)); xiua_IntFormat(r1_buff,1024,MyNum,XNFPERCENT); i = xiua_IntParse(r1_buff,XNFPERCENT); TestA = (UBool)(TestA && (MyNum == i)); i = xiua_IntParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyNum == i)); if (TestA) { printf("Passed - integer tests\n"); } else { printf("Failed - integer tests\n"); } line--; xiua_FloatFormat(r1_buff,1024,MyFlt,XNFDECIMAL); a = xiua_FloatParse(r1_buff,XNFDECIMAL); TestA = (UBool)(MyFlt == a); a = xiua_FloatParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyFlt == a)); xiua_FloatFormat(r1_buff,1024,MyFlt,XNFCURRENCY); a = xiua_FloatParse(r1_buff,XNFCURRENCY); TestA = (UBool)(TestA && (MyFlt == a)); a = xiua_FloatParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyFlt == a)); xiua_FloatFormat(r1_buff,1024,MyFlt,XNFPERCENT); a = xiua_FloatParse(r1_buff,XNFPERCENT); TestA = (UBool)(TestA && (MyFlt == a)); a = xiua_FloatParse(r1_buff,XNFANY); TestA = (UBool)(TestA && (MyFlt == a)); if (TestA) { printf("Passed - floating point tests\n"); } else { printf("Failed - floating point tests\n"); } line--; while (line >= 0) { printf(" \n"); line--; } ch = getchar(); line = 23; xiua_OpenLocale(LocCH,XDFCODEPAGE); numCnt = 0; totCnt = 0; maxCnt = 0; avgCnt = 0; i = 1; j = -1; k = -1; while (i) { i = xiua_GetNextLocale(list_locale, XIUA_MAXLOCALESIZE, &j,&k,XLTCOUNTRY); /* i = xiua_GetNextLocale(list_locale, XIUA_MAXLOCALESIZE, &j,&k,XLTCOUNTRY); i = xiua_GetNextLocale(list_locale, XIUA_MAXLOCALESIZE, &j,&k,XLTLANGUAGE); i = xiua_GetNextLocale(list_locale, XIUA_MAXLOCALESIZE, &j,&k,XLTFULL); */ if (i < 1) break; i = xiua_DisplayLocale(r1_buff, 1024, list_locale,XLLBOTH); printf("%s\n",r1_buff); if (line <= 0) { ch = getchar(); line = 22; } else { line--; } numCnt++; i++; totCnt += i; if (maxCnt < i) maxCnt = i; } avgCnt = totCnt / numCnt; printf("\nNumber=%d, Total bytes=%d, Average=%d, Max=%d\n", numCnt,totCnt,avgCnt,maxCnt); line -= 2; xiua_CloseLocale(LocCH,XDFCODEPAGE,XLCDEFAULT); while (line >= 0) { printf(" \n"); line--; } ch = getchar(); line = 23; numCnt = 0; totCnt = 0; maxCnt = 0; avgCnt = 0; maxSize = 0; i = 1; j = -1; k = -1; l = -1; m = -1; while (i) { i = xiua_GetNextLocaleTZone(list_tzone, XIUA_MAXTIMEZONESIZE,&j,&k,&l,&m); if (i < 1) break; if (strlen(list_tzone) > maxSize) maxSize = strlen(list_tzone); i = xiua_DisplayTZone(r1_buff, 1024, list_tzone); printf("%s\n",r1_buff); if (line <= 0) { ch = getchar(); line = 22; } else { line--; } numCnt++; i++; totCnt += i; if (maxCnt < i) maxCnt = i; } avgCnt = totCnt / numCnt; printf("\nNumber=%d, Total bytes=%d, Average=%d, Max=%d Max size=%d\n", numCnt,totCnt,avgCnt,maxCnt,maxSize); line -= 2; printf(" \n"); line--; /* */ while (line >= 0) { printf(" \n"); line--; } ch = getchar(); line = 23; numCnt = 0; totCnt = 0; maxCnt = 0; avgCnt = 0; maxSize = 0; i = 1; j = -1; k = -1; l = -1; m = -1; while (i) { i = xiua_GetNextTZone(list_tzone, XIUA_MAXTIMEZONESIZE,&j,&k,&l,&m); if (i < 1) break; if (strlen(list_tzone) > maxSize) maxSize = strlen(list_tzone); i = xiua_DisplayTZone(r1_buff, 1024, list_tzone); printf("%s\n",r1_buff); if (line <= 0) { ch = getchar(); line = 22; } else { line--; } numCnt++; i++; totCnt += i; if (maxCnt < i) maxCnt = i; } avgCnt = totCnt / numCnt; printf("\nNumber=%d, Total bytes=%d, Average=%d, Max=%d Max size=%d\n", numCnt,totCnt,avgCnt,maxCnt,maxSize); line -= 2; printf(" \n"); line--; /* */ #if defined(WIN32) printf( "Press any key " ); ch = getchar(); #endif return 0; } #if 0 static int32_t ToAsciiHex(char *target, void * source, int32_t sourceLen) /*-------------------------------------------------------------- * NAME: Binary to ASCII Hex * Routine to convert a binary data into HEX ASCII ( 2 chars per byte) * Length is the number of binary bytes *-------------------------------------------------------------*/ { unsigned char * x; unsigned char * y; int32_t i; x = (unsigned char *)source; y = (unsigned char *)target; for (i=0;i>4) &0x0F]; *y++ = asciihex[(*x)&0x0F]; x++; } return i*2; } static int32_t ToEbcdicHex(char *target, void * source, int32_t sourceLen) /*-------------------------------------------------------------- * NAME: Binary to EBCDIC Hex * Routine to convert a binary data into HEX EBCDIC ( 2 chars per byte) * Length is the number of binary bytes *-------------------------------------------------------------*/ { unsigned char * x; unsigned char * y; int32_t i; x = (unsigned char *)source; y = (unsigned char *)target; for (i=0;i>4) &0x0F]; *y++ = ebchex[(*x)&0x0F]; x++; } return i*2; } #endif static int32_t GreekedText(char * dst, size_t dsize,char *src, UChar * wrk) { UChar uch = 1; int i = 0; while (uch) { uch = (UChar8)src[i]; if (uch >= 0x0021 && uch <= 0x007E) { uch += 0xFEE0; /* full width character -> ASCII Unicode char */ } if (uch >= 0x00A0 && uch <= 0x00DF) { uch += 0xFEC0; /* half width character (Hankata) -> Unicode char */ /* Note: 0x00A0 and 0xFF60 are invalid characters */ } wrk[i] = uch; i++; } return xiua_UTF16toNative(dst, dsize, wrk, -1); } static void runTesta(char * name, int * ln) { GreekedText(data_buff, 256, (char *)grline, work_ubuff); xiua_RomanDigitStr(data_buff); xiua_NativetoChar(r1_buff, 256, data_buff,-1); if (strcmp((const char *)grline,r1_buff) == 0) { printf("Passed - xiua_RomanDigitStr (%s)\n",name); *ln = *ln - 1; } else { printf("Failed - xiua_RomanDigitStr (%s)\n",name); *ln = *ln - 1; } } static void runTestb(char * name, int * ln) { int j, k; UBool Test1; UBool Test2; UBool Test3; GreekedText(data_buff, 256, (char *)grline, work_ubuff); p2_addr = data_buff; for (j=0;j<3;j++) { p2_addr = xiua_CharNext(p2_addr); } k = xiua_CharLenMin(); j = xiua_CharLen(p2_addr) + k; xiua_strncpyEx(p2_buff,p2_addr,j); p1_addr = xiua_strchrEx(data_buff,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(xiua_CharCnt(r1_buff, -1) == 3); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strchrEx(p1_addr,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(Test1 && (xiua_CharCnt(r1_buff, -1) == 28)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strchrEx(p1_addr,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(Test1 && (xiua_CharCnt(r1_buff, -1) == 32)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strchrEx(p1_addr,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(Test1 && (xiua_CharCnt(r1_buff, -1) == 39)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strchrEx(p1_addr,p2_buff); Test1 = (UBool)(Test1 && (p1_addr == NULL)); p1_addr = xiua_strstr(data_buff,p2_buff); Test2 = (UBool)(xiua_CharCnt(data_buff,(int32_t)(p1_addr-data_buff)) == 3); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strstr(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(data_buff,(int32_t)(p1_addr-data_buff)) == 28)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strstr(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(data_buff,(int32_t)(p1_addr-data_buff)) == 32)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strstr(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(data_buff,(int32_t)(p1_addr-data_buff)) == 39)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strstr(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (p1_addr == NULL)); GreekedText(p2_buff, 256, "test", work_ubuff); p1_addr = xiua_strstr(data_buff,p2_buff); Test3 = (UBool)(xiua_CharCnt(data_buff,(int32_t)(p1_addr-data_buff)) == 31); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strstr(p1_addr,p2_buff); Test3 = (UBool)(Test3 && (p1_addr == NULL)); if (Test1 & Test2 & Test3) { printf("Passed - xiua_strchrEx/xiua_strstr (%s)\n",name); *ln = *ln - 1; } else { printf("Failed - xiua_strchrEx/xiua_strstr (%s)\n",name); *ln = *ln - 1; } } static void runTestc(char * name, int * ln) { int j, k; UBool Test1; UBool Test2; UBool Test3; GreekedText(data_buff, 256, (char *)grline, work_ubuff); GreekedText(p2_buff, 256, (char *)grchars1, work_ubuff); k = xiua_CharLenMin(); p1_addr = xiua_strpbrk(data_buff,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(xiua_CharCnt(r1_buff, -1) == 9); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strpbrk(p1_addr,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(Test1 && (xiua_CharCnt(r1_buff, -1) == 19)); p1_addr = xiua_CharNext(p1_addr); p1_addr = xiua_strpbrk(p1_addr,p2_buff); xiua_strncpyEx(r1_buff,data_buff,(int32_t)(p1_addr-data_buff+k)); Test1 = (UBool)(Test1 && (xiua_CharCnt(r1_buff, -1) == 29)); j = xiua_strcspn(data_buff,p2_buff); Test2 = (UBool)(xiua_CharCnt(data_buff,j) == 9); p1_addr = data_buff+j; j = xiua_strspn(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(p1_addr,j) == 1)); p1_addr = p1_addr+j; j = xiua_strcspn(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(p1_addr,j) == 9)); p1_addr = p1_addr+j; j = xiua_strspn(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(p1_addr,j) == 1)); p1_addr = p1_addr+j; j = xiua_strcspn(p1_addr,p2_buff); Test2 = (UBool)(Test2 && (xiua_CharCnt(p1_addr,j) == 9)); xiua_strcpy(p1_buff,data_buff); r1_addr = p1_buff; p1_addr = xiua_strtok(p1_buff,p2_buff); Test3 = (UBool)(p1_addr == r1_addr); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 9)); r1_addr = p1_addr+xiua_strlen(p1_addr); k = xiua_CharLen(data_buff+(r1_addr-p1_buff)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (p1_addr == r1_addr+k)); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 9)); r1_addr = p1_addr+xiua_strlen(p1_addr); k = xiua_CharLen(data_buff+(r1_addr-p1_buff)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (p1_addr == r1_addr+k)); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 9)); GreekedText(data_buff, 256, (char *)grline1, work_ubuff); GreekedText(p2_buff, 256, " -q", work_ubuff); xiua_strcpy(p1_buff,data_buff); p1_addr = xiua_strtok(p1_buff,p2_buff); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 4)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 2)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 1)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 6)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (xiua_CharCnt(p1_addr, -1) == 4)); p1_addr = xiua_strtok(NULL,p2_buff); Test3 = (UBool)(Test3 && (p1_addr == NULL)); if (Test1 && Test2 && Test3) { printf("Passed - xiua_strtok (%s)\n",name); *ln = *ln - 1; } else { printf("Failed - xiua_strtok (%s)\n",name); *ln = *ln - 1; } } static void runTestd(char * name, int * ln) { int i, j; UBool Test1 = TRUE; j = xiua_strlen(big_buff2); Test1 = (UBool)(xiua_strncmp(big_buff1,big_buff2,j) == 0); for (j=0;j<5;j++) { *big_buff2 = 0; i = xiua_NativetoLocale(big_buff2,20000, big_buff1,-1,*LocJP_list[j]); Test1 = (UBool)(Test1 && (big_sizes[j] == i)); *big_buff3 = 0; i = xiua_LocaletoNative(big_buff3,20000, big_buff2,-1,*LocJP_list[j]); Test1 = (UBool)(Test1 && (big_size == i)); i = xiua_MatchStr(big_buff1,big_buff3,-1); if (i >= 0) { Test1 = FALSE; printf("Buffer missmatch at %d - %s to %s\n",i,name, Loc_DataFormat[j].dfmt); *ln = *ln - 1; } } if (Test1) { printf("Passed - xiua_LocaletoLocale (%s)\n",name); *ln = *ln - 1; } else { printf("Failed - xiua_LocaletoLocale (%s)\n",name); *ln = *ln - 1; } }