ICU-3546 TestFlushCache doesn't need internal API for testing anymore,
but TestDefaultConverterError does need internal API for testing. X-SVN-Rev: 15317
This commit is contained in:
parent
0795f3cafe
commit
7a91fe3d9a
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2003, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
@ -94,7 +94,7 @@ cnv_open(const char *name, UErrorCode *pErrorCode) {
|
||||
|
||||
|
||||
static void ListNames(void);
|
||||
void TestFlushCache(void); /* defined in cctest.c */
|
||||
static void TestFlushCache(void);
|
||||
static void TestDuplicateAlias(void);
|
||||
static void TestCCSID(void);
|
||||
static void TestJ932(void);
|
||||
@ -104,6 +104,7 @@ static void TestConvertSafeCloneCallback(void);
|
||||
static void TestEBCDICSwapLFNL(void);
|
||||
static void TestConvertEx(void);
|
||||
static void TestConvertAlgorithmic(void);
|
||||
void TestDefaultConverterError(void); /* defined in cctest.c */
|
||||
|
||||
void addTestConvert(TestNode** root);
|
||||
|
||||
@ -123,6 +124,7 @@ void addTestConvert(TestNode** root)
|
||||
addTest(root, &TestEBCDICSwapLFNL, "tsconv/ccapitst/TestEBCDICSwapLFNL");
|
||||
addTest(root, &TestConvertEx, "tsconv/ccapitst/TestConvertEx");
|
||||
addTest(root, &TestConvertAlgorithmic, "tsconv/ccapitst/TestConvertAlgorithmic");
|
||||
addTest(root, &TestDefaultConverterError, "tsconv/ccapitst/TestDefaultConverterError");
|
||||
}
|
||||
|
||||
static void ListNames(void) {
|
||||
@ -1059,6 +1061,79 @@ static UConverterToUCallback otherCharAction(UConverterToUCallback MIA)
|
||||
return (MIA==(UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP)?(UConverterToUCallback)UCNV_TO_U_CALLBACK_SUBSTITUTE:(UConverterToUCallback)UCNV_TO_U_CALLBACK_STOP;
|
||||
}
|
||||
|
||||
static void TestFlushCache(void) {
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
UConverter* someConverters[5];
|
||||
int flushCount = 0;
|
||||
|
||||
/* flush the converter cache to get a consistent state before the flushing is tested */
|
||||
ucnv_flushCache();
|
||||
|
||||
/*Testing ucnv_open()*/
|
||||
/* Note: These converters have been chosen because they do NOT
|
||||
encode the Latin characters (U+0041, ...), and therefore are
|
||||
highly unlikely to be chosen as system default codepages */
|
||||
|
||||
someConverters[0] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[1] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[2] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[3] = ucnv_open("gb18030", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[4] = ucnv_open("ibm-954", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
|
||||
/* Testing ucnv_flushCache() */
|
||||
log_verbose("\n---Testing ucnv_flushCache...\n");
|
||||
if ((flushCount=ucnv_flushCache())==0)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed [line %d], expect 0 got %d \n", __LINE__, flushCount);
|
||||
|
||||
/*testing ucnv_close() and ucnv_flushCache() */
|
||||
ucnv_close(someConverters[0]);
|
||||
ucnv_close(someConverters[1]);
|
||||
|
||||
if ((flushCount=ucnv_flushCache())==0)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed [line %d], expect 0 got %d \n", __LINE__, flushCount);
|
||||
|
||||
ucnv_close(someConverters[2]);
|
||||
ucnv_close(someConverters[3]);
|
||||
|
||||
if ((flushCount=ucnv_flushCache())==2)
|
||||
log_verbose("Flush cache ok\n"); /*because first, second and third are same */
|
||||
else
|
||||
log_data_err("Flush Cache failed line %d, got %d expected 2 or there is an error in ucnv_close()\n",
|
||||
__LINE__,
|
||||
flushCount);
|
||||
|
||||
ucnv_close(someConverters[4]);
|
||||
if ( (flushCount=ucnv_flushCache())==1)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed line %d, expected 1 got %d \n", __LINE__, flushCount);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the converter alias API, specifically the fuzzy matching of
|
||||
* alias names and the alias table integrity. Make sure each
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2003, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
@ -9,80 +9,27 @@
|
||||
|
||||
#include "cintltst.h"
|
||||
#include "ustr_imp.h"
|
||||
void TestFlushCache(void); /* keep gcc happy */
|
||||
void TestDefaultConverterError(void); /* keep gcc happy */
|
||||
|
||||
|
||||
void TestFlushCache(void) {
|
||||
/* This makes sure that a converter isn't leaked when an error is passed to
|
||||
u_getDefaultConverter */
|
||||
void TestDefaultConverterError(void) {
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
UConverter* someConverters[5];
|
||||
int flushCount = 0;
|
||||
|
||||
/* flush the converter cache to get a consistent state before the flushing is tested */
|
||||
ucnv_flushCache();
|
||||
/* Remove the default converter */
|
||||
ucnv_close(u_getDefaultConverter(&err));
|
||||
|
||||
/*Testing ucnv_open()*/
|
||||
/* Note: These converters have been chosen because they do NOT
|
||||
encode the Latin characters (U+0041, ...), and therefore are
|
||||
highly unlikely to be chosen as system default codepages */
|
||||
|
||||
someConverters[0] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
log_err("Didn't expect a failure yet %s\n", myErrorName(err));
|
||||
return;
|
||||
}
|
||||
|
||||
someConverters[1] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
/* Set to any radom error state */
|
||||
err = U_FILE_ACCESS_ERROR;
|
||||
if (u_getDefaultConverter(&err) != NULL) {
|
||||
log_err("Didn't expect to get a converter on a failure\n");
|
||||
}
|
||||
|
||||
someConverters[2] = ucnv_open("ibm-1047", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[3] = ucnv_open("gb18030", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
someConverters[4] = ucnv_open("ibm-954", &err);
|
||||
if (U_FAILURE(err)) {
|
||||
log_data_err("FAILURE! %s\n", myErrorName(err));
|
||||
}
|
||||
|
||||
|
||||
/* Testing ucnv_flushCache() */
|
||||
log_verbose("\n---Testing ucnv_flushCache...\n");
|
||||
if ((flushCount=ucnv_flushCache())==0)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed [line %d], expect 0 got %d \n", __LINE__, flushCount);
|
||||
|
||||
/*testing ucnv_close() and ucnv_flushCache() */
|
||||
ucnv_close(someConverters[0]);
|
||||
ucnv_close(someConverters[1]);
|
||||
|
||||
if ((flushCount=ucnv_flushCache())==0)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed [line %d], expect 0 got %d \n", __LINE__, flushCount);
|
||||
|
||||
ucnv_close(someConverters[2]);
|
||||
ucnv_close(someConverters[3]);
|
||||
|
||||
if ((flushCount=ucnv_flushCache())==2)
|
||||
log_verbose("Flush cache ok\n"); /*because first, second and third are same */
|
||||
else
|
||||
log_data_err("Flush Cache failed line %d, got %d expected 2 or there is an error in ucnv_close()\n",
|
||||
__LINE__,
|
||||
flushCount);
|
||||
|
||||
ucnv_close(someConverters[4]);
|
||||
if ( (flushCount=ucnv_flushCache())==1)
|
||||
log_verbose("Flush cache ok\n");
|
||||
else
|
||||
log_data_err("Flush Cache failed line %d, expected 1 got %d \n", __LINE__, flushCount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user