From 8ed1e11d822acabcf87ab024096d6c033b4e00c4 Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Sat, 28 Oct 2000 01:08:25 +0000 Subject: [PATCH] ICU-703 Added tests for JP1, JP2 and CN-Ext X-SVN-Rev: 2832 --- icu4c/source/test/cintltst/nucnvtst.c | 420 ++++++++++++++++++++------ 1 file changed, 335 insertions(+), 85 deletions(-) diff --git a/icu4c/source/test/cintltst/nucnvtst.c b/icu4c/source/test/cintltst/nucnvtst.c index 2e3486805c8..a04b26433f5 100644 --- a/icu4c/source/test/cintltst/nucnvtst.c +++ b/icu4c/source/test/cintltst/nucnvtst.c @@ -41,8 +41,11 @@ void TestDBCS(void); void TestMBCS(void); void TestISO_2022(void); void TestISO_2022_JP(void); +void TestISO_2022_JP_1(void); +void TestISO_2022_JP_2(void); void TestISO_2022_KR(void); void TestISO_2022_CN(void); +void TestISO_2022_CN_EXT(void); void TestHZ(void); void TestISO_2022_JP_Next(void); void TestEBCDIC_STATEFUL(void); @@ -170,8 +173,11 @@ void addTestNewConvert(TestNode** root) addTest(root, &TestMBCS, "tsconv/nucnvtst/TestMBCS"); addTest(root, &TestISO_2022, "tsconv/nucnvtst/TestISO_2022"); addTest(root, &TestISO_2022_JP, "tsconv/nucnvtst/TestISO_2022_JP"); + addTest(root, &TestISO_2022_JP_1, "tsconv/nucnvtst/TestISO_2022_JP_1"); + addTest(root, &TestISO_2022_JP_2, "tsconv/nucnvtst/TestISO_2022_JP_2"); addTest(root, &TestISO_2022_KR, "tsconv/nucnvtst/TestISO_2022_KR"); addTest(root, &TestISO_2022_CN, "tsconv/nucnvtst/TestISO_2022_CN"); + addTest(root, &TestISO_2022_CN_EXT, "tsconv/nucnvtst/TestISO_2022_CN_EXT"); addTest(root, &TestHZ, "tsconv/nucnvtst/TestHZ"); addTest(root, &TestISO_2022_JP_Next, "tsconv/nucnvtst/TestISO_2022_JP_Next"); addTest(root, &TestEBCDIC_STATEFUL, "tsconv/nucnvtst/TestEBCDIC_STATEFUL"); @@ -1336,53 +1342,57 @@ TestSmallTargetBuffer(const uint16_t* source, const UChar* sourceLimit,UConverte UChar *uBuf,*test; int32_t uBufSize = 120; int len=0; + int i=5; UErrorCode errorCode=U_ZERO_ERROR; uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5); cBuf =(char*)malloc(uBufSize * sizeof(char) * 10); - uSource = (UChar*) source; - uSourceLimit=(const UChar*)sourceLimit; - cTarget = cBuf; - uTarget = uBuf; - cSource = cBuf; - cTargetLimit = cBuf; - uTargetLimit = uBuf; + for(;--i>0; ){ + uSource = (UChar*) source; + uSourceLimit=(const UChar*)sourceLimit; + cTarget = cBuf; + uTarget = uBuf; + cSource = cBuf; + cTargetLimit = cBuf; + uTargetLimit = uBuf; - do{ - - cTargetLimit = cTargetLimit+ 1; - ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&uSource,uSourceLimit,NULL,FALSE, &errorCode); - if(errorCode==U_BUFFER_OVERFLOW_ERROR){ - errorCode=U_ZERO_ERROR; - continue; - } + do{ + + cTargetLimit = cTargetLimit+ i; + ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&uSource,uSourceLimit,NULL,FALSE, &errorCode); + if(errorCode==U_BUFFER_OVERFLOW_ERROR){ + errorCode=U_ZERO_ERROR; + continue; + } - if(U_FAILURE(errorCode)){ - log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode)); - return; - } - - }while (uSource0;){ + uSource = (UChar*) source; + cTarget = cBuf; + uTarget = uBuf; + cSource = cBuf; + cTargetLimit = cBuf; + uTargetLimit = uBuf+uBufSize*5; + cTargetLimit = cTargetLimit+uBufSize*10; + uSourceLimit=uSource; + do{ - uSourceLimit = uSourceLimit+1; - ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&uSource,uSourceLimit,NULL,FALSE, &errorCode); - if(errorCode==U_BUFFER_OVERFLOW_ERROR){ - errorCode=U_ZERO_ERROR; - continue; - } + uSourceLimit = uSourceLimit+1; + ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&uSource,uSourceLimit,NULL,FALSE, &errorCode); + if(errorCode==U_BUFFER_OVERFLOW_ERROR){ + errorCode=U_ZERO_ERROR; + continue; + } - if(U_FAILURE(errorCode)){ - log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode)); - return; - } - - }while (uSource