ICU-5282 Fix problems found by uconfigtest.

X-SVN-Rev: 19922
This commit is contained in:
Eric Mader 2006-07-28 22:58:29 +00:00
parent cbb5fd45d1
commit 87731aeae7
24 changed files with 362 additions and 59 deletions

View file

@ -483,9 +483,13 @@ ucnv_setSubstString(UConverter *cnv,
return;
}
#if !UCONFIG_NO_LEGACY_CONVERSION
if (cnv->sharedData->impl->writeSub == NULL ||
(cnv->sharedData->staticData->conversionType == UCNV_MBCS &&
ucnv_MBCSGetType(cnv) != UCNV_EBCDIC_STATEFUL)
#else
if (cnv->sharedData->impl->writeSub == NULL
#endif
) {
/* The converter is not stateful. Store the charset bytes as a fixed string. */
subChars = (uint8_t *)chars;

View file

@ -101,7 +101,11 @@ static void TestCCSID(void);
static void TestJ932(void);
static void TestJ1968(void);
static void TestLMBCSMaxChar(void);
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestConvertSafeCloneCallback(void);
#endif
static void TestEBCDICSwapLFNL(void);
static void TestConvertEx(void);
static void TestConvertAlgorithmic(void);
@ -121,8 +125,12 @@ void addTestConvert(TestNode** root)
addTest(root, &TestFlushCache, "tsconv/ccapitst/TestFlushCache");
addTest(root, &TestAlias, "tsconv/ccapitst/TestAlias");
addTest(root, &TestDuplicateAlias, "tsconv/ccapitst/TestDuplicateAlias");
addTest(root, &TestConvertSafeClone, "tsconv/ccapitst/TestConvertSafeClone");
addTest(root, &TestConvertSafeCloneCallback,"tsconv/ccapitst/TestConvertSafeCloneCallback");
addTest(root, &TestConvertSafeClone, "tsconv/ccapitst/TestConvertSafeClone");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestConvertSafeCloneCallback,"tsconv/ccapitst/TestConvertSafeCloneCallback");
#endif
addTest(root, &TestCCSID, "tsconv/ccapitst/TestCCSID");
addTest(root, &TestJ932, "tsconv/ccapitst/TestJ932");
addTest(root, &TestJ1968, "tsconv/ccapitst/TestJ1968");
@ -249,6 +257,7 @@ static void ListNames(void) {
static void TestConvert()
{
#if !UCONFIG_NO_LEGACY_CONVERSION
char myptr[4];
char save[4];
int32_t testLong1 = 0;
@ -1058,6 +1067,7 @@ static void TestConvert()
free((void*)output_cp_buffer);
free((void*)ucs_file_buffer);
free((void*)my_ucs_file_buffer);
#endif
}
static UConverterFromUCallback otherUnicodeAction(UConverterFromUCallback MIA)
@ -1072,6 +1082,7 @@ static UConverterToUCallback otherCharAction(UConverterToUCallback MIA)
}
static void TestFlushCache(void) {
#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode err = U_ZERO_ERROR;
UConverter* someConverters[5];
int flushCount = 0;
@ -1141,7 +1152,7 @@ static void TestFlushCache(void) {
log_verbose("Flush cache ok\n");
else
log_data_err("Flush Cache failed line %d, expected 1 got %d \n", __LINE__, flushCount);
#endif
}
/**
@ -1483,6 +1494,7 @@ static void TSCC_print_log(TSCCContext *q, const char *name)
}
}
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestConvertSafeCloneCallback()
{
UErrorCode err = U_ZERO_ERROR;
@ -1648,6 +1660,7 @@ static void TestConvertSafeCloneCallback()
free(from2); /* from1 is stack based */
}
}
#endif
static UBool
containsAnyOtherByte(uint8_t *p, int32_t length, uint8_t b) {
@ -1665,18 +1678,26 @@ static void TestConvertSafeClone()
{
/* one 'regular' & all the 'private stateful' converters */
static const char *const names[] = {
#if !UCONFIG_NO_LEGACY_CONVERSION
"ibm-1047",
"ISO_2022,locale=zh,version=1",
#endif
"SCSU",
#if !UCONFIG_NO_LEGACY_CONVERSION
"HZ",
"lmbcs",
"ISCII,version=0",
"ISO_2022,locale=kr,version=1",
"ISO_2022,locale=jp,version=2",
#endif
"BOCU-1",
"UTF-7",
#if !UCONFIG_NO_LEGACY_CONVERSION
"IMAP-mailbox-name",
"ibm-1047-s390"
#else
"IMAP=mailbox-name"
#endif
};
/* store the actual sizes of each converter */
@ -1890,6 +1911,7 @@ static void TestConvertSafeClone()
}
static void TestCCSID() {
#if !UCONFIG_NO_LEGACY_CONVERSION
UConverter *cnv;
UErrorCode errorCode;
int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
@ -1916,6 +1938,7 @@ static void TestCCSID() {
ucnv_close(cnv);
}
#endif
}
/* jitterbug 932: ucnv_convert() bugs --------------------------------------- */
@ -1953,6 +1976,7 @@ TestJ932(void)
*/
static void bug1()
{
#if !UCONFIG_NO_LEGACY_CONVERSION
static char char_in[CHUNK_SIZE+32];
static char char_out[CHUNK_SIZE*2];
@ -1992,6 +2016,7 @@ static void bug1()
log_err("error j932 bug 1: expected success, got U_TRUNCATED_CHAR_FOUND\n");
}
}
#endif
}
/* bug2: pre-flighting loop bug: simple overflow causes bug */
@ -2066,6 +2091,7 @@ static void bug2()
*/
static void bug3()
{
#if !UCONFIG_NO_LEGACY_CONVERSION
static char char_in[CHUNK_SIZE*4];
static char target[5];
UErrorCode err = U_ZERO_ERROR;
@ -2120,6 +2146,7 @@ static void bug3()
*/
log_data_err("error j932 bug 3b: expected 0x%04x, got 0x%04x\n", sizeof(char_in) * 2, size);
}
#endif
}
static void
@ -2228,6 +2255,7 @@ convertExMultiStreaming(UConverter *srcCnv, UConverter *targetCnv,
}
static void TestConvertEx() {
#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t
utf8[]={
/* 4e00 30a1 ff61 0410 */
@ -2368,10 +2396,12 @@ static void TestConvertEx() {
ucnv_close(cnv1);
ucnv_close(cnv2);
#endif
}
static void
TestConvertAlgorithmic() {
#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t
utf8[]={
/* 4e00 30a1 ff61 0410 */
@ -2492,6 +2522,7 @@ TestConvertAlgorithmic() {
log_err("ucnv_fromAlgorithmic(illegal alg. type) sets %s\n", u_errorName(errorCode));
}
ucnv_close(cnv);
#endif
}
static void TestLMBCSMaxChar(void) {
@ -2651,6 +2682,7 @@ static void TestJ1968(void) {
}
#if !UCONFIG_NO_LEGACY_CONVERSION
static void
testSwap(const char *name, UBool swap) {
/*
@ -2804,10 +2836,17 @@ TestEBCDICSwapLFNL() {
testSwap(tests[i].name, tests[i].swap);
}
}
#else
static void
TestEBCDICSwapLFNL() {
/* test nothing... */
}
#endif
static const UVersionInfo ICU_34 = {3,4,0,0};
static void TestFromUCountPending(){
#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
/* const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; */
static const struct {
@ -2906,10 +2945,12 @@ static void TestFromUCountPending(){
}
}
ucnv_close(cnv);
#endif
}
static void
TestToUCountPending(){
#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
static const struct {
char input[6];
@ -3017,7 +3058,7 @@ TestToUCountPending(){
}
ucnv_close(cnv);
}
#endif
}
static void TestOneDefaultNameChange(const char *name) {
@ -3049,8 +3090,10 @@ static void TestDefaultName(void) {
/*change the default name by setting it */
TestOneDefaultNameChange("UTF-8");
#if !UCONFIG_NO_LEGACY_CONVERSION
TestOneDefaultNameChange("ISCII,version=1");
TestOneDefaultNameChange("ISCII,version=2");
#endif
TestOneDefaultNameChange("ISO-8859-1");
/*set the default name back*/
@ -3173,6 +3216,7 @@ TestSubstString() {
}
ucnv_close(cnv);
#if !UCONFIG_NO_LEGACY_CONVERSION
errorCode=U_ZERO_ERROR;
cnv=ucnv_open("HZ", &errorCode);
if(U_FAILURE(errorCode)) {
@ -3191,7 +3235,7 @@ TestSubstString() {
}
}
ucnv_close(cnv);
#endif
/*
* Further testing of ucnv_setSubstString() is done via intltest convert.
* We do not test edge cases of illegal arguments and similar because the

View file

@ -2370,6 +2370,7 @@ static UBool isLocaleAvailable(UResourceBundle* resIndex, const char* loc){
}
static void TestCalendar() {
#if !UCONFIG_NO_FORMATTING
int i;
UErrorCode status = U_ZERO_ERROR;
UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
@ -2401,9 +2402,11 @@ static void TestCalendar() {
ucal_close(c2);
}
ures_close(resIndex);
#endif
}
static void TestDateFormat() {
#if !UCONFIG_NO_FORMATTING
int i;
UErrorCode status = U_ZERO_ERROR;
UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
@ -2442,9 +2445,11 @@ static void TestDateFormat() {
udat_close(df2);
}
ures_close(resIndex);
#endif
}
static void TestCollation() {
#if !UCONFIG_NO_COLLATION
int i;
UErrorCode status = U_ZERO_ERROR;
UResourceBundle *resIndex = ures_open(NULL,"res_index", &status);
@ -2483,6 +2488,7 @@ static void TestCollation() {
ucol_close(c2);
}
ures_close(resIndex);
#endif
}
static void TestULocale() {

View file

@ -639,6 +639,7 @@ static void TestNewTypes() {
}
}
/* test for jitterbug#2626 */
#if !UCONFIG_NO_COLLATION
{
UResourceBundle* resB = NULL;
const UChar* str = NULL;
@ -655,6 +656,7 @@ static void TestNewTypes() {
}
ures_close(resB);
}
#endif
{
const char *sourcePath = ctest_dataSrcDir();
int32_t srcPathLen = (int32_t)strlen(sourcePath);

View file

@ -1522,6 +1522,11 @@ TestUNormIterator() {
/* test nothing */
}
static void
TestBadUNormIterator(void) {
/* test nothing, as well */
}
#else
#include "unicode/unorm.h"

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2005, International Business Machines Corporation and
* Copyright (c) 1999-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
@ -11,6 +11,7 @@
void TestEuroRegression(void);
void addTestEuroRegression(TestNode** root);
#if !UCONFIG_NO_LEGACY_CONVERSION
void addTestEuroRegression(TestNode** root)
{
addTest(root, &TestEuroRegression, "tsconv/eurocreg/TestEuroRegression");
@ -179,3 +180,9 @@ UBool isEuroAware(UConverter* myConv)
}
}
#else
void addTestEuroRegression(TestNode** root)
{
/* test nothing... */
}
#endif

View file

@ -90,8 +90,12 @@ void addTestConvertErrorCallBack(TestNode** root)
addTest(root, &TestStopCallBack, "tsconv/nccbtst/TestStopCallBack");
addTest(root, &TestSubCallBack, "tsconv/nccbtst/TestSubCallBack");
addTest(root, &TestSubWithValueCallBack, "tsconv/nccbtst/TestSubWithValueCallBack");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestLegalAndOtherCallBack, "tsconv/nccbtst/TestLegalAndOtherCallBack");
addTest(root, &TestSingleByteCallBack, "tsconv/nccbtst/TestSingleByteCallBack");
#endif
addTest(root, &TestCallBackFailure, "tsconv/nccbtst/TestCallBackFailure");
}
@ -117,12 +121,13 @@ static void TestSubCallBack()
TestSub(1,NEW_MAX_BUFFER);
TestSub(1,1);
TestSub(NEW_MAX_BUFFER, 1);
#if !UCONFIG_NO_LEGACY_CONVERSION
TestEBCDIC_STATEFUL_Sub(1, 1);
TestEBCDIC_STATEFUL_Sub(1, NEW_MAX_BUFFER);
TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, 1);
TestEBCDIC_STATEFUL_Sub(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
#endif
}
static void TestSubWithValueCallBack()
@ -133,6 +138,7 @@ static void TestSubWithValueCallBack()
TestSubWithValue(NEW_MAX_BUFFER, 1);
}
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestLegalAndOtherCallBack()
{
TestLegalAndOthers(NEW_MAX_BUFFER, NEW_MAX_BUFFER);
@ -148,6 +154,7 @@ static void TestSingleByteCallBack()
TestSingleByte(1,1);
TestSingleByte(NEW_MAX_BUFFER, 1);
}
#endif
static void TestSkip(int32_t inputsize, int32_t outputsize)
{
@ -166,6 +173,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
/*From Unicode*/
log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_SKIP \n");
#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const UChar sampleText[] = { 0x0000, 0xAC00, 0xAC01, 0xEF67, 0xD700 };
static const UChar sampleText2[] = { 0x6D63, 0x6D64, 0x6D65, 0x6D66 };
@ -198,6 +206,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->ibm-930 with skip with untaken fallbacks did not match.\n");
}
}
#endif
{
static const UChar usasciiFromU[] = { 0x61, 0x80, 0x4e00, 0x31, 0xd800, 0xdfff, 0x39 };
@ -218,6 +227,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->US-ASCII with skip did not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
/* SBCS NLTC codepage 367 for US-ASCII */
if(!testConvertFromUnicode(usasciiFromU, sizeof(usasciiFromU)/U_SIZEOF_UCHAR,
usasciiFromUBytes, sizeof(usasciiFromUBytes),
@ -227,6 +237,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("u->ibm-367 with skip did not match.\n");
}
#endif
/* ISO-Latin-1 */
if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
@ -238,6 +249,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("u->LATIN_1 with skip did not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
/* windows-1252 */
if(!testConvertFromUnicode(latin1FromU, sizeof(latin1FromU)/U_SIZEOF_UCHAR,
latin1FromUBytes, sizeof(latin1FromUBytes),
@ -370,6 +382,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
};
#endif
static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
@ -384,6 +397,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
2,
};
#if !UCONFIG_NO_LEGACY_CONVERSION
/* ISCII */
static const UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, };
static const uint8_t to_iscii[]={
@ -461,7 +476,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
if(!testConvertFromUnicodeWithContext(hz_inputText1, sizeof(hz_inputText1)/sizeof(hz_inputText1[0]),
to_hz1, sizeof(to_hz1), "hz",
UCNV_FROM_U_CALLBACK_SKIP, from_hzOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
log_err("u-> hz with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
log_err("u-> hz with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
#endif
/*SCSU*/
if(!testConvertFromUnicode(SCSU_inputText, sizeof(SCSU_inputText)/sizeof(SCSU_inputText[0]),
@ -469,6 +485,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SKIP, from_SCSUOffs, NULL, 0 ))
log_err("u-> SCSU with skip did not match.\n");
#if !UCONFIG_NO_LEGACY_CONVERSION
/*ISCII*/
if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
to_iscii, sizeof(to_iscii), "ISCII,version=0",
@ -479,7 +496,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
to_iscii1, sizeof(to_iscii1), "ISCII,version=0",
UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
log_err("u-> iscii with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
#endif
}
log_verbose("Testing fromUnicode for BOCU-1 with UCNV_TO_U_CALLBACK_SKIP\n");
@ -630,6 +647,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
/*to Unicode*/
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_SKIP \n");
#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const UChar IBM_949skiptoUnicode[]= {0x0000, 0xAC00, 0xAC01, 0xD700 };
@ -661,6 +679,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
UCNV_TO_U_CALLBACK_SKIP, fromIBM930Offs, NULL, 0,"i",U_ILLEGAL_CHAR_FOUND ))
log_err("ibm-930->u with skip did not match.\n");
}
#endif
{
static const uint8_t usasciiToUBytes[] = { 0x61, 0x80, 0x31 };
@ -681,6 +700,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("US-ASCII->u with skip did not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
/* SBCS NLTC codepage 367 for US-ASCII */
if(!testConvertToUnicode(usasciiToUBytes, sizeof(usasciiToUBytes),
usasciiToU, sizeof(usasciiToU)/U_SIZEOF_UCHAR,
@ -690,6 +710,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("ibm-367->u with skip did not match.\n");
}
#endif
/* ISO-Latin-1 */
if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
@ -701,6 +722,7 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("LATIN_1->u with skip did not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
/* windows-1252 */
if(!testConvertToUnicode(latin1ToUBytes, sizeof(latin1ToUBytes),
latin1ToU, sizeof(latin1ToU)/U_SIZEOF_UCHAR,
@ -710,8 +732,10 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
) {
log_err("windows-1252->u with skip did not match.\n");
}
#endif
}
#if !UCONFIG_NO_LEGACY_CONVERSION
{
static const uint8_t sampleTxtEBCIDIC_STATEFUL [] ={
0x0e, 0x5d, 0x5f , 0x41, 0x79, 0x41, 0x44
@ -874,6 +898,8 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
log_err("LMBCS->u with skip did not match.\n");
}
#endif
log_verbose("Testing to Unicode for UTF-8 with UCNV_TO_U_CALLBACK_SKIP \n");
{
const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@ -1073,7 +1099,10 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
gInBufferSize = inputsize;
gOutBufferSize = outputsize;
/*From Unicode*/
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expstopIBM_949, sizeof(expstopIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_STOP, toIBM949Offsstop, NULL, 0 ))
@ -1205,6 +1234,8 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
}
#endif
log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_STOP \n");
{
static const UChar SCSU_inputText[]={ 0x0041, 0xd801/*illegal*/, 0x0042, };
@ -1223,7 +1254,10 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
log_err("u-> SCSU with skip did not match.\n");
}
/*to Unicode*/
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(expstopIBM_949, sizeof(expstopIBM_949),
IBM_949stoptoUnicode, sizeof(IBM_949stoptoUnicode)/sizeof(IBM_949stoptoUnicode[0]),"ibm-949",
UCNV_TO_U_CALLBACK_STOP, fromIBM949Offs, NULL, 0 ))
@ -1280,6 +1314,8 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
UCNV_TO_U_CALLBACK_STOP, from_euc_twOffs, NULL, 0 ))
log_err("euc-tw->u with stop did not match.\n");
}
#endif
log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_STOP \n");
{
static const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@ -1336,6 +1372,8 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
gOutBufferSize = outputsize;
/*from unicode*/
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expsubIBM_949, sizeof(expsubIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_SUBSTITUTE, toIBM949Offssub, NULL, 0 ))
@ -1389,6 +1427,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SUBSTITUTE, from_euc_twOffs, NULL, 0 ))
log_err("u-> euc-tw with substitute did not match.\n");
}
#endif
log_verbose("Testing fromUnicode for SCSU with UCNV_FROM_U_CALLBACK_SUBSTITUTE \n");
{
@ -1498,6 +1537,8 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
}
/*to unicode*/
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(expsubIBM_949, sizeof(expsubIBM_949),
IBM_949subtoUnicode, sizeof(IBM_949subtoUnicode)/sizeof(IBM_949subtoUnicode[0]),"ibm-949",
UCNV_TO_U_CALLBACK_SUBSTITUTE, fromIBM949Offs, NULL, 0 ))
@ -1562,10 +1603,9 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
euc_jptoUnicode, sizeof(euc_jptoUnicode)/sizeof(euc_jptoUnicode[0]),"euc-jp",
UCNV_TO_U_CALLBACK_SUBSTITUTE, from_euc_jpOffs, NULL, 0 ,"i", U_ILLEGAL_CHAR_FOUND))
log_err("euc-jp->u with substitute did not match.\n");
}
#endif
log_verbose("Testing toUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
{
const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
@ -1590,6 +1630,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
log_err("scsu->u with stop did not match.\n");;
}
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing ibm-930 subchar/subchar1\n");
{
static const UChar u1[]={ 0x6d63, 0x6d64, 0x6d65, 0x6d66, 0xdf };
@ -1628,6 +1669,7 @@ static void TestSub(int32_t inputsize, int32_t outputsize)
log_err("gb18030->u with substitute did not match.\n");
}
}
#endif
log_verbose("Testing UTF-7 toUnicode with substitute callbacks\n");
{
@ -1755,6 +1797,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
gOutBufferSize = outputsize;
/*from Unicode*/
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertFromUnicode(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expsubwvalIBM_949, sizeof(expsubwvalIBM_949), "ibm-949",
UCNV_FROM_U_CALLBACK_ESCAPE, toIBM949Offs, NULL, 0 ))
@ -2192,11 +2236,12 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0 ))
log_err("u-> iscii with subst with value did not match.\n");
}
#endif
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
/*to Unicode*/
{
#if !UCONFIG_NO_LEGACY_CONVERSION
static const uint8_t sampleTxtToU[]= { 0x00, 0x9f, 0xaf,
0x81, 0xad, /*unassigned*/
0x89, 0xd3 };
@ -2307,7 +2352,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
0x42,};
static const int32_t from_isciiOffs [] ={0,1,2,2,2,2,3,4,5,5,5,5,6 };
#endif
/*UTF8*/
static const uint8_t sampleTxtUTF8[]={
@ -2346,7 +2391,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
9
};
#if !UCONFIG_NO_LEGACY_CONVERSION
if(!testConvertToUnicode(sampleTxtToU, sizeof(sampleTxtToU),
IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs, NULL, 0 ))
@ -2429,6 +2475,8 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
UCNV_TO_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0))
log_err("ISCII ->u with substitute with value did not match.\n");
#endif
if(!testConvertToUnicode(sampleTxtUTF8, sizeof(sampleTxtUTF8),
UTF8ToUnicode, sizeof(UTF8ToUnicode)/sizeof(UTF8ToUnicode[0]),"UTF-8",
UCNV_TO_U_CALLBACK_ESCAPE, fromUTF8, NULL, 0))
@ -2440,6 +2488,7 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
}
}
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestLegalAndOthers(int32_t inputsize, int32_t outputsize)
{
static const UChar legalText[] = { 0x0000, 0xAC00, 0xAC01, 0xD700 };
@ -2527,8 +2576,7 @@ static void TestEBCDIC_STATEFUL_Sub(int32_t inputsize, int32_t outputsize)
UCNV_FROM_U_CALLBACK_SUBSTITUTE, offset_930_subvaried, mySubChar, 1 ))
log_err("u-> ibm-930(EBCDIC_STATEFUL) with subst(setSubChar=0x3f) did not match.\n");
}
#endif
UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
const char *codepage, UConverterFromUCallback callback , const int32_t *expectOffsets,

View file

@ -23,6 +23,7 @@
#include "cmemory.h"
#include "cstring.h"
#if !UCONFIG_NO_LEGACY_CONVERSION
#define NEW_MAX_BUFFER 999
@ -745,3 +746,10 @@ static void TestConvertFallBackWithBufferSizes(int32_t outsize, int32_t insize )
}
}
#else
void addTestConverterFallBack(TestNode** root)
{
/* test nothing... */
}
#endif

View file

@ -61,8 +61,12 @@ static void setNuConvTestName(const char *codepage, const char *direction)
static void TestSurrogateBehaviour(void);
static void TestErrorBehaviour(void);
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestToUnicodeErrorBehaviour(void);
static void TestGetNextErrorBehaviour(void);
#endif
static void TestRegressionUTF8(void);
static void TestRegressionUTF32(void);
static void TestAvailableConverters(void);
@ -115,8 +119,12 @@ void addExtraTests(TestNode** root)
{
addTest(root, &TestSurrogateBehaviour, "tsconv/ncnvtst/TestSurrogateBehaviour");
addTest(root, &TestErrorBehaviour, "tsconv/ncnvtst/TestErrorBehaviour");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestToUnicodeErrorBehaviour, "tsconv/ncnvtst/ToUnicodeErrorBehaviour");
addTest(root, &TestGetNextErrorBehaviour, "tsconv/ncnvtst/TestGetNextErrorBehaviour");
#endif
addTest(root, &TestAvailableConverters, "tsconv/ncnvtst/TestAvailableConverters");
addTest(root, &TestFlushInternalBuffer, "tsconv/ncnvtst/TestFlushInternalBuffer");
addTest(root, &TestResetBehaviour, "tsconv/ncnvtst/TestResetBehaviour");
@ -132,10 +140,13 @@ static void TestSurrogateBehaviour(){
{
UChar sampleText[] = {0x0031, 0xd801, 0xdc01, 0x0032};
const uint8_t expected[] = {0x31, 0x1a, 0x32};
#if !UCONFIG_NO_LEGACY_CONVERSION
/*SBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "ibm-920", 0 , TRUE, U_ZERO_ERROR))
log_err("u-> ibm-920 [UCNV_SBCS] not match.\n");
#endif
/*LATIN_1*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
@ -143,6 +154,8 @@ static void TestSurrogateBehaviour(){
log_err("u-> LATIN_1 not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing for DBCS and MBCS\n");
{
UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4};
@ -164,6 +177,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "ibm-1363", offsets, TRUE, U_ZERO_ERROR))
log_err("u-> ibm-1363 [UCNV_MBCS] not match.\n");
}
log_verbose("Testing for ISO-2022-jp\n");
{
UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -182,6 +196,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-jp", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
}
log_verbose("Testing for ISO-2022-cn\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -211,6 +226,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-cn", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
}
log_verbose("Testing for ISO-2022-kr\n");
{
static const UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -240,6 +256,7 @@ static void TestSurrogateBehaviour(){
expected, sizeof(expected), "iso-2022-kr", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> iso-2022-kr [UCNV_DBCS] not match.\n");
}
log_verbose("Testing for HZ\n");
{
static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -262,11 +279,13 @@ static void TestSurrogateBehaviour(){
/*hz*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "HZ", 0 , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
log_err("u-> HZ not match.\n");
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "HZ", offsets , TRUE, U_ZERO_ERROR))
log_err("u-> not match.\n");
log_err("u-> HZ not match.\n");
}
#endif
/*UTF-8*/
log_verbose("Testing for UTF8\n");
{
@ -295,21 +314,18 @@ static void TestSurrogateBehaviour(){
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, TRUE, U_ZERO_ERROR ))
log_err("UTF8 -> did not match.\n");
log_err("UTF8 -> u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, FALSE, U_ZERO_ERROR ))
log_err("UTF8 -> did not match.\n");
log_err("UTF8 -> u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, TRUE, U_ZERO_ERROR ))
log_err("UTF8 -> did not match.\n");
log_err("UTF8 ->u did not match.\n");
if(!convertToU(expected, sizeof(expected),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, FALSE, U_ZERO_ERROR ))
log_err("UTF8 -> did not match.\n");
log_err("UTF8 -> u did not match.\n");
}
}
/*test various error behaviours*/
@ -322,6 +338,7 @@ static void TestErrorBehaviour(){
static const uint8_t expected[] = { 0x31, 0x1a};
static const uint8_t expected2[] = { 0x31, 0x1a, 0x32};
#if !UCONFIG_NO_LEGACY_CONVERSION
/*SBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expected, sizeof(expected), "ibm-920", 0, TRUE, U_ZERO_ERROR))
@ -332,7 +349,7 @@ static void TestErrorBehaviour(){
if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
expected2, sizeof(expected2), "ibm-920", 0, TRUE, U_ZERO_ERROR))
log_err("u-> ibm-920 [UCNV_SBCS] did not match\n");
#endif
/*LATIN_1*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
@ -347,7 +364,7 @@ static void TestErrorBehaviour(){
log_err("u-> LATIN_1 did not match\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing for DBCS and MBCS\n");
{
static const UChar sampleText[] = { 0x00a1, 0xd801};
@ -368,10 +385,6 @@ static void TestErrorBehaviour(){
static const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe};
static const int32_t offsets4MBCS[] = { 0x00, 0x01, 0x01, 0x01, 0x02, 0x02 };
/*DBCS*/
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedSUB, sizeof(expectedSUB), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
@ -427,6 +440,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> euc-jp [UCNV_MBCS] \n");
}
/*iso-2022-jp*/
log_verbose("Testing for iso-2022-jp\n");
{
@ -466,6 +480,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "iso-2022-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> iso-2022-jp [UCNV_MBCS] \n");
}
/*iso-2022-cn*/
log_verbose("Testing for iso-2022-cn\n");
{
@ -516,6 +531,7 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "iso-2022-cn", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> iso-2022-cn [UCNV_MBCS] \n");
}
/*iso-2022-kr*/
log_verbose("Testing for iso-2022-kr\n");
{
@ -607,10 +623,10 @@ static void TestErrorBehaviour(){
expected4MBCS, sizeof(expected4MBCS), "HZ", offsets4MBCS, FALSE, U_ZERO_ERROR))
log_err("u-> HZ [UCNV_MBCS] \n");
}
#endif
}
#if !UCONFIG_NO_LEGACY_CONVERSION
/*test different convertToUnicode error behaviours*/
static void TestToUnicodeErrorBehaviour()
{
@ -662,6 +678,7 @@ static void TestGetNextErrorBehaviour(){
}
ucnv_close(cnv);
}
#endif
#define MAX_UTF16_LEN 2
#define MAX_UTF8_LEN 4
@ -697,6 +714,7 @@ static void TestRegressionUTF8(){
log_err("UTF8->Unicode did not match.\n");
}
}
free(standardForm);
free(utf8);
@ -917,6 +935,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("u-> UTF8 did not match.\n");
}
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_ESCAPE \n");
{
UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
@ -932,6 +951,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
(UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset,FALSE))
log_err("u-> ibm-943 with subst with value did not match.\n");
}
#endif
log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
{
@ -945,7 +965,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("utf8->u with substitute did not match.\n");;
}
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
/*to Unicode*/
{
@ -963,7 +983,7 @@ static void TestWithBufferSize(int32_t insize, int32_t outsize){
log_err("ibm-943->u with substitute with value did not match.\n");
}
#endif
}
static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
@ -1495,6 +1515,7 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *
static void TestResetBehaviour(void){
#if !UCONFIG_NO_LEGACY_CONVERSION
log_verbose("Testing Reset for DBCS and MBCS\n");
{
static const UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4};
@ -1532,6 +1553,7 @@ static void TestResetBehaviour(void){
log_err("ibm-1363 -> did not match.\n");
}
log_verbose("Testing Reset for ISO-2022-jp\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -1562,6 +1584,7 @@ static void TestResetBehaviour(void){
log_err("iso-2022-jp -> did not match.\n");
}
log_verbose("Testing Reset for ISO-2022-cn\n");
{
static const UChar sampleText[] = { 0x4e00, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -1605,6 +1628,7 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("iso-2022-cn -> did not match.\n");
}
log_verbose("Testing Reset for ISO-2022-kr\n");
{
UChar sampleText[] = { 0x4e00,0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -1652,6 +1676,7 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("iso-2022-kr -> did not match.\n");
}
log_verbose("Testing Reset for HZ\n");
{
static const UChar sampleText[] = { 0x4e00, 0xd801, 0xdc01, 0x04e01, 0x0031, 0xd801, 0xdc01, 0x0032};
@ -1695,6 +1720,8 @@ static void TestResetBehaviour(void){
offsets1, TRUE))
log_err("hz -> did not match.\n");
}
#endif
/*UTF-8*/
log_verbose("Testing for UTF8\n");
{
@ -1825,13 +1852,17 @@ TestTruncated() {
{ "UTF-32", { 0, 0, 0x4e }, 3 },
{ "UTF-32", { 0xff }, 1 },
{ "UTF-32", { 0, 0, 0xfe, 0xff, 0 }, 5 },
{ "SCSU", { 0x0e, 0x4e }, 2 }, /* SQU 0x4e */
#if !UCONFIG_NO_LEGACY_CONVERSION
{ "BOCU-1", { 0xd5 }, 1 },
{ "Shift-JIS", { 0xe0 }, 1 },
{ "ibm-939", { 0x0e, 0x41 }, 2 } /* SO 0x41 */
#else
{ "BOCU-1", { 0xd5 }, 1 ,}
#endif
};
int32_t i;
@ -1865,11 +1896,14 @@ TestUnicodeSet() {
"SCSU",
"BOCU-1",
"CESU-8",
#if !UCONFIG_NO_LEGACY_CONVERSION
"gb18030",
#endif
"IMAP-mailbox-name"
};
static const char *const lmbcsNames[]={
#if !UCONFIG_NO_LEGACY_CONVERSION
"LMBCS-1",
"LMBCS-2",
"LMBCS-3",
@ -1882,16 +1916,23 @@ TestUnicodeSet() {
"LMBCS-17",
"LMBCS-18",
"LMBCS-19"
#endif
};
static const NameRange nameRanges[]={
{ "US-ASCII", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
#if !UCONFIG_NO_LEGACY_CONVERSION
{ "ibm-367", 0, 0x7f, -1, -1, 0x80, 0x10ffff },
#endif
{ "ISO-8859-1", 0, 0x7f, -1, -1, 0x100, 0x10ffff },
#if !UCONFIG_NO_LEGACY_CONVERSION
{ "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff },
{ "windows-1251", 0, 0x7f, 0x410, 0x44f, 0x3000, 0xd7ff },
{ "HZ", 0x410, 0x44f, 0x4e00, 0x4eff, 0xac00, 0xd7ff },
{ "shift-jis", 0x3041, 0x3093, 0x30a1, 0x30f3, 0x900, 0x1cff }
#else
{ "UTF-8", 0, 0xd7ff, 0xe000, 0x10ffff, 0xd800, 0xdfff }
#endif
};
/* open an empty set */

View file

@ -44,12 +44,16 @@ static void TestUTF32(void);
static void TestUTF32BE(void);
static void TestUTF32LE(void);
static void TestLATIN1(void);
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestSBCS(void);
static void TestDBCS(void);
static void TestMBCS(void);
#ifdef U_ENABLE_GENERIC_ISO_2022
static void TestISO_2022(void);
#endif
static void TestISO_2022_JP(void);
static void TestISO_2022_JP_1(void);
static void TestISO_2022_JP_2(void);
@ -59,7 +63,11 @@ static void TestISO_2022_CN(void);
static void TestISO_2022_CN_EXT(void);
static void TestJIS(void);
static void TestHZ(void);
#endif
static void TestSCSU(void);
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestEBCDIC_STATEFUL(void);
static void TestGB18030(void);
static void TestLMBCS(void);
@ -67,16 +75,19 @@ static void TestJitterbug255(void);
static void TestEBCDICUS4XML(void);
static void TestJitterbug915(void);
static void TestISCII(void);
static void TestCoverageMBCS(void);
static void TestJitterbug2346(void);
static void TestJitterbug2411(void);
#endif
static void TestRoundTrippingAllUTF(void);
static void TestConv(const uint16_t in[],
int len,
const char* conv,
const char* lang,
char byteArr[],
int byteArrLen);
static void TestRoundTrippingAllUTF(void);
static void TestCoverageMBCS(void);
static void TestJitterbug2346(void);
static void TestJitterbug2411(void);
void addTestNewConvert(TestNode** root);
/* open a converter, using test data if it begins with '@' */
@ -229,15 +240,22 @@ void addTestNewConvert(TestNode** root)
addTest(root, &TestUTF32, "tsconv/nucnvtst/TestUTF32");
addTest(root, &TestUTF32BE, "tsconv/nucnvtst/TestUTF32BE");
addTest(root, &TestUTF32LE, "tsconv/nucnvtst/TestUTF32LE");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestLMBCS, "tsconv/nucnvtst/TestLMBCS");
#endif
addTest(root, &TestLATIN1, "tsconv/nucnvtst/TestLATIN1");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestSBCS, "tsconv/nucnvtst/TestSBCS");
addTest(root, &TestDBCS, "tsconv/nucnvtst/TestDBCS");
addTest(root, &TestMBCS, "tsconv/nucnvtst/TestMBCS");
#ifdef U_ENABLE_GENERIC_ISO_2022
addTest(root, &TestISO_2022, "tsconv/nucnvtst/TestISO_2022");
#endif
addTest(root, &TestISO_2022_JP, "tsconv/nucnvtst/TestISO_2022_JP");
addTest(root, &TestJIS, "tsconv/nucnvtst/TestJIS");
addTest(root, &TestISO_2022_JP_1, "tsconv/nucnvtst/TestISO_2022_JP_1");
@ -248,20 +266,35 @@ void addTestNewConvert(TestNode** root)
addTest(root, &TestISO_2022_CN_EXT, "tsconv/nucnvtst/TestISO_2022_CN_EXT");
addTest(root, &TestJitterbug915, "tsconv/nucnvtst/TestJitterbug915");
addTest(root, &TestHZ, "tsconv/nucnvtst/TestHZ");
#endif
addTest(root, &TestSCSU, "tsconv/nucnvtst/TestSCSU");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestEBCDIC_STATEFUL, "tsconv/nucnvtst/TestEBCDIC_STATEFUL");
addTest(root, &TestGB18030, "tsconv/nucnvtst/TestGB18030");
addTest(root, &TestJitterbug255, "tsconv/nucnvtst/TestJitterbug255");
addTest(root, &TestEBCDICUS4XML, "tsconv/nucnvtst/TestEBCDICUS4XML");
addTest(root, &TestISCII, "tsconv/nucnvtst/TestISCII");
#if !UCONFIG_NO_COLLATION
addTest(root, &TestJitterbug981, "tsconv/nucnvtst/TestJitterbug981");
#endif
addTest(root, &TestJitterbug1293, "tsconv/nucnvtst/TestJitterbug1293");
#endif
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestCoverageMBCS, "tsconv/nucnvtst/TestCoverageMBCS");
#endif
addTest(root, &TestRoundTrippingAllUTF, "tsconv/nucnvtst/TestRoundTrippingAllUTF");
#if !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestJitterbug2346, "tsconv/nucnvtst/TestJitterbug2346");
addTest(root, &TestJitterbug2411, "tsconv/nucnvtst/TestJitterbug2411");
#endif
}
@ -775,11 +808,13 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
}
#ifdef U_ENABLE_GENERIC_ISO_2022
#if !UCONFIG_NO_LEGACY_CONVERSION && defined(U_ENABLE_GENERIC_ISO_2022)
/*ISO-2022*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedISO2022, sizeof(expectedISO2022), "ISO_2022", toISO2022Offs,FALSE );
#endif
/*UTF16 LE*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedUTF16LE, sizeof(expectedUTF16LE), "utf-16le", toUTF16LEOffs,FALSE );
@ -792,9 +827,12 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF32 BE*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedUTF32BE, sizeof(expectedUTF32BE), "utf-32be", toUTF32BEOffs,FALSE );
/*LATIN_1*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedLATIN1, sizeof(expectedLATIN1), "LATIN_1", toLATIN1Offs,FALSE );
#if !UCONFIG_NO_LEGACY_CONVERSION
/*EBCDIC_STATEFUL*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedIBM930, sizeof(expectedIBM930), "ibm-930", toIBM930Offs,FALSE );
@ -815,6 +853,7 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*SBCS*/
testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
expectedISO88593, sizeof(expectedISO88593), "iso-8859-3", toISO88593Offs,FALSE );
#endif
/****/
@ -822,11 +861,12 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF-8*/
testConvertToU(expectedUTF8, sizeof(expectedUTF8),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf8", fmUTF8Offs,FALSE);
#ifdef U_ENABLE_GENERIC_ISO_2022
#if !UCONFIG_NO_LEGACY_CONVERSION && defined(U_ENABLE_GENERIC_ISO_2022)
/*ISO-2022*/
testConvertToU(expectedISO2022, sizeof(expectedISO2022),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ISO_2022", fmISO2022Offs,FALSE);
#endif
/*UTF16 LE*/
testConvertToU(expectedUTF16LE, sizeof(expectedUTF16LE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-16le", fmUTF16LEOffs,FALSE);
@ -839,17 +879,21 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
/*UTF32 BE*/
testConvertToU(expectedUTF32BE, sizeof(expectedUTF32BE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-32be", fmUTF32BEOffs,FALSE);
#if !UCONFIG_NO_LEGACY_CONVERSION
/*EBCDIC_STATEFUL*/
testConvertToU(expectedIBM930, sizeof(expectedIBM930),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ibm-930", fmIBM930Offs,FALSE);
/*MBCS*/
testConvertToU(expectedIBM943, sizeof(expectedIBM943),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "ibm-943", fmIBM943Offs,FALSE);
#endif
/* Try it again to make sure it still works */
testConvertToU(expectedUTF16LE, sizeof(expectedUTF16LE),
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "utf-16le", fmUTF16LEOffs,FALSE);
#if !UCONFIG_NO_LEGACY_CONVERSION
testConvertToU(expectedMaltese913, sizeof(expectedMaltese913),
malteseUChars, sizeof(malteseUChars)/sizeof(malteseUChars[0]), "latin3", NULL,FALSE);
@ -861,6 +905,7 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize )
expectedLMBCS, sizeof(expectedLMBCS), "LMBCS-1", toLMBCSOffs,FALSE );
testConvertToU(expectedLMBCS, sizeof(expectedLMBCS),
LMBCSUChars, sizeof(LMBCSUChars)/sizeof(LMBCSUChars[0]), "LMBCS-1", fmLMBCSOffs,FALSE);
#endif
/* UTF-7 examples are mostly from http://www.imc.org/rfc2152 */
{
@ -1274,6 +1319,7 @@ static void TestConverterType(const char *convName, UConverterType convType) {
static void TestConverterTypesAndStarters()
{
#if !UCONFIG_NO_LEGACY_CONVERSION
UConverter* myConverter;
UErrorCode err = U_ZERO_ERROR;
UBool mystarters[256];
@ -1334,19 +1380,33 @@ static void TestConverterTypesAndStarters()
TestConverterType("ibm-930", UCNV_EBCDIC_STATEFUL);
TestConverterType("ibm-878", UCNV_SBCS);
#endif
TestConverterType("iso-8859-1", UCNV_LATIN_1);
TestConverterType("ibm-1208", UCNV_UTF8);
TestConverterType("utf-8", UCNV_UTF8);
TestConverterType("UTF-16BE", UCNV_UTF16_BigEndian);
TestConverterType("UTF-16LE", UCNV_UTF16_LittleEndian);
TestConverterType("UTF-32BE", UCNV_UTF32_BigEndian);
TestConverterType("UTF-32LE", UCNV_UTF32_LittleEndian);
#ifdef U_ENABLE_GENERIC_ISO_2022
#if !UCONFIG_NO_LEGACY_CONVERSION
#if defined(U_ENABLE_GENERIC_ISO_2022)
TestConverterType("iso-2022", UCNV_ISO_2022);
#endif
TestConverterType("hz", UCNV_HZ);
#endif
TestConverterType("scsu", UCNV_SCSU);
#if !UCONFIG_NO_LEGACY_CONVERSION
TestConverterType("x-iscii-de", UCNV_ISCII);
#endif
TestConverterType("ascii", UCNV_US_ASCII);
TestConverterType("utf-7", UCNV_UTF7);
TestConverterType("IMAP-mailbox-name", UCNV_IMAP_MAILBOX);
@ -1428,6 +1488,7 @@ static void TestAmbiguous()
}
}
#if !UCONFIG_NO_LEGACY_CONVERSION
sjis_cnv = ucnv_open("ibm-943", &status);
if (U_FAILURE(status))
{
@ -1480,6 +1541,7 @@ static void TestAmbiguous()
}
ucnv_close(sjis_cnv);
ucnv_close(ascii_cnv);
#endif
}
static void
@ -3607,6 +3669,8 @@ TestSCSU() {
TestConv(russianUTF16,(sizeof(russianUTF16)/2), "SCSU","russian",(char *)russianSCSU,sizeof(russianSCSU));
TestConv(monkeyIn,(sizeof(monkeyIn)/2),"SCSU","monkey",NULL,0);
}
#if !UCONFIG_NO_LEGACY_CONVERSION
static void TestJitterbug2346(){
char source[] = { 0x1b,0x24,0x42,0x3d,0x45,0x1b,0x28,0x4a,0x0d,0x0a,
0x1b,0x24,0x42,0x3d,0x45,0x1b,0x28,0x4a,0x0d,0x0a};
@ -3654,6 +3718,7 @@ static void TestJitterbug2346(){
}
static void
TestISO_2022_JP_1() {
/* test input */
@ -5133,6 +5198,7 @@ static void TestEBCDICUS4XML()
}
ucnv_close(cnv);
}
#endif /* #if !UCONFIG_NO_LEGACY_COLLATION */
#if !UCONFIG_NO_COLLATION

View file

@ -213,6 +213,7 @@ bail:
static void TestC1Bytes(void)
{
#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
const char *ssISO = "This is a small sample of some English text. Just enough to be sure that it detects correctly.";
const char *ssWindows = "This is another small sample of some English text. Just enough to be sure that it detects correctly. It also includes some \\u201CC1\\u201D bytes.";
@ -259,6 +260,7 @@ bail:
freeBytes(bISO);
ucsdet_close(csd);
#endif
}
static void TestInputFilter(void)

View file

@ -1594,12 +1594,14 @@ TestSwapData() {
errorCode=U_ZERO_ERROR;
/* Test argument checking. ucol_swapBinary is normally tested via ures_swap, and isn't normally called directly. */
#if !UCONFIG_NO_COLLATION
ucol_swapBinary(NULL, NULL, -1, NULL, NULL);
ucol_swapBinary(NULL, NULL, -1, NULL, &errorCode);
if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
log_err("ucol_swapBinary did not fail as expected\n", name);
}
errorCode=U_ZERO_ERROR;
#endif
for(i=0; i<LENGTHOF(swapCases); ++i) {
/* build the name for logging */

View file

@ -53,6 +53,7 @@ void LocaleAliasTest::runIndexedTest( int32_t index, UBool exec, const char* &na
}
void LocaleAliasTest::TestCalendar() {
#if !UCONFIG_NO_FORMATTING
UErrorCode status = U_ZERO_ERROR;
for (int i=0; i<_LOCALE_NUMBER; i++) {
Locale oldLoc(_LOCALE_ALIAS[i][0]);
@ -81,8 +82,10 @@ void LocaleAliasTest::TestCalendar() {
delete c1;
delete c2;
}
#endif
}
void LocaleAliasTest::TestDateFormat() {
#if !UCONFIG_NO_FORMATTING
UErrorCode status = U_ZERO_ERROR;
for (int i=0; i<_LOCALE_NUMBER; i++) {
Locale oldLoc(_LOCALE_ALIAS[i][0]);
@ -113,8 +116,10 @@ void LocaleAliasTest::TestDateFormat() {
delete df1;
delete df2;
}
#endif
}
void LocaleAliasTest::TestCollation() {
#if !UCONFIG_NO_COLLATION
UErrorCode status = U_ZERO_ERROR;
for (int i=0; i<_LOCALE_NUMBER; i++) {
Locale oldLoc(_LOCALE_ALIAS[i][0]);
@ -144,6 +149,7 @@ void LocaleAliasTest::TestCollation() {
delete c1;
delete c2;
}
#endif
}
void LocaleAliasTest::TestULocale() {
for (int i=0; i<_LOCALE_NUMBER; i++) {

View file

@ -109,12 +109,15 @@ static UnicodeString *split(const UnicodeString &src, UChar ch, int32_t &splits)
static char *extractBytes(const UnicodeString &source, const char *codepage, int32_t &length)
{
int32_t sLength = source.length();
char *bytes;
char *bytes = NULL;
length = source.extract(0, sLength, NULL, codepage);
bytes = NEW_ARRAY(char, length + 1);
source.extract(0, sLength, bytes, codepage);
if (length > 0) {
bytes = NEW_ARRAY(char, length + 1);
source.extract(0, sLength, bytes, codepage);
}
return bytes;
}
@ -140,6 +143,13 @@ void CharsetDetectionTest::checkEncoding(const UnicodeString &testString, const
int32_t byteLength = 0;
char *bytes = extractBytes(testString, codepage, byteLength);
if (bytes == NULL) {
#if !UCONFIG_NO_LEGACY_CONVERSION
errln("Can't open a " + encoding + " converter for " + id);
#endif
return;
}
ucsdet_setText(csd, bytes, byteLength, &status);
int32_t matchCount = 0;
@ -411,6 +421,7 @@ bail:
void CharsetDetectionTest::C1BytesTest()
{
#if !UCONFIG_NO_LEGACY_CONVERSION
UErrorCode status = U_ZERO_ERROR;
UnicodeString sISO = "This is a small sample of some English text. Just enough to be sure that it detects correctly.";
UnicodeString ssWindows = "This is another small sample of some English text. Just enough to be sure that it detects correctly. It also includes some \\u201CC1\\u201D bytes.";
@ -455,10 +466,12 @@ bail:
freeBytes(bISO);
ucsdet_close(csd);
#endif
}
void CharsetDetectionTest::DetectionTest()
{
#if !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_CONVERSION
UErrorCode status = U_ZERO_ERROR;
char path[2048];
const char *testFilePath = getPath(path, "csdetest.xml");
@ -497,6 +510,7 @@ void CharsetDetectionTest::DetectionTest()
delete root;
delete parser;
#endif
}

View file

@ -52,7 +52,7 @@ IdnaConfTest::~IdnaConfTest(){
delete [] base;
}
#if !UCONFIG_NO_IDNA
/* this function is modified from RBBITest::ReadAndConvertFile()
*
*/
@ -335,8 +335,12 @@ void IdnaConfTest::Test(void){
Call(); // for last record
}
#else
void IdnaConfTest::Test(void)
{
// test nothing...
}
#endif
void IdnaConfTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/){
switch (index) {

View file

@ -1370,6 +1370,7 @@ void RBBITest::executeTest(TestParams *t) {
void RBBITest::TestExtended() {
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
UErrorCode status = U_ZERO_ERROR;
Locale locale("");
@ -1720,6 +1721,7 @@ end_test:
delete tp.srcLine;
delete tp.srcCol;
delete [] testFile;
#endif
}
@ -3744,6 +3746,7 @@ void RBBITest::TestLineBreaks(void)
void RBBITest::TestSentBreaks(void)
{
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
Locale locale("en");
UErrorCode status = U_ZERO_ERROR;
BreakIterator *bi = BreakIterator::createSentenceInstance(locale, status);
@ -3802,6 +3805,7 @@ void RBBITest::TestSentBreaks(void)
testBreakBoundPreceding(this, ustr, bi, expected, expectedcount);
}
delete bi;
#endif
}
void RBBITest::TestMonkey(char *params) {

View file

@ -23,6 +23,18 @@ CLEANFILES = *~ $(DEPS)
TESTTARGET = letest
GENTARGET = gendata
BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
# Simplify the path for Unix
BUILDDIR := $(BUILDDIR:test/cintltst/../../=)
# Simplify the path for Windows
BUILDDIR := $(BUILDDIR:test\\cintltst/../../=)
# Simplify the path for Windows 98
BUILDDIR := $(BUILDDIR:TEST\\CINTLTST/../../=)
ifneq ($(top_builddir),$(top_srcdir))
CPPFLAGS += -I$(top_builddir)/common
endif
CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/layout -I$(top_srcdir)
DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
LIBS = $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) $(LIBCTESTFW) $(LIBICUTOOLUTIL) @LIBS@ @LIB_M@

View file

@ -537,6 +537,7 @@ LEFontInstance *openFont(const char *fontName, const char *checksum, const char
U_CDECL_BEGIN
static void U_CALLCONV DataDrivenTest(void)
{
#if !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_CONVERSION
UErrorCode status = U_ZERO_ERROR;
char path[2048];
const char *testFilePath = getPath(path, "letest.xml");
@ -702,6 +703,7 @@ free_c_strings:
delete root;
delete parser;
#endif
}
U_CDECL_END

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2003-2004, International Business Machines
* Copyright (C) 2003-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -29,6 +29,8 @@
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
#if !UCONFIG_NO_CONVERSION
static void
CnvExtClose(NewConverter *cnvData);
@ -1057,3 +1059,5 @@ CnvExtAddTable(NewConverter *cnvData, UCMTable *table, UConverterStaticData *sta
makeToUTable(extData, table) &&
makeFromUTable(extData, table);
}
#endif /* UCONFIG_NO_CONVERSION */

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2000-2004, International Business Machines
* Copyright (C) 2000-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -25,6 +25,8 @@
#include "makeconv.h"
#include "genmbcs.h"
#if !UCONFIG_NO_CONVERSION
typedef struct MBCSData {
NewConverter newConverter;
@ -1098,3 +1100,5 @@ MBCSWrite(NewConverter *cnvData, const UConverterStaticData *staticData,
/* return the number of bytes that should have been written */
return header.offsetFromUBytes+header.fromUBytesLength;
}
#endif /* UCONFIG_NO_CONVERSION */

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2000-2003, International Business Machines
* Copyright (C) 2000-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -19,6 +19,8 @@
#include "makeconv.h"
#if !UCONFIG_NO_CONVERSION
enum {
MBCS_STAGE_2_BLOCK_SIZE=0x40, /* 64; 64=1<<6 for 6 bits in stage 2 */
MBCS_STAGE_2_BLOCK_SIZE_SHIFT=6, /* log2(MBCS_STAGE_2_BLOCK_SIZE) */
@ -42,4 +44,6 @@ MBCSOpen(UCMFile *ucm);
U_CFUNC NewConverter *
CnvExtOpen(UCMFile *ucm);
#endif
#endif /* UCONFIG_NO_CONVERSION */
#endif /* __GENMBCS_H__ */

View file

@ -36,6 +36,8 @@
#define DEBUG 0
#if !UCONFIG_NO_CONVERSION
typedef struct ConvData {
UCMFile *ucm;
NewConverter *cnvData, *extData;
@ -738,6 +740,13 @@ createConverter(ConvData *data, const char *converterName, UErrorCode *pErrorCod
cleanupConvData(&baseData);
}
}
#else
int main(int argc, char *argv[])
{
printf("Your version of ICU was built without conversion,\n");
printf("so this tool has no functionality.\n");
}
#endif
/*
* Hey, Emacs, please set the following:

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2000-2003, International Business Machines
* Copyright (C) 2000-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -22,6 +22,7 @@
#include "unewdata.h"
#include "ucm.h"
#if !UCONFIG_NO_CONVERSION
/* exports from makeconv.c */
U_CFUNC UBool VERBOSE;
@ -53,5 +54,6 @@ struct NewConverter {
(*write)(NewConverter *cnvData, const UConverterStaticData *staticData,
UNewDataMemory *pData, int32_t tableType);
};
#endif /* UCONFIG_NO_CONVERSION */
#endif
#endif /* __MAKECONV_H__ */

View file

@ -1,7 +1,7 @@
/*
******************************************************************************
*
* Copyright (C) 1998-2001, International Business Machines
* Copyright (C) 1998-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@ -15,6 +15,7 @@
#include "unicode/ucnv.h"
#include "ucnv_bld.h"
#if !UCONFIG_NO_CONVERSION
static const UConverterStaticData _SBCSStaticData={
sizeof(UConverterStaticData),
@ -64,3 +65,5 @@ const UConverterStaticData *ucnv_converterStaticData[UCNV_NUMBER_OF_SUPPORTED_CO
NULL/*ISO2022*/,
/* LMBCS */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
#endif /* UCONFIG_NO_CONVERSION */