ICU-1718 Fix for Windows.

X-SVN-Rev: 8436
This commit is contained in:
George Rhoten 2002-04-11 00:10:51 +00:00
parent 4f6f62fbc7
commit d26acd0c32
2 changed files with 146 additions and 146 deletions

View File

@ -1022,8 +1022,8 @@ static void TestStringCompatibility() {
}
for (num = 0; num < 0x80; num++) {
testBuf[0] = 0xFF;
uStringBuf[0] = 0xfffe;
testBuf[0] = (char)0xFF;
uStringBuf[0] = (UChar)0xfffe;
sprintf(testBuf, "%c", num);
u_sprintf(uStringBuf, NULL, "%c", num);
u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
@ -1099,152 +1099,152 @@ static void TestStream() {
static void TestTranslitOps()
{
UFILE *f;
UErrorCode err = U_ZERO_ERROR;
UTransliterator *a = NULL, *b = NULL, *c = NULL;
log_verbose("opening a transliterator and UFILE for testing\n");
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
if(f == NULL)
{
log_err("Couldn't open test file for writing");
return;
}
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err opening transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
log_verbose("setting a transliterator\n");
b = u_fsettransliterator(f, U_WRITE, a, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(b != NULL)
{
log_err("Err, a transliterator was already set!\n");
}
log_verbose("un-setting transliterator (setting to null)\n");
c = u_fsettransliterator(f, U_WRITE, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(c != a)
{
log_err("Err, transliterator that came back was not the original one.\n");
}
log_verbose("Trying to set read transliterator (should fail)\n");
b = u_fsettransliterator(f, U_READ, NULL, &err);
if(err != U_UNSUPPORTED_ERROR)
{
log_err("Should have U_UNSUPPORTED_ERROR setting Read transliterator but got %s - REVISIT AND UPDATE TEST\n", u_errorName(err));
u_fclose(f);
return;
}
else
{
log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
err = U_ZERO_ERROR;
}
utrans_close(c);
u_fclose(f);
UFILE *f;
UErrorCode err = U_ZERO_ERROR;
UTransliterator *a = NULL, *b = NULL, *c = NULL;
log_verbose("opening a transliterator and UFILE for testing\n");
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
if(f == NULL)
{
log_err("Couldn't open test file for writing");
return;
}
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err opening transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
log_verbose("setting a transliterator\n");
b = u_fsettransliterator(f, U_WRITE, a, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(b != NULL)
{
log_err("Err, a transliterator was already set!\n");
}
log_verbose("un-setting transliterator (setting to null)\n");
c = u_fsettransliterator(f, U_WRITE, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(c != a)
{
log_err("Err, transliterator that came back was not the original one.\n");
}
log_verbose("Trying to set read transliterator (should fail)\n");
b = u_fsettransliterator(f, U_READ, NULL, &err);
if(err != U_UNSUPPORTED_ERROR)
{
log_err("Should have U_UNSUPPORTED_ERROR setting Read transliterator but got %s - REVISIT AND UPDATE TEST\n", u_errorName(err));
u_fclose(f);
return;
}
else
{
log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
err = U_ZERO_ERROR;
}
utrans_close(c);
u_fclose(f);
}
static void TestTranslitOut()
{
UFILE *f;
UErrorCode err = U_ZERO_ERROR;
UTransliterator *a = NULL, *b = NULL, *c = NULL;
FILE *infile;
UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x0000 };
UChar ubuf[256];
int len;
log_verbose("opening a transliterator and UFILE for testing\n");
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
if(f == NULL)
{
log_err("Couldn't open test file for writing");
return;
}
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err opening transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
log_verbose("setting a transliterator\n");
b = u_fsettransliterator(f, U_WRITE, a, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(b != NULL)
{
log_err("Err, a transliterator was already set!\n");
}
u_fprintf(f, "%KStephanos", 0xFEFF);
u_fclose(f);
log_verbose("Re reading test file to verify transliteration\n");
infile = fopen(STANDARD_TEST_FILE, "rb");
if(infile == NULL)
{
log_err("Couldn't reopen test file\n");
return;
}
len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
log_verbose("Read %d UChars\n", len);
if(len != u_strlen(compare))
{
log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
}
ubuf[len]=0;
if(u_strlen(compare) != u_strlen(ubuf))
{
log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
}
if(u_strcmp(compare, ubuf))
{
log_err("Read string doesn't match expected.\n");
}
else
{
log_verbose("Read string matches expected.\n");
}
fclose(infile);
UFILE *f;
UErrorCode err = U_ZERO_ERROR;
UTransliterator *a = NULL, *b = NULL, *c = NULL;
FILE *infile;
UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x0000 };
UChar ubuf[256];
int len;
log_verbose("opening a transliterator and UFILE for testing\n");
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
if(f == NULL)
{
log_err("Couldn't open test file for writing");
return;
}
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
if(U_FAILURE(err))
{
log_err("Err opening transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
log_verbose("setting a transliterator\n");
b = u_fsettransliterator(f, U_WRITE, a, &err);
if(U_FAILURE(err))
{
log_err("Err setting transliterator %s\n", u_errorName(err));
u_fclose(f);
return;
}
if(b != NULL)
{
log_err("Err, a transliterator was already set!\n");
}
u_fprintf(f, "%KStephanos", 0xFEFF);
u_fclose(f);
log_verbose("Re reading test file to verify transliteration\n");
infile = fopen(STANDARD_TEST_FILE, "rb");
if(infile == NULL)
{
log_err("Couldn't reopen test file\n");
return;
}
len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
log_verbose("Read %d UChars\n", len);
if(len != u_strlen(compare))
{
log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
}
ubuf[len]=0;
if(u_strlen(compare) != u_strlen(ubuf))
{
log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
}
if(u_strcmp(compare, ubuf))
{
log_err("Read string doesn't match expected.\n");
}
else
{
log_verbose("Read string matches expected.\n");
}
fclose(infile);
}
static void addAllTests(TestNode** root) {

View File

@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib icuio.lib icuuc.lib ctestfw.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\lib"
# ADD LINK32 kernel32.lib icuio.lib icuin.lib icuuc.lib ctestfw.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\lib"
!ELSEIF "$(CFG)" == "iotest - Win32 Debug"
@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib icuiod.lib icuucd.lib ctestfwd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\lib"
# ADD LINK32 kernel32.lib icuiod.lib icuind.lib icuucd.lib ctestfwd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\lib"
!ENDIF