From bb92483e1d3dd57a429b2a5626462cef9d057833 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 24 Oct 2000 21:01:12 +0000 Subject: [PATCH] ICU-544 some tests for gb 18030 X-SVN-Rev: 2773 --- icu4c/source/test/cintltst/nccbtst.c | 35 +++++++++++++++++++++++++--- icu4c/source/test/cintltst/nccbtst.h | 4 ++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/icu4c/source/test/cintltst/nccbtst.c b/icu4c/source/test/cintltst/nccbtst.c index 1acc19aad29..76558a42d6c 100644 --- a/icu4c/source/test/cintltst/nccbtst.c +++ b/icu4c/source/test/cintltst/nccbtst.c @@ -26,6 +26,7 @@ #define NEW_MAX_BUFFER 999 #define nct_min(x,y) ((xu with substitute did not match.\n");; } + log_verbose("Testing GB 18030 with substitute callbacks\n"); + { + static const UChar u1[]={ + 0x24, 0x7f, 0x80, 0x1f9, 0x20ac, 0x4e00, 0x9fa6, 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff }; + static const uint8_t gb1[]={ + 0x24, 0x7f, 0x84, 0x32, 0xeb, 0x38, 0xa8, 0xbf, 0x80, 0xd2, 0xbb, 0x82, 0x35, 0x8f, 0x34, 0x84, 0x32, 0xeb, 0x37, 0x90, 0x30, 0x81, 0x30, 0xe3, 0x32, 0x9a, 0x35 }; + static const offsets1[]={ + 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 10, 10, 10, 10 }; + + static const UChar u2[]={ + 0x24, 0x7f, 0x80, 0x1f9, 0x20ac, 0x4e00, 0x9fa6, 0xffff, 0xd800, 0xdc00, 0xfffd, 0xdbff, 0xdfff }; + static const uint8_t gb2[]={ + 0x24, 0x7f, 0x84, 0x32, 0xeb, 0x38, 0xa8, 0xbf, 0x80, 0xd2, 0xbb, 0x82, 0x35, 0x8f, 0x34, 0x84, 0x32, 0xeb, 0x37, 0x90, 0x30, 0x81, 0x30, 0xe3, 0x32, 0x9a, 0x36, 0xe3, 0x32, 0x9a, 0x35 }; + static const offsets2[]={ + 0, 1, 2, 6, 8, 9, 11, 15, 19, 19, 23, 27, 27 }; + + if(!testConvertFromUnicode(u1, ARRAY_LENGTH(u1), gb1, ARRAY_LENGTH(gb1), "gb18030", + (UConverterFromUCallback)UCNV_FROM_U_CALLBACK_SUBSTITUTE, offsets1, NULL, 0) + ) { + log_err("u->gb18030 with substitute did not match.\n"); + } + + if(!testConvertToUnicode(gb2, ARRAY_LENGTH(gb2), u2, ARRAY_LENGTH(u2), "gb18030", + (UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets2, NULL, 0) + ) { + log_err("gb18030->u with substitute did not match.\n"); + } + } } void TestSubWithValue(int32_t inputsize, int32_t outputsize) @@ -913,7 +942,7 @@ void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize) UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, UConverterFromUCallback callback , int32_t *expectOffsets, + const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets, const char *mySubChar, int8_t len) { @@ -1120,7 +1149,7 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t } UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen, - const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets, + const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets, const char *mySubChar, int8_t len) { UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/test/cintltst/nccbtst.h b/icu4c/source/test/cintltst/nccbtst.h index fb1b6f06bac..1f00f533841 100644 --- a/icu4c/source/test/cintltst/nccbtst.h +++ b/icu4c/source/test/cintltst/nccbtst.h @@ -40,12 +40,12 @@ static void TestSingleByte(int32_t inputsize, int32_t outputsize); static void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize); UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t *expect, int expectLen, - const char *codepage, UConverterFromUCallback callback, int32_t *expectOffsets, + const char *codepage, UConverterFromUCallback callback, const int32_t *expectOffsets, const char *mySubChar, int8_t len); UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen, - const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets, + const char *codepage, UConverterToUCallback callback, const int32_t *expectOffsets, const char *mySubChar, int8_t len);