From 08ba5287481c664d7be02d5825f51b3ec4f12666 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Sat, 1 Sep 2001 04:23:43 +0000 Subject: [PATCH] ICU-821 Fix for Linux 7.1 X-SVN-Rev: 5683 --- icu4c/source/test/cintltst/cnormtst.c | 12 +- icu4c/source/test/cintltst/nccbtst.c | 194 ++++++++++---------- icu4c/source/test/cintltst/ncnvtst.c | 244 +++++++++++++------------- icu4c/source/test/cintltst/nucnvtst.c | 19 +- 4 files changed, 238 insertions(+), 231 deletions(-) diff --git a/icu4c/source/test/cintltst/cnormtst.c b/icu4c/source/test/cintltst/cnormtst.c index 2535ba61121..d7b69cebf5c 100644 --- a/icu4c/source/test/cintltst/cnormtst.c +++ b/icu4c/source/test/cintltst/cnormtst.c @@ -552,21 +552,21 @@ void TestQuickCheck() void TestCheckFCD() { UErrorCode status = U_ZERO_ERROR; - const UChar FAST_[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + static const UChar FAST_[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}; - const UChar FALSE_[] = {0x0001, 0x0002, 0x02EA, 0x03EB, 0x0300, 0x0301, + static const UChar FALSE_[] = {0x0001, 0x0002, 0x02EA, 0x03EB, 0x0300, 0x0301, 0x02B9, 0x0314, 0x0315, 0x0316}; - const UChar TRUE_[] = {0x0030, 0x0040, 0x0440, 0x056D, 0x064F, 0x06E7, + static const UChar TRUE_[] = {0x0030, 0x0040, 0x0440, 0x056D, 0x064F, 0x06E7, 0x0050, 0x0730, 0x09EE, 0x1E10}; - const UChar datastr[][5] = + static const UChar datastr[][5] = { {0x0061, 0x030A, 0x1E05, 0x0302, 0}, {0x0061, 0x030A, 0x00E2, 0x0323, 0}, {0x0061, 0x0323, 0x00E2, 0x0323, 0}, {0x0061, 0x0323, 0x1E05, 0x0302, 0} }; - const UBool result[] = {UNORM_YES, UNORM_NO, UNORM_NO, UNORM_YES}; + static const UBool result[] = {UNORM_YES, UNORM_NO, UNORM_NO, UNORM_YES}; - const UChar datachar[] = {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + static const UChar datachar[] = {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, diff --git a/icu4c/source/test/cintltst/nccbtst.c b/icu4c/source/test/cintltst/nccbtst.c index 75785209892..e9dc60319d5 100644 --- a/icu4c/source/test/cintltst/nccbtst.c +++ b/icu4c/source/test/cintltst/nccbtst.c @@ -146,30 +146,30 @@ static void TestSingleByteCallBack() static void TestSkip(int32_t inputsize, int32_t outputsize) { - UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; - UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; + static const UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; + static const UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - const uint8_t expskipIBM_949[]= { + static const uint8_t expskipIBM_949[]= { 0x00, 0xb0, 0xa1, 0xb0, 0xa2, 0xc8, 0xd3 }; - const uint8_t expskipIBM_943[] = { + static const uint8_t expskipIBM_943[] = { 0x9f, 0xaf, 0x9f, 0xb1, 0x89, 0x59 }; - const uint8_t expskipIBM_930[] = { + static const uint8_t expskipIBM_930[] = { 0x0e, 0x5d, 0x5f, 0x5d, 0x63, 0x46, 0x6b }; - UChar IBM_949skiptoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xD700 }; - UChar IBM_943skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 }; - UChar IBM_930skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 }; + static const UChar IBM_949skiptoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xD700 }; + static const UChar IBM_943skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 }; + static const UChar IBM_930skiptoUnicode[]= { 0x6D63, 0x6D64, 0x6D66 }; - int32_t toIBM949Offsskip [] = { 0, 1, 1, 2, 2, 4, 4}; - int32_t toIBM943Offsskip [] = { 0, 0, 1, 1, 3, 3}; - int32_t toIBM930Offsskip [] = { 0, 0, 0, 1, 1, 3, 3}; + static const int32_t toIBM949Offsskip [] = { 0, 1, 1, 2, 2, 4, 4}; + static const int32_t toIBM943Offsskip [] = { 0, 0, 1, 1, 3, 3}; + static const int32_t toIBM930Offsskip [] = { 0, 0, 0, 1, 1, 3, 3}; - int32_t fromIBM949Offs [] = { 0, 1, 3, 5}; - int32_t fromIBM943Offs [] = { 0, 2, 4}; - int32_t fromIBM930Offs [] = { 1, 3, 5}; + static const int32_t fromIBM949Offs [] = { 0, 1, 3, 5}; + static const int32_t fromIBM943Offs [] = { 0, 2, 4}; + static const int32_t fromIBM930Offs [] = { 1, 3, 5}; gInBufferSize = inputsize; gOutBufferSize = outputsize; @@ -257,81 +257,81 @@ static void TestSkip(int32_t inputsize, int32_t outputsize) } { - UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const uint8_t toIBM943[]= { 0x61, 0x61 }; - int32_t offset[]= {0, 4}; + static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; + static const uint8_t toIBM943[]= { 0x61, 0x61 }; + static const int32_t offset[]= {0, 4}; /* EUC_JP*/ - UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; - const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, + static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; + static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae, 0x61, 0x8e, 0xe0, }; - int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 6, 7, 7}; + static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2, 6, 7, 7}; /*EUC_TW*/ - UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const uint8_t to_euc_tw[]={ + static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; + static const uint8_t to_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5, 0x61, 0xe6, 0xca, 0x8a, }; - int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 6, 7, 7, 8,}; + static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2, 6, 7, 7, 8,}; /*ISO-2022-JP*/ - UChar iso_2022_jp_inputText[]={0x0041, 0x00E9/*unassigned*/,0x0042, }; - const uint8_t to_iso_2022_jp[]={ + static const UChar iso_2022_jp_inputText[]={0x0041, 0x00E9/*unassigned*/,0x0042, }; + static const uint8_t to_iso_2022_jp[]={ 0x41, 0x42, }; - int32_t from_iso_2022_jpOffs [] ={0,2}; + static const int32_t from_iso_2022_jpOffs [] ={0,2}; - UChar iso_2022_jp_inputText1[]={0x3000, 0x00E9, 0x3001, }; - const uint8_t to_iso_2022_jp1[]={ + static const UChar iso_2022_jp_inputText1[]={0x3000, 0x00E9, 0x3001, }; + static const uint8_t to_iso_2022_jp1[]={ 0x1b, 0x24, 0x42, 0x21, 0x21, 0x21, 0x22, }; - int32_t from_iso_2022_jpOffs1 [] ={0,0,0,0,0,2,2,}; + static const int32_t from_iso_2022_jpOffs1 [] ={0,0,0,0,0,2,2,}; /*ISO-2022-JP*/ - UChar iso_2022_jp_inputText2[]={0x0041, 0x00E9/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; - const uint8_t to_iso_2022_jp2[]={ + UChar const iso_2022_jp_inputText2[]={0x0041, 0x00E9/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; + static const uint8_t to_iso_2022_jp2[]={ 0x41, 0x43, }; - int32_t from_iso_2022_jpOffs2 [] ={0,2}; + static const int32_t from_iso_2022_jpOffs2 [] ={0,2}; /*ISO-2022-cn*/ - UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, }; - const uint8_t to_iso_2022_cn[]={ + static const UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, }; + static const uint8_t to_iso_2022_cn[]={ 0x0F, 0x41, 0x0F, 0x42, }; - int32_t from_iso_2022_cnOffs [] ={ + static const int32_t from_iso_2022_cnOffs [] ={ 0,0, 2,2, }; /*ISO-2022-CN*/ - UChar iso_2022_cn_inputText1[]={0x0041, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; - const uint8_t to_iso_2022_cn1[]={ + static const UChar iso_2022_cn_inputText1[]={0x0041, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; + static const uint8_t to_iso_2022_cn1[]={ 0x0F, 0x41, 0x0F, 0x43, }; - int32_t from_iso_2022_cnOffs1 [] ={0,0,2,2}; + static const int32_t from_iso_2022_cnOffs1 [] ={0,0,2,2}; /*ISO-2022-kr*/ - UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, }; - const uint8_t to_iso_2022_kr[]={ + static const UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, }; + static const uint8_t to_iso_2022_kr[]={ 0x1b, 0x24, 0x29, 0x43, 0x41, 0x0e, 0x25, 0x50, 0x25, 0x50, 0x0f, 0x42, }; - int32_t from_iso_2022_krOffs [] ={ + static const int32_t from_iso_2022_krOffs [] ={ -1,-1,-1,-1, 0, 1,1,1, @@ -340,15 +340,15 @@ static void TestSkip(int32_t inputsize, int32_t outputsize) }; /*ISO-2022-kr*/ - UChar iso_2022_kr_inputText1[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, }; - const uint8_t to_iso_2022_kr1[]={ + static const UChar iso_2022_kr_inputText1[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, }; + static const uint8_t to_iso_2022_kr1[]={ 0x1b, 0x24, 0x29, 0x43, 0x41, 0x0e, 0x25, 0x50, 0x25, 0x50, }; - int32_t from_iso_2022_krOffs1 [] ={ + static const int32_t from_iso_2022_krOffs1 [] ={ -1,-1,-1,-1, 0, 1,1,1, @@ -356,32 +356,32 @@ static void TestSkip(int32_t inputsize, int32_t outputsize) }; /* HZ encoding */ - UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, }; + static const UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, }; - const uint8_t to_hz[]={ + static const uint8_t to_hz[]={ 0x7e, 0x7d, 0x41, 0x7e, 0x7b, 0x26, 0x30, 0x26, 0x30, 0x7e, 0x7d, 0x42, }; - int32_t from_hzOffs [] ={ + static const int32_t from_hzOffs [] ={ 0,0,0, 1,1,1,1, 3,3, 4,4,4,4 }; - UChar hz_inputText1[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, }; + static const UChar hz_inputText1[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0,0xd801/*illegal*/, 0x0042, }; - const uint8_t to_hz1[]={ + static const uint8_t to_hz1[]={ 0x7e, 0x7d, 0x41, 0x7e, 0x7b, 0x26, 0x30, 0x26, 0x30, }; - int32_t from_hzOffs1 [] ={ + static const int32_t from_hzOffs1 [] ={ 0,0,0, 1,1,1,1, 3,3, @@ -389,37 +389,37 @@ static void TestSkip(int32_t inputsize, int32_t outputsize) }; - UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, }; + static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, }; - const uint8_t to_SCSU[]={ + static const uint8_t to_SCSU[]={ 0x41, 0x42 }; - int32_t from_SCSUOffs [] ={ + static const int32_t from_SCSUOffs [] ={ 0, 2, }; /* ISCII */ - UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, }; - const uint8_t to_iscii[]={ + static const UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, }; + static const uint8_t to_iscii[]={ 0x41, 0x42, }; - int32_t from_isciiOffs [] ={ + static const int32_t from_isciiOffs [] ={ 0,2, }; /*ISCII*/ - UChar iscii_inputText1[]={0x0044, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; - const uint8_t to_iscii1[]={ + static const UChar iscii_inputText1[]={0x0044, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, }; + static const uint8_t to_iscii1[]={ 0x44, 0x43, }; - int32_t from_isciiOffs1 [] ={0,2}; + static const int32_t from_isciiOffs1 [] ={0,2}; if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]), toIBM943, sizeof(toIBM943), "ibm-943", @@ -758,30 +758,30 @@ static void TestSkip(int32_t inputsize, int32_t outputsize) static void TestStop(int32_t inputsize, int32_t outputsize) { - UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; - UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; + static const UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 }; + static const UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 }; - const uint8_t expstopIBM_949[]= { + static const uint8_t expstopIBM_949[]= { 0x00, 0xb0, 0xa1, 0xb0, 0xa2}; - const uint8_t expstopIBM_943[] = { + static const uint8_t expstopIBM_943[] = { 0x9f, 0xaf, 0x9f, 0xb1}; - const uint8_t expstopIBM_930[] = { + static const uint8_t expstopIBM_930[] = { 0x0e, 0x5d, 0x5f, 0x5d, 0x63}; - UChar IBM_949stoptoUnicode[]= {0x0000, 0xAC00, 0xAC01}; - UChar IBM_943stoptoUnicode[]= { 0x6D63, 0x6D64}; - UChar IBM_930stoptoUnicode[]= { 0x6D63, 0x6D64}; + static const UChar IBM_949stoptoUnicode[]= {0x0000, 0xAC00, 0xAC01}; + static const UChar IBM_943stoptoUnicode[]= { 0x6D63, 0x6D64}; + static const UChar IBM_930stoptoUnicode[]= { 0x6D63, 0x6D64}; - int32_t toIBM949Offsstop [] = { 0, 1, 1, 2, 2}; - int32_t toIBM943Offsstop [] = { 0, 0, 1, 1}; - int32_t toIBM930Offsstop [] = { 0, 0, 0, 1, 1}; + static const int32_t toIBM949Offsstop [] = { 0, 1, 1, 2, 2}; + static const int32_t toIBM943Offsstop [] = { 0, 0, 1, 1}; + static const int32_t toIBM930Offsstop [] = { 0, 0, 0, 1, 1}; - int32_t fromIBM949Offs [] = { 0, 1, 3}; - int32_t fromIBM943Offs [] = { 0, 2}; - int32_t fromIBM930Offs [] = { 1, 3}; + static const int32_t fromIBM949Offs [] = { 0, 1, 3}; + static const int32_t fromIBM943Offs [] = { 0, 2}; + static const int32_t fromIBM930Offs [] = { 1, 3}; gInBufferSize = inputsize; gOutBufferSize = outputsize; @@ -801,72 +801,72 @@ static void TestStop(int32_t inputsize, int32_t outputsize) log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_STOP \n"); { - UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; - const uint8_t toIBM943[]= { 0x61,}; - int32_t offset[]= {0,} ; + static const UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 }; + static const uint8_t toIBM943[]= { 0x61,}; + static const int32_t offset[]= {0,} ; /*EUC_JP*/ - UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; - const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,}; - int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2,}; + static const UChar euc_jp_inputText[]={ 0x0061, 0x4edd, 0x5bec, 0xd801, 0xdc01, 0xd801, 0x0061, 0x00a2 }; + static const uint8_t to_euc_jp[]={ 0x61, 0xa1, 0xb8, 0x8f, 0xf4, 0xae,}; + static const int32_t fromEUC_JPOffs [] ={ 0, 1, 1, 2, 2, 2,}; /*EUC_TW*/ - UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; - const uint8_t to_euc_tw[]={ + static const UChar euc_tw_inputText[]={ 0x0061, 0x2295, 0x5BF2, 0xd801, 0xdc01, 0xd801, 0x0061, 0x8706, 0x8a, }; + static const uint8_t to_euc_tw[]={ 0x61, 0xa2, 0xd3, 0x8e, 0xa2, 0xdc, 0xe5,}; - int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2,}; + static const int32_t from_euc_twOffs [] ={ 0, 1, 1, 2, 2, 2, 2,}; /*ISO-2022-JP*/ - UChar iso_2022_jp_inputText[]={0x0041, 0x00E9, 0x0042, }; - const uint8_t to_iso_2022_jp[]={ + static const UChar iso_2022_jp_inputText[]={0x0041, 0x00E9, 0x0042, }; + static const uint8_t to_iso_2022_jp[]={ 0x41, }; - int32_t from_iso_2022_jpOffs [] ={0,}; + static const int32_t from_iso_2022_jpOffs [] ={0,}; /*ISO-2022-cn*/ - UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712, 0x0042, }; - const uint8_t to_iso_2022_cn[]={ + static const UChar iso_2022_cn_inputText[]={ 0x0041, 0x3712, 0x0042, }; + static const uint8_t to_iso_2022_cn[]={ 0x0F, 0x41, }; - int32_t from_iso_2022_cnOffs [] ={ + static const int32_t from_iso_2022_cnOffs [] ={ 0,0, 2,2, }; /*ISO-2022-kr*/ - UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, }; - const uint8_t to_iso_2022_kr[]={ + static const UChar iso_2022_kr_inputText[]={ 0x0041, 0x03A0,0x3712/*unassigned*/,0x03A0, 0x0042, }; + static const uint8_t to_iso_2022_kr[]={ 0x1b, 0x24, 0x29, 0x43, 0x41, 0x0e, 0x25, 0x50, }; - int32_t from_iso_2022_krOffs [] ={ + static const int32_t from_iso_2022_krOffs [] ={ -1,-1,-1,-1, 0, 1,1,1, }; /* HZ encoding */ - UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, }; + static const UChar hz_inputText[]={ 0x0041, 0x03A0,0x0662/*unassigned*/,0x03A0, 0x0042, }; - const uint8_t to_hz[]={ + static const uint8_t to_hz[]={ 0x7e, 0x7d, 0x41, 0x7e, 0x7b, 0x26, 0x30, }; - int32_t from_hzOffs [] ={ + static const int32_t from_hzOffs [] ={ 0, 0,0, 1,1,1,1, }; /*ISCII*/ - UChar iscii_inputText[]={ 0x0041, 0x3712, 0x0042, }; - const uint8_t to_iscii[]={ + static const UChar iscii_inputText[]={ 0x0041, 0x3712, 0x0042, }; + static const uint8_t to_iscii[]={ 0x41, }; - int32_t from_isciiOffs [] ={ + static const int32_t from_isciiOffs [] ={ 0, }; diff --git a/icu4c/source/test/cintltst/ncnvtst.c b/icu4c/source/test/cintltst/ncnvtst.c index 386876a4d1f..7bb9f9b1ff9 100644 --- a/icu4c/source/test/cintltst/ncnvtst.c +++ b/icu4c/source/test/cintltst/ncnvtst.c @@ -37,14 +37,14 @@ static void printSeqErr(const unsigned char* a, int len); static void printUSeq(const UChar* a, int len); static void printUSeqErr(const UChar* a, int len); static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus); + const char *codepage, const int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus); static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expect, int expectLen, - const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus); + const char *codepage, const int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus); static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, UConverterFromUCallback callback, int32_t *expectOffsets, UBool testReset); + const char *codepage, UConverterFromUCallback callback, const int32_t *expectOffsets, UBool testReset); static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen, - const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets, UBool testReset); + const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets, UBool testReset); static void setNuConvTestName(const char *codepage, const char *direction) { @@ -178,9 +178,9 @@ static void TestSurrogateBehaviour(){ } log_verbose("Testing for ISO-2022-cn\n"); { - UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = { + static const uint8_t expected[] = { 0x1B, 0x24, 0x29, 0x41, 0x0E, 0x52, 0x3B, 0x36, 0x21, 0x0F, 0x31, @@ -190,7 +190,7 @@ static void TestSurrogateBehaviour(){ - int32_t offsets[] = { + static const int32_t offsets[] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, @@ -207,9 +207,9 @@ static void TestSurrogateBehaviour(){ } log_verbose("Testing for ISO-2022-kr\n"); { - UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x1B, 0x24, 0x29, 0x43, + static const uint8_t expected[] = {0x1B, 0x24, 0x29, 0x43, 0x0E, 0x6C, 0x69, 0x0f, 0x1A, 0x0e, 0x6F, 0x4B, @@ -217,7 +217,7 @@ static void TestSurrogateBehaviour(){ 0x1A, 0x32 }; - int32_t offsets[] = {-1, -1, -1, -1, + static const int32_t offsets[] = {-1, -1, -1, -1, 0, 0, 0, 1, 1, 3, 3, 3, @@ -236,9 +236,9 @@ static void TestSurrogateBehaviour(){ } log_verbose("Testing for HZ\n"); { - UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x7E, 0x7B, 0x52, 0x3B, + static const uint8_t expected[] = {0x7E, 0x7B, 0x52, 0x3B, 0x7E, 0x7D, 0x1A, 0x7E, 0x7B, 0x36, 0x21, 0x7E, 0x7D, 0x31, @@ -246,7 +246,7 @@ static void TestSurrogateBehaviour(){ 0x32 }; - int32_t offsets[] = {0,0,0,0, + static const int32_t offsets[] = {0,0,0,0, 1,1,1, 3,3,3,3, 4,4,4, @@ -264,15 +264,15 @@ static void TestSurrogateBehaviour(){ /*UTF-8*/ log_verbose("Testing for UTF8\n"); { - UChar sampleText[] = { 0x4e00, 0x0701, 0x0031, 0xbfc1, 0xd801, 0xdc01, 0x0032}; - int32_t offsets[]={0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + static const UChar sampleText[] = { 0x4e00, 0x0701, 0x0031, 0xbfc1, 0xd801, 0xdc01, 0x0032}; + static const int32_t offsets[]={0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x06 }; - const uint8_t expected[] = {0xe4, 0xb8, 0x80, 0xdc, 0x81, 0x31, + static const uint8_t expected[] = {0xe4, 0xb8, 0x80, 0xdc, 0x81, 0x31, 0xeb, 0xbf, 0x81, 0xF0, 0x90, 0x90, 0x81, 0x32}; - int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; + static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; /*UTF-8*/ if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "UTF8", offsets, TRUE, U_ZERO_ERROR )) @@ -310,10 +310,10 @@ static void TestSurrogateBehaviour(){ static void TestErrorBehaviour(){ log_verbose("Testing for SBCS and LATIN_1\n"); { - UChar sampleText[] = { 0x0031, 0xd801}; - UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; - const uint8_t expected[] = { 0x31}; - const uint8_t expected2[] = { 0x31, 0x1a, 0x32}; + static const UChar sampleText[] = { 0x0031, 0xd801}; + static const UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; + static const uint8_t expected[] = { 0x31}; + static const uint8_t expected2[] = { 0x31, 0x1a, 0x32}; /*SBCS*/ if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), @@ -343,21 +343,21 @@ static void TestErrorBehaviour(){ log_verbose("Testing for DBCS and MBCS\n"); { - UChar sampleText[] = { 0x00a1, 0xd801}; - const uint8_t expected[] = { 0xa2, 0xae}; - int32_t offsets[] = { 0x00, 0x00, 0x01, 0x01}; + static const UChar sampleText[] = { 0x00a1, 0xd801}; + static const uint8_t expected[] = { 0xa2, 0xae}; + static const int32_t offsets[] = { 0x00, 0x00, 0x01, 0x01}; - UChar sampleText2[] = { 0x00a1, 0xd801, 0x00a4}; - const uint8_t expected2[] = { 0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4}; - int32_t offsets2[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02}; + static const UChar sampleText2[] = { 0x00a1, 0xd801, 0x00a4}; + static const uint8_t expected2[] = { 0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4}; + static const int32_t offsets2[] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x02}; - UChar sampleText3MBCS[] = { 0x0001, 0x00a4, 0xdc01}; - const uint8_t expected3MBCS[] = { 0x01, 0xa2, 0xb4, 0xa1, 0xe0}; - int32_t offsets3MBCS[] = { 0x00, 0x01, 0x01, 0x02, 0x02}; + static const UChar sampleText3MBCS[] = { 0x0001, 0x00a4, 0xdc01}; + static const uint8_t expected3MBCS[] = { 0x01, 0xa2, 0xb4, 0xa1, 0xe0}; + static const int32_t offsets3MBCS[] = { 0x00, 0x01, 0x01, 0x02, 0x02}; - UChar sampleText4MBCS[] = { 0x0061, 0x00a6, 0xdc01}; - const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe}; - int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 }; + static const UChar sampleText4MBCS[] = { 0x0061, 0x00a6, 0xdc01}; + static const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe}; + static const int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 }; @@ -421,21 +421,21 @@ static void TestErrorBehaviour(){ /*iso-2022-jp*/ log_verbose("Testing for iso-2022-jp\n"); { - UChar sampleText[] = { 0x0031, 0xd801}; - const uint8_t expected[] = { 0x31}; - int32_t offsets[] = { 0x00}; + static const UChar sampleText[] = { 0x0031, 0xd801}; + static const uint8_t expected[] = { 0x31}; + static const int32_t offsets[] = { 0x00}; - UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; - const uint8_t expected2[] = { 0x31,0x1A,0x32}; - int32_t offsets2[] = { 0x00,0x01,0x02}; + static const UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; + static const uint8_t expected2[] = { 0x31,0x1A,0x32}; + static const int32_t offsets2[] = { 0x00,0x01,0x02}; - UChar sampleText3MBCS[] = { 0x3000, 0x0050, 0xdc01,0x3001}; - const uint8_t expected3MBCS[] = { 0x1B, 0x24, 0x42, 0x21, 0x21, 0x1B, 0x28, 0x42, 0x50, 0x1A, 0x1B, 0x24, 0x42, 0x21, 0x22,}; - int32_t offsets3MBCS[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03,}; + static const UChar sampleText3MBCS[] = { 0x3000, 0x0050, 0xdc01,0x3001}; + static const uint8_t expected3MBCS[] = { 0x1B, 0x24, 0x42, 0x21, 0x21, 0x1B, 0x28, 0x42, 0x50, 0x1A, 0x1B, 0x24, 0x42, 0x21, 0x22,}; + static const int32_t offsets3MBCS[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03,}; - UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; - const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x42, 0x30, 0x6c,0x1b,0x28,0x42,0x1a}; - int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01,0x02,0x02,0x02,0x02 }; + static const UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; + static const uint8_t expected4MBCS[] = { 0x61, 0x1b, 0x24, 0x42, 0x30, 0x6c,0x1b,0x28,0x42,0x1a}; + static const int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01,0x02,0x02,0x02,0x02 }; if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "iso-2022-jp", offsets, TRUE, U_TRUNCATED_CHAR_FOUND)) log_err("u-> iso-2022-jp [UCNV_MBCS] \n"); @@ -470,21 +470,21 @@ static void TestErrorBehaviour(){ /*iso-2022-cn*/ log_verbose("Testing for iso-2022-cn\n"); { - UChar sampleText[] = { 0x0031, 0xd801}; - const uint8_t expected[] = { 0x0f, 0x31}; - int32_t offsets[] = { 0x00, 0x00}; + static const UChar sampleText[] = { 0x0031, 0xd801}; + static const uint8_t expected[] = { 0x0f, 0x31}; + static const int32_t offsets[] = { 0x00, 0x00}; - UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; - const uint8_t expected2[] = { 0x0f, 0x31, 0x1A,0x32}; - int32_t offsets2[] = { 0x00, 0x00, 0x01,0x02}; + static const UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; + static const uint8_t expected2[] = { 0x0f, 0x31, 0x1A,0x32}; + static const int32_t offsets2[] = { 0x00, 0x00, 0x01,0x02}; - UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; - const uint8_t expected3MBCS[] = {0x0f, 0x51, 0x50, 0x1A}; - int32_t offsets3MBCS[] = { 0x00, 0x00, 0x01, 0x02 }; + static const UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; + static const uint8_t expected3MBCS[] = {0x0f, 0x51, 0x50, 0x1A}; + static const int32_t offsets3MBCS[] = { 0x00, 0x00, 0x01, 0x02 }; - UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; - const uint8_t expected4MBCS[] = { 0x0f, 0x61, 0x1b, 0x24, 0x29, 0x41, 0x0e, 0x52, 0x3b, 0x0f, 0x1a }; - int32_t offsets4MBCS[] = { 0x00, 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; + static const UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; + static const uint8_t expected4MBCS[] = { 0x0f, 0x61, 0x1b, 0x24, 0x29, 0x41, 0x0e, 0x52, 0x3b, 0x0f, 0x1a }; + static const int32_t offsets4MBCS[] = { 0x00, 0x00, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "iso-2022-cn", offsets, TRUE, U_TRUNCATED_CHAR_FOUND)) log_err("u-> iso-2022-cn [UCNV_MBCS] \n"); @@ -519,25 +519,25 @@ static void TestErrorBehaviour(){ /*iso-2022-kr*/ log_verbose("Testing for iso-2022-kr\n"); { - UChar sampleText[] = { 0x0031, 0xd801}; - const uint8_t expected[] = { 0x1b, 0x24, 0x29, 0x43, 0x31}; - int32_t offsets[] = { -1, -1, -1, -1, 0x00}; + static const UChar sampleText[] = { 0x0031, 0xd801}; + static const uint8_t expected[] = { 0x1b, 0x24, 0x29, 0x43, 0x31}; + static const int32_t offsets[] = { -1, -1, -1, -1, 0x00}; - UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; - const uint8_t expected2[] = { 0x1b, 0x24, 0x29, 0x43, 0x31, 0x1A, 0x32}; - int32_t offsets2[] = { -1, -1, -1, -1, 0x00, 0x01, 0x02}; + static const UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; + static const uint8_t expected2[] = { 0x1b, 0x24, 0x29, 0x43, 0x31, 0x1A, 0x32}; + static const int32_t offsets2[] = { -1, -1, -1, -1, 0x00, 0x01, 0x02}; - UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; - const uint8_t expected3MBCS[] = { 0x1b, 0x24, 0x29, 0x43, 0x51, 0x50, 0x1A }; - int32_t offsets3MBCS[] = { -1, -1, -1, -1, 0x00, 0x01, 0x02, 0x02 }; + static const UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; + static const uint8_t expected3MBCS[] = { 0x1b, 0x24, 0x29, 0x43, 0x51, 0x50, 0x1A }; + static const int32_t offsets3MBCS[] = { -1, -1, -1, -1, 0x00, 0x01, 0x02, 0x02 }; - UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01,0x4e00}; - const uint8_t expected4MBCS[] = { 0x1b, 0x24, 0x29, 0x43, + static const UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01,0x4e00}; + static const uint8_t expected4MBCS[] = { 0x1b, 0x24, 0x29, 0x43, 0x61, 0x0e, 0x6c, 0x69, 0x0f, 0x1a, 0x0e, 0x6c, 0x69,}; - int32_t offsets4MBCS[] = { -1, -1, -1, -1, 0x00, 0x01 ,0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03 }; + static const int32_t offsets4MBCS[] = { -1, -1, -1, -1, 0x00, 0x01 ,0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03 }; if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "iso-2022-kr", offsets, TRUE, U_TRUNCATED_CHAR_FOUND)) log_err("u-> iso-2022-kr [UCNV_MBCS] \n"); @@ -573,21 +573,21 @@ static void TestErrorBehaviour(){ /*HZ*/ log_verbose("Testing for HZ\n"); { - UChar sampleText[] = { 0x0031, 0xd801}; - const uint8_t expected[] = { 0x7e, 0x7d, 0x31}; - int32_t offsets[] = { 0x00, 0x00, 0x00}; + static const UChar sampleText[] = { 0x0031, 0xd801}; + static const uint8_t expected[] = { 0x7e, 0x7d, 0x31}; + static const int32_t offsets[] = { 0x00, 0x00, 0x00}; - UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; - const uint8_t expected2[] = { 0x7e, 0x7d, 0x31, 0x1A, 0x32 }; - int32_t offsets2[] = { 0x00, 0x00, 0x00, 0x01, 0x02 }; + static const UChar sampleText2[] = { 0x0031, 0xd801, 0x0032}; + static const uint8_t expected2[] = { 0x7e, 0x7d, 0x31, 0x1A, 0x32 }; + static const int32_t offsets2[] = { 0x00, 0x00, 0x00, 0x01, 0x02 }; - UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; - const uint8_t expected3MBCS[] = { 0x7e, 0x7d, 0x51, 0x50, 0x1A }; - int32_t offsets3MBCS[] = { 0x00, 0x00, 0x00, 0x01, 0x02}; + static const UChar sampleText3MBCS[] = { 0x0051, 0x0050, 0xdc01}; + static const uint8_t expected3MBCS[] = { 0x7e, 0x7d, 0x51, 0x50, 0x1A }; + static const int32_t offsets3MBCS[] = { 0x00, 0x00, 0x00, 0x01, 0x02}; - UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; - const uint8_t expected4MBCS[] = { 0x7e, 0x7d, 0x61, 0x7e, 0x7b, 0x52, 0x3b, 0x7e, 0x7d, 0x1a }; - int32_t offsets4MBCS[] = { 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 ,0x01, 0x02, 0x02, 0x02 }; + static const UChar sampleText4MBCS[] = { 0x0061, 0x4e00, 0xdc01}; + static const uint8_t expected4MBCS[] = { 0x7e, 0x7d, 0x61, 0x7e, 0x7b, 0x52, 0x3b, 0x7e, 0x7d, 0x1a }; + static const int32_t offsets4MBCS[] = { 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 ,0x01, 0x02, 0x02, 0x02 }; if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "HZ", offsets, TRUE, U_TRUNCATED_CHAR_FOUND)) log_err("u-> HZ [UCNV_MBCS] \n"); @@ -906,7 +906,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){ } static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus) + const char *codepage, const int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus) { int32_t i=0; @@ -995,7 +995,7 @@ static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *e static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expect, int expectLen, - const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus) + const char *codepage, const int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus) { UErrorCode status = U_ZERO_ERROR; UConverter *conv = 0; @@ -1092,7 +1092,7 @@ static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expe static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, UConverterFromUCallback callback , int32_t *expectOffsets, UBool testReset) + const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets, UBool testReset) { UErrorCode status = U_ZERO_ERROR; UConverter *conv = 0; @@ -1264,7 +1264,7 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_ } static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen, - const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets, UBool testReset) + const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets, UBool testReset) { UErrorCode status = U_ZERO_ERROR; UConverter *conv = 0; @@ -1436,13 +1436,13 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar * static void TestResetBehaviour(void){ log_verbose("Testing Reset for SBCS and LATIN_1\n"); { - UChar sampleText[] = {0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x31, 0x1a, 0x32}; - int32_t offsets[] = { 0,1,3}; + static const UChar sampleText[] = {0x0031, 0xd801, 0xdc01, 0x0032}; + static const uint8_t expected[] = {0x31, 0x1a, 0x32}; + static const int32_t offsets[] = { 0,1,3}; - UChar sampleText1[] = {0x0031, 0x0033, 0x0034, 0x0032}; - const uint8_t expected1[] = {0x31, 0x33,0x34, 0x32}; - int32_t offsets1[] = { 0,1,2,3}; + static const UChar sampleText1[] = {0x0031, 0x0033, 0x0034, 0x0032}; + static const uint8_t expected1[] = {0x31, 0x33,0x34, 0x32}; + static const int32_t offsets1[] = { 0,1,2,3}; /*SBCS*/ if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), @@ -1467,14 +1467,14 @@ static void TestResetBehaviour(void){ } log_verbose("Testing Reset for DBCS and MBCS\n"); { - UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4}; - const uint8_t expected[] = {0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4}; - int32_t offsets[] = {0x00, 0x00, 0x01, 0x01, 0x03, 0x03 }; + static const UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4}; + static const uint8_t expected[] = {0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4}; + static const int32_t offsets[] = {0x00, 0x00, 0x01, 0x01, 0x03, 0x03 }; - UChar sampleText1[] = {0x00a1, 0x00a4, 0x00a7, 0x00a8}; - const uint8_t expected1[] = {0xa2, 0xae,0xA2,0xB4,0xA1,0xD7,0xA1,0xA7}; - int32_t offsets1[] = { 0,2,4,6}; + static const UChar sampleText1[] = {0x00a1, 0x00a4, 0x00a7, 0x00a8}; + static const uint8_t expected1[] = {0xa2, 0xae,0xA2,0xB4,0xA1,0xD7,0xA1,0xA7}; + static const int32_t offsets1[] = { 0,2,4,6}; /*DBCS*/ if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), @@ -1504,19 +1504,19 @@ static void TestResetBehaviour(void){ } log_verbose("Testing Reset for ISO-2022-jp\n"); { - UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x1b, 0x24, 0x42,0x30,0x6c,0x43,0x7a,0x1b,0x28,0x42, + static const uint8_t expected[] = {0x1b, 0x24, 0x42,0x30,0x6c,0x43,0x7a,0x1b,0x28,0x42, 0x31,0x1A, 0x32}; - int32_t offsets[] = {0,0,0,0,0,1,1,2,2,2,2,3,5 }; + static const int32_t offsets[] = {0,0,0,0,0,1,1,2,2,2,2,3,5 }; - UChar sampleText1[] = {0x4e00, 0x04e01, 0x0031,0x001A, 0x0032}; - const uint8_t expected1[] = {0x1b, 0x24, 0x42,0x30,0x6c,0x43,0x7a,0x1b,0x28,0x42, + static const UChar sampleText1[] = {0x4e00, 0x04e01, 0x0031,0x001A, 0x0032}; + static const uint8_t expected1[] = {0x1b, 0x24, 0x42,0x30,0x6c,0x43,0x7a,0x1b,0x28,0x42, 0x31,0x1A, 0x32}; - int32_t offsets1[] = { 3,5,10,11,12}; + static const int32_t offsets1[] = { 3,5,10,11,12}; /*iso-2022-jp*/ if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), @@ -1534,9 +1534,9 @@ static void TestResetBehaviour(void){ } log_verbose("Testing Reset for ISO-2022-cn\n"); { - UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = { + static const uint8_t expected[] = { 0x1B, 0x24, 0x29, 0x41, 0x0E, 0x52, 0x3B, 0x36, 0x21, 0x0f, 0x31, @@ -1545,7 +1545,7 @@ static void TestResetBehaviour(void){ }; - int32_t offsets[] = { + static const int32_t offsets[] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, @@ -1553,14 +1553,14 @@ static void TestResetBehaviour(void){ 5, 5, }; UChar sampleText1[] = {0x4e00, 0x04e01, 0x0031,0x001A, 0x0032}; - const uint8_t expected1[] = { + static const uint8_t expected1[] = { 0x1B, 0x24, 0x29, 0x41, 0x0E, 0x52, 0x3B, 0x36, 0x21, 0x1B, 0x24, 0x29, 0x47, 0x1B, 0x4E, 0x24, 0x22, 0x0f, 0x1A, 0x32 }; - int32_t offsets1[] = { 5,7,15,18,19}; + static const int32_t offsets1[] = { 5,7,15,18,19}; /*iso-2022-CN*/ if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), @@ -1579,7 +1579,7 @@ static void TestResetBehaviour(void){ { UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x1B, 0x24, 0x29, 0x43, + static const uint8_t expected[] = {0x1B, 0x24, 0x29, 0x43, 0x0E, 0x6C, 0x69, 0x0f, 0x1A, 0x0e, 0x6F, 0x4B, @@ -1587,7 +1587,7 @@ static void TestResetBehaviour(void){ 0x1A, 0x32 }; - int32_t offsets[] = {-1, -1, -1, -1, + static const int32_t offsets[] = {-1, -1, -1, -1, 0, 0, 0, 1, 1, 3, 3, 3, @@ -1595,9 +1595,9 @@ static void TestResetBehaviour(void){ 5, 7, }; - UChar sampleText1[] = { 0x4e00,0x0041, 0x04e01, 0x0031, 0x0042, 0x0032}; + static const UChar sampleText1[] = { 0x4e00,0x0041, 0x04e01, 0x0031, 0x0042, 0x0032}; - const uint8_t expected1[] = {0x1B, 0x24, 0x29, 0x43, + static const uint8_t expected1[] = {0x1B, 0x24, 0x29, 0x43, 0x0E, 0x6C, 0x69, 0x0f, 0x41, 0x0e, 0x6F, 0x4B, @@ -1605,7 +1605,7 @@ static void TestResetBehaviour(void){ 0x42, 0x32 }; - int32_t offsets1[] = { + static const int32_t offsets1[] = { 5, 8, 10, 13, 14, 15 @@ -1624,9 +1624,9 @@ static void TestResetBehaviour(void){ } log_verbose("Testing Reset for HZ\n"); { - UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032}; - const uint8_t expected[] = {0x7E, 0x7B, 0x52, 0x3B, + static const uint8_t expected[] = {0x7E, 0x7B, 0x52, 0x3B, 0x7E, 0x7D, 0x1A, 0x7E, 0x7B, 0x36, 0x21, 0x7E, 0x7D, 0x31, @@ -1634,15 +1634,15 @@ static void TestResetBehaviour(void){ 0x32 }; - int32_t offsets[] = {0,0,0,0, + static const int32_t offsets[] = {0,0,0,0, 1,1,1, 3,3,3,3, 4,4,4, 5, 7,}; - UChar sampleText1[] = { 0x4e00, 0x0035, 0x04e01, 0x0031, 0x0041, 0x0032}; + static const UChar sampleText1[] = { 0x4e00, 0x0035, 0x04e01, 0x0031, 0x0041, 0x0032}; - const uint8_t expected1[] = {0x7E, 0x7B, 0x52, 0x3B, + static const uint8_t expected1[] = {0x7E, 0x7B, 0x52, 0x3B, 0x7E, 0x7D, 0x35, 0x7E, 0x7B, 0x36, 0x21, 0x7E, 0x7D, 0x31, @@ -1650,7 +1650,7 @@ static void TestResetBehaviour(void){ 0x32 }; - int32_t offsets1[] = {2,6,9,13,14,15 + static const int32_t offsets1[] = {2,6,9,13,14,15 }; /*hz*/ @@ -1668,15 +1668,15 @@ static void TestResetBehaviour(void){ /*UTF-8*/ log_verbose("Testing for UTF8\n"); { - UChar sampleText[] = { 0x4e00, 0x0701, 0x0031, 0xbfc1, 0xd801, 0xdc01, 0x0032}; + static const UChar sampleText[] = { 0x4e00, 0x0701, 0x0031, 0xbfc1, 0xd801, 0xdc01, 0x0032}; int32_t offsets[]={0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x06 }; - const uint8_t expected[] = {0xe4, 0xb8, 0x80, 0xdc, 0x81, 0x31, + static const uint8_t expected[] = {0xe4, 0xb8, 0x80, 0xdc, 0x81, 0x31, 0xeb, 0xbf, 0x81, 0xF0, 0x90, 0x90, 0x81, 0x32}; - int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; + static const int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D }; /*UTF-8*/ if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]), expected, sizeof(expected), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE,offsets , TRUE)) diff --git a/icu4c/source/test/cintltst/nucnvtst.c b/icu4c/source/test/cintltst/nucnvtst.c index 4ad45cdd881..6a1cda260d4 100644 --- a/icu4c/source/test/cintltst/nucnvtst.c +++ b/icu4c/source/test/cintltst/nucnvtst.c @@ -4227,9 +4227,9 @@ static void TestJitterbug792() static void TestEBCDICUS4XML() { UChar unicodes_x[] = {0x0000, 0x0000, 0x0000, 0x0000}; - const UChar toUnicodeMaps_x[] = {0x000A, 0x000A, 0x000D, 0x0000}; - const char fromUnicodeMaps_x[] = {0x25, 0x25, 0x0D, 0x00}; - const char newLines_x[] = {0x25, 0x15, 0x0D, 0x00}; + static const UChar toUnicodeMaps_x[] = {0x000A, 0x000A, 0x000D, 0x0000}; + static const char fromUnicodeMaps_x[] = {0x25, 0x25, 0x0D, 0x00}; + static const char newLines_x[] = {0x25, 0x15, 0x0D, 0x00}; char target_x[] = {0x00, 0x00, 0x00, 0x00}; UChar *unicodes = unicodes_x; const UChar *toUnicodeMaps = toUnicodeMaps_x; @@ -4241,15 +4241,22 @@ static void TestEBCDICUS4XML() cnv = ucnv_open("ebcdic-xml-us", &status); if (U_FAILURE(status) || cnv == 0) { log_err("Failed to open the converter for EBCDIC-XML-US.\n"); - return; + return; } ucnv_toUnicode(cnv, &unicodes, unicodes+3, (const char**)&newLines, newLines+3, NULL, TRUE, &status); if (U_FAILURE(status) || memcmp(unicodes_x, toUnicodeMaps, sizeof(UChar)*3) != 0) { - log_err("To Unicode conversion failed in EBCDICUS4XML test.\n"); + log_err("To Unicode conversion failed in EBCDICUS4XML test. %s\n", + u_errorName(status)); + printUSeqErr(unicodes_x, 3); + printUSeqErr(toUnicodeMaps, 3); } + status = U_ZERO_ERROR; ucnv_fromUnicode(cnv, &target, target+3, (const UChar**)&toUnicodeMaps, toUnicodeMaps+3, NULL, TRUE, &status); if (U_FAILURE(status) || memcmp(target_x, fromUnicodeMaps, sizeof(char)*3) != 0) { - log_err("From Unicode conversion failed in EBCDICUS4XML test.\n"); + log_err("From Unicode conversion failed in EBCDICUS4XML test. %s\n", + u_errorName(status)); + printSeqErr(target_x, 3); + printSeqErr(fromUnicodeMaps, 3); } ucnv_close(cnv); }