ICU-1718 Fix for Windows.
X-SVN-Rev: 8436
This commit is contained in:
parent
4f6f62fbc7
commit
d26acd0c32
@ -1022,8 +1022,8 @@ static void TestStringCompatibility() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (num = 0; num < 0x80; num++) {
|
for (num = 0; num < 0x80; num++) {
|
||||||
testBuf[0] = 0xFF;
|
testBuf[0] = (char)0xFF;
|
||||||
uStringBuf[0] = 0xfffe;
|
uStringBuf[0] = (UChar)0xfffe;
|
||||||
sprintf(testBuf, "%c", num);
|
sprintf(testBuf, "%c", num);
|
||||||
u_sprintf(uStringBuf, NULL, "%c", num);
|
u_sprintf(uStringBuf, NULL, "%c", num);
|
||||||
u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
|
u_austrncpy(myString, uStringBuf, sizeof(myString)/sizeof(myString[0]));
|
||||||
@ -1099,152 +1099,152 @@ static void TestStream() {
|
|||||||
|
|
||||||
static void TestTranslitOps()
|
static void TestTranslitOps()
|
||||||
{
|
{
|
||||||
UFILE *f;
|
UFILE *f;
|
||||||
UErrorCode err = U_ZERO_ERROR;
|
UErrorCode err = U_ZERO_ERROR;
|
||||||
UTransliterator *a = NULL, *b = NULL, *c = NULL;
|
UTransliterator *a = NULL, *b = NULL, *c = NULL;
|
||||||
|
|
||||||
log_verbose("opening a transliterator and UFILE for testing\n");
|
log_verbose("opening a transliterator and UFILE for testing\n");
|
||||||
|
|
||||||
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
|
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", NULL);
|
||||||
if(f == NULL)
|
if(f == NULL)
|
||||||
{
|
{
|
||||||
log_err("Couldn't open test file for writing");
|
log_err("Couldn't open test file for writing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
|
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
|
||||||
if(U_FAILURE(err))
|
if(U_FAILURE(err))
|
||||||
{
|
{
|
||||||
log_err("Err opening transliterator %s\n", u_errorName(err));
|
log_err("Err opening transliterator %s\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_verbose("setting a transliterator\n");
|
log_verbose("setting a transliterator\n");
|
||||||
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
||||||
if(U_FAILURE(err))
|
if(U_FAILURE(err))
|
||||||
{
|
{
|
||||||
log_err("Err setting transliterator %s\n", u_errorName(err));
|
log_err("Err setting transliterator %s\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b != NULL)
|
if(b != NULL)
|
||||||
{
|
{
|
||||||
log_err("Err, a transliterator was already set!\n");
|
log_err("Err, a transliterator was already set!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("un-setting transliterator (setting to null)\n");
|
log_verbose("un-setting transliterator (setting to null)\n");
|
||||||
c = u_fsettransliterator(f, U_WRITE, NULL, &err);
|
c = u_fsettransliterator(f, U_WRITE, NULL, &err);
|
||||||
if(U_FAILURE(err))
|
if(U_FAILURE(err))
|
||||||
{
|
{
|
||||||
log_err("Err setting transliterator %s\n", u_errorName(err));
|
log_err("Err setting transliterator %s\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c != a)
|
if(c != a)
|
||||||
{
|
{
|
||||||
log_err("Err, transliterator that came back was not the original one.\n");
|
log_err("Err, transliterator that came back was not the original one.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Trying to set read transliterator (should fail)\n");
|
log_verbose("Trying to set read transliterator (should fail)\n");
|
||||||
b = u_fsettransliterator(f, U_READ, NULL, &err);
|
b = u_fsettransliterator(f, U_READ, NULL, &err);
|
||||||
if(err != U_UNSUPPORTED_ERROR)
|
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));
|
log_err("Should have U_UNSUPPORTED_ERROR setting Read transliterator but got %s - REVISIT AND UPDATE TEST\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
|
log_verbose("Got %s error (expected) setting READ transliterator.\n", u_errorName(err));
|
||||||
err = U_ZERO_ERROR;
|
err = U_ZERO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
utrans_close(c);
|
utrans_close(c);
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TestTranslitOut()
|
static void TestTranslitOut()
|
||||||
{
|
{
|
||||||
UFILE *f;
|
UFILE *f;
|
||||||
UErrorCode err = U_ZERO_ERROR;
|
UErrorCode err = U_ZERO_ERROR;
|
||||||
UTransliterator *a = NULL, *b = NULL, *c = NULL;
|
UTransliterator *a = NULL, *b = NULL, *c = NULL;
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x0000 };
|
UChar compare[] = { 0xfeff, 0x03a3, 0x03c4, 0x03b5, 0x03c6, 0x1f00, 0x03bd, 0x03bf, 0x03c2, 0x0000 };
|
||||||
UChar ubuf[256];
|
UChar ubuf[256];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
log_verbose("opening a transliterator and UFILE for testing\n");
|
log_verbose("opening a transliterator and UFILE for testing\n");
|
||||||
|
|
||||||
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
|
f = u_fopen(STANDARD_TEST_FILE, "w", "en_US_POSIX", "utf-16");
|
||||||
if(f == NULL)
|
if(f == NULL)
|
||||||
{
|
{
|
||||||
log_err("Couldn't open test file for writing");
|
log_err("Couldn't open test file for writing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
|
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
|
||||||
if(U_FAILURE(err))
|
if(U_FAILURE(err))
|
||||||
{
|
{
|
||||||
log_err("Err opening transliterator %s\n", u_errorName(err));
|
log_err("Err opening transliterator %s\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("setting a transliterator\n");
|
log_verbose("setting a transliterator\n");
|
||||||
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
||||||
if(U_FAILURE(err))
|
if(U_FAILURE(err))
|
||||||
{
|
{
|
||||||
log_err("Err setting transliterator %s\n", u_errorName(err));
|
log_err("Err setting transliterator %s\n", u_errorName(err));
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b != NULL)
|
if(b != NULL)
|
||||||
{
|
{
|
||||||
log_err("Err, a transliterator was already set!\n");
|
log_err("Err, a transliterator was already set!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
u_fprintf(f, "%KStephanos", 0xFEFF);
|
u_fprintf(f, "%KStephanos", 0xFEFF);
|
||||||
|
|
||||||
u_fclose(f);
|
u_fclose(f);
|
||||||
|
|
||||||
log_verbose("Re reading test file to verify transliteration\n");
|
log_verbose("Re reading test file to verify transliteration\n");
|
||||||
infile = fopen(STANDARD_TEST_FILE, "rb");
|
infile = fopen(STANDARD_TEST_FILE, "rb");
|
||||||
if(infile == NULL)
|
if(infile == NULL)
|
||||||
{
|
{
|
||||||
log_err("Couldn't reopen test file\n");
|
log_err("Couldn't reopen test file\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
|
len=fread(ubuf, sizeof(UChar), u_strlen(compare), infile);
|
||||||
log_verbose("Read %d UChars\n", len);
|
log_verbose("Read %d UChars\n", len);
|
||||||
if(len != u_strlen(compare))
|
if(len != u_strlen(compare))
|
||||||
{
|
{
|
||||||
log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
|
log_err("Wanted %d UChars from file, got %d\n", u_strlen(compare), len);
|
||||||
}
|
}
|
||||||
ubuf[len]=0;
|
ubuf[len]=0;
|
||||||
|
|
||||||
if(u_strlen(compare) != u_strlen(ubuf))
|
if(u_strlen(compare) != u_strlen(ubuf))
|
||||||
{
|
{
|
||||||
log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
|
log_err("Wanted %d UChars from file, but u_strlen() returns %d\n", u_strlen(compare), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(u_strcmp(compare, ubuf))
|
if(u_strcmp(compare, ubuf))
|
||||||
{
|
{
|
||||||
log_err("Read string doesn't match expected.\n");
|
log_err("Read string doesn't match expected.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_verbose("Read string matches expected.\n");
|
log_verbose("Read string matches expected.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addAllTests(TestNode** root) {
|
static void addAllTests(TestNode** root) {
|
||||||
|
@ -50,7 +50,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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"
|
!ELSEIF "$(CFG)" == "iotest - Win32 Debug"
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ BSC32=bscmake.exe
|
|||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
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 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
|
!ENDIF
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user