summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/test/iotest
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2007-11-21 12:29:46 +0000
committerJonathan Kew <jfkthame@googlemail.com>2007-11-21 12:29:46 +0000
commit952d69f85d43b087ce9fa79d3fc6f1c076000bc7 (patch)
treedd6937a6486e80e1638618308481075efab000ae /Build/source/libs/icu-xetex/test/iotest
parent888236cb9df7b7d7b5a3e2d784037a9a59511c53 (diff)
updated icu-xetex library for XeTeX 0.997
git-svn-id: svn://tug.org/texlive/trunk@5536 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu-xetex/test/iotest')
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/Makefile.in22
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/filetst.c53
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/iotest.cpp124
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/iotest.h3
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/iotest.vcproj27
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/stream.cpp135
-rw-r--r--Build/source/libs/icu-xetex/test/iotest/strtst.c48
7 files changed, 248 insertions, 164 deletions
diff --git a/Build/source/libs/icu-xetex/test/iotest/Makefile.in b/Build/source/libs/icu-xetex/test/iotest/Makefile.in
index 3e22044f4d5..bfdbcf4c39f 100644
--- a/Build/source/libs/icu-xetex/test/iotest/Makefile.in
+++ b/Build/source/libs/icu-xetex/test/iotest/Makefile.in
@@ -1,6 +1,10 @@
+#******************************************************************************
+#
+# Copyright (C) 1999-2005, International Business Machines
+# Corporation and others. All Rights Reserved.
+#
+#******************************************************************************
## Makefile.in for ICU - test/iotest
-## Copyright (c) 2002-2005, International Business Machines Corporation and
-## others. All Rights Reserved.
## Source directory information
srcdir = @srcdir@
@@ -8,6 +12,7 @@ top_srcdir = @top_srcdir@
top_builddir = ../..
+## All the flags and other definitions are included here.
include $(top_builddir)/icudefs.mk
## Build directory information
@@ -27,15 +32,19 @@ BUILDDIR := $(BUILDDIR:test\\iotest/../../=)
# Simplify the path for Windows 98
BUILDDIR := $(BUILDDIR:TEST\\IOTEST/../../=)
-CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n \
--I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/io
+ifneq ($(top_builddir),$(top_srcdir))
+CPPFLAGS += -I$(top_builddir)/common
+endif
+CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/ctestfw -I$(top_srcdir)/io
DEFS += -D'U_TOPSRCDIR="$(top_srcdir)/"' -D'U_TOPBUILDDIR="$(BUILDDIR)"'
LIBS = $(LIBCTESTFW) $(LIBICUTOOLUTIL) $(LIBICUIO) $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
-OBJECTS = iotest.o strtst.o filetst.o trnstst.o
+OBJECTS = iotest.o stream.o strtst.o filetst.o trnstst.o
DEPS = $(OBJECTS:.o=.d)
+-include Makefile.local
+
## List of phony targets
.PHONY : all all-local install install-local clean clean-local \
distclean distclean-local dist dist-local check check-local
@@ -64,8 +73,6 @@ clean-local:
distclean-local: clean-local
$(RMV) Makefile
--include Makefile.local
-
check-local: all-local
$(INVOKE) ./$(TARGET) $(IOTEST_OPTS) || true
@@ -85,3 +92,4 @@ ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
endif
endif
endif
+
diff --git a/Build/source/libs/icu-xetex/test/iotest/filetst.c b/Build/source/libs/icu-xetex/test/iotest/filetst.c
index 1c09dd0a02c..1e908e42a1b 100644
--- a/Build/source/libs/icu-xetex/test/iotest/filetst.c
+++ b/Build/source/libs/icu-xetex/test/iotest/filetst.c
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 2004-2005, International Business Machines
+* Copyright (C) 2004-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: filetst.c
@@ -53,8 +53,11 @@ static void TestFileFromICU(UFILE *myFile) {
origPtr = (void *) INT64_C(0x1000200030004000);
} else if (sizeof(void *) == 16) {
/* iSeries */
- int32_t massiveBigEndianPtr[] = { 0x10002000, 0x30004000, 0x50006000, 0x70008000 };
- origPtr = *((void **)massiveBigEndianPtr);
+ union {
+ int32_t arr[4];
+ void *ptr;
+ } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
+ origPtr = massiveBigEndianPtr.ptr;
} else {
log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
}
@@ -90,8 +93,8 @@ static void TestFileFromICU(UFILE *myFile) {
u_fprintf(myFile, "Pointer to integer Value: %d\n", *n);
u_fprintf(myFile, "This is a long test123456789012345678901234567890123456789012345678901234567890\n");
*n = 1;
- fprintf(u_fgetfile(myFile), "\tNormal fprintf count: n=%d %n n=%d\n", (int)*n, (int*)n, (int)*n);
- fprintf(u_fgetfile(myFile), "\tNormal fprintf count value: n=%d\n", (int)*n);
+ u_fprintf(myFile, "\tNormal fprintf count: n=%d %n n=%d\n", (int)*n, (int*)n, (int)*n);
+ fprintf(u_fgetfile(myFile), "\tNormal fprintf count value: n=%d\n", (int)*n); /* Should be 27 as stated later on. */
u_fclose(myFile);
myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, NULL);
@@ -163,27 +166,27 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("%%X Got: %X, Expected: %X\n", *newValuePtr, *n);
}
*newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Float %%f: %f\n", newDoubleValuePtr);
+ u_fscanf(myFile, "Float %%f: %lf\n", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
}
*newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Lowercase float %%e: %e\n", newDoubleValuePtr);
+ u_fscanf(myFile, "Lowercase float %%e: %le\n", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
}
*newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Uppercase float %%E: %E\n", newDoubleValuePtr);
+ u_fscanf(myFile, "Uppercase float %%E: %lE\n", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
}
*newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Lowercase float %%g: %g\n", newDoubleValuePtr);
+ u_fscanf(myFile, "Lowercase float %%g: %lg\n", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
}
*newDoubleValuePtr = -1.0;
- u_fscanf(myFile, "Uppercase float %%G: %G\n", newDoubleValuePtr);
+ u_fscanf(myFile, "Uppercase float %%G: %lG\n", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
}
@@ -433,12 +436,12 @@ static void TestfgetsBuffers(void) {
}
u_fputc(0x3BC, myFile);
- if (u_fputc(0x110000, myFile) != U_EOF) {
+ if (u_fputc(0x110000, myFile) != U_EOF) {
log_err("u_fputc should return U_EOF for 0x110000.\n");
- }
- if (u_fputc((UChar32)0xFFFFFFFFu, myFile) != U_EOF) {
+ }
+ if (u_fputc((UChar32)0xFFFFFFFFu, myFile) != U_EOF) {
log_err("u_fputc should return U_EOF for 0xFFFFFFFF.\n");
- }
+ }
u_fputc(0xFF41, myFile);
u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0]));
u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));
@@ -1396,32 +1399,32 @@ static void TestVargs(void) {
static void TestUnicodeFormat(void)
{
#if !UCONFIG_NO_FORMATTING
- /* Make sure that invariant conversion doesn't happen on the _u formats. */
+ /* Make sure that invariant conversion doesn't happen on the _u formats. */
UChar myUString[256];
- UFILE *myFile;
- static const UChar TEST_STR[] = { 0x03BC, 0x0025, 0x0024, 0};
- static const UChar PERCENT_S[] = { 0x03BC, 0x0025, 0x0053, 0};
+ UFILE *myFile;
+ static const UChar TEST_STR[] = { 0x03BC, 0x0025, 0x0024, 0};
+ static const UChar PERCENT_S[] = { 0x03BC, 0x0025, 0x0053, 0};
- u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
+ u_memset(myUString, 0x2a, sizeof(myUString)/sizeof(*myUString));
myFile = u_fopen(STANDARD_TEST_FILE, "w", NULL, "UTF-8");
if (!myFile) {
log_err("Test file can't be opened\n");
return;
}
- u_fprintf_u(myFile, PERCENT_S, TEST_STR);
- u_fclose(myFile);
+ u_fprintf_u(myFile, PERCENT_S, TEST_STR);
+ u_fclose(myFile);
myFile = u_fopen(STANDARD_TEST_FILE, "r", NULL, "UTF-8");
if (!myFile) {
log_err("Test file can't be opened\n");
return;
}
- u_fscanf_u(myFile, PERCENT_S, myUString);
- u_fclose(myFile);
- if (u_strcmp(TEST_STR, myUString) != 0) {
+ u_fscanf_u(myFile, PERCENT_S, myUString);
+ u_fclose(myFile);
+ if (u_strcmp(TEST_STR, myUString) != 0) {
log_err("u_fscanf_u doesn't work.\n");
- }
+ }
#endif
}
diff --git a/Build/source/libs/icu-xetex/test/iotest/iotest.cpp b/Build/source/libs/icu-xetex/test/iotest/iotest.cpp
index 250aafb6237..748ae3584d8 100644
--- a/Build/source/libs/icu-xetex/test/iotest/iotest.cpp
+++ b/Build/source/libs/icu-xetex/test/iotest/iotest.cpp
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 2002-2005, International Business Machines
+* Copyright (C) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: iotest.cpp
@@ -14,7 +14,6 @@
#include "unicode/ustdio.h"
-#include "unicode/ustream.h"
#include "unicode/uclean.h"
#include "unicode/ucnv.h"
@@ -26,36 +25,9 @@
#include "unicode/tstdtmod.h"
#include "putilimp.h"
-#if U_IOSTREAM_SOURCE >= 199711
-#include <iostream>
-#if defined(U_LINUX) || defined(U_CYGWIN)
-#define USE_SSTREAM 1
-#include <sstream>
-#else
-// <strstream> is deprecated on some platforms, and the compiler complains very loudly if you use it.
-#include <strstream>
-#endif
-using namespace std;
-#elif U_IOSTREAM_SOURCE >= 198506
-#include <iostream.h>
-#include <strstream.h>
-#endif
-
#include <string.h>
#include <stdlib.h>
-U_CDECL_BEGIN
-#ifdef U_WINDOWS
-const UChar NEW_LINE[] = {0x0d,0x0a,0};
-const char C_NEW_LINE[] = {0x0d,0x0a,0};
-#define UTF8_NEW_LINE "\x0d\x0a"
-#else
-const UChar NEW_LINE[] = {0x0a,0};
-const char C_NEW_LINE[] = {'\n',0};
-#define UTF8_NEW_LINE "\x0a"
-#endif
-U_CDECL_END
-
class DataDrivenLogger : public TestLog {
static const char* fgDataDir;
static char *fgTestDataPath;
@@ -389,6 +361,7 @@ static void U_CALLCONV DataDrivenScanf(void)
int32_t i32, expected32;
int64_t i64, expected64;
double dbl, expectedDbl;
+ volatile float flt, expectedFlt; // Use volatile in order to get around an Intel compiler issue.
int32_t uBufferLenReturned;
//const char *fileLocale = "en_US_POSIX";
@@ -438,6 +411,15 @@ static void U_CALLCONV DataDrivenScanf(void)
i, dbl, expectedDbl);
}
break;
+ case 0x66: // 'f' float
+ expectedFlt = (float)atof(u_austrcpy(cBuffer, expectedResult));
+ uBufferLenReturned = u_sscanf_u(argument, format, &flt);
+ //uFileBufferLenReturned = u_fscanf_u(testFile, format, flt);
+ if (flt != expectedFlt) {
+ log_err("error in scanf test case[%d] Got: %f Exp: %f\n",
+ i, flt, expectedFlt);
+ }
+ break;
case 0x31: // '1' int8_t
expected8 = (int8_t)uto64(expectedResult);
uBufferLenReturned = u_sscanf_u(argument, format, &i8);
@@ -682,88 +664,6 @@ static void U_CALLCONV DataDrivenPrintfPrecision(void)
}
U_CDECL_END
-U_CDECL_BEGIN
-static void U_CALLCONV TestStream(void)
-{
-#if U_IOSTREAM_SOURCE >= 198506
- const UChar thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
- const UChar mu[] = { 0x6D, 0x75, 0};
- UnicodeString str1 = UNICODE_STRING_SIMPLE("str1");
- UnicodeString str2 = UNICODE_STRING_SIMPLE(" <<");
- UnicodeString str3 = UNICODE_STRING_SIMPLE("2");
- UnicodeString str4 = UNICODE_STRING_SIMPLE(" UTF-8 ");
- UnicodeString inStr = UNICODE_STRING_SIMPLE(" UTF-8 ");
- UnicodeString inStr2;
- char defConvName[UCNV_MAX_CONVERTER_NAME_LENGTH*2];
- char inStrC[128];
- UErrorCode status = U_ZERO_ERROR;
- UConverter *defConv;
- static const char testStr[] = "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20\x73\x74\x72\x31\x20\x20\x20\x3C\x3C\x32\x31\x20" UTF8_NEW_LINE "\x20\x55\x54\x46\x2D\x38\x20\xCE\xBC\xF0\x90\x80\x81\xF0\x90\x80\x82";
-
- str4.append((UChar32)0x03BC); /* mu */
- str4.append((UChar32)0x10001);
- str4.append((UChar32)0x10002);
-
- /* release the default converter and use utf-8 for a bit */
- defConv = u_getDefaultConverter(&status);
- if (U_FAILURE(status)) {
- log_err("Can't get default converter\n");
- return;
- }
- ucnv_close(defConv);
- strncpy(defConvName, ucnv_getDefaultName(), sizeof(defConvName)/sizeof(defConvName[0]));
- ucnv_setDefaultName("UTF-8");
-
- static const char * const TESTSTRING = "\x20\x74\x48\x69\x73\xCE\xBC\xE2\x80\x82\x20\x6D\x75\x20\x77\x6F\x72\x6C\x64";
-#ifdef USE_SSTREAM
- ostringstream outTestStream;
- istringstream inTestStream(TESTSTRING);
-#else
- char testStreamBuf[512];
- ostrstream outTestStream(testStreamBuf, sizeof(testStreamBuf));
- istrstream inTestStream(TESTSTRING, 0);
-
- /* initialize testStreamBuf */
- memset(testStreamBuf, '*', sizeof(testStreamBuf));
- testStreamBuf[sizeof(testStreamBuf)-1] = 0;
-#endif
-
- outTestStream << "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20";
- outTestStream << str1 << "\x20\x20" << str2 << str3 << "\x31\x20" << UTF8_NEW_LINE << str4 << ends;
-#ifdef USE_SSTREAM
- string tempStr = outTestStream.str();
- const char *testStreamBuf = tempStr.c_str();
-#endif
- if (strcmp(testStreamBuf, testStr) != 0) {
- log_err("Got: \"%s\", Expected: \"%s\"\n", testStreamBuf, testStr);
- }
-
- inTestStream >> inStr >> inStr2;
- if (inStr.compare(thisMu) != 0) {
- u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
- inStrC[inStr.length()] = 0;
- log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
- }
- if (inStr2.compare(mu) != 0) {
- u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
- inStrC[inStr.length()] = 0;
- log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
- }
-
- /* return the default converter to the original state. */
- ucnv_setDefaultName(defConvName);
- defConv = u_getDefaultConverter(&status);
- if (U_FAILURE(status)) {
- log_err("Can't get default converter");
- return;
- }
- ucnv_close(defConv);
-#else
- log_info("U_IOSTREAM_SOURCE is disabled\n");
-#endif
-}
-U_CDECL_END
-
static void addAllTests(TestNode** root) {
addFileTest(root);
addStringTest(root);
@@ -774,7 +674,7 @@ static void addAllTests(TestNode** root) {
addTest(root, &DataDrivenPrintfPrecision, "datadriv/DataDrivenPrintfPrecision");
addTest(root, &DataDrivenScanf, "datadriv/DataDrivenScanf");
#endif
- addTest(root, &TestStream, "stream/TestStream");
+ addStreamTests(root);
}
/* returns the path to icu/source/data/out */
diff --git a/Build/source/libs/icu-xetex/test/iotest/iotest.h b/Build/source/libs/icu-xetex/test/iotest/iotest.h
index 6e63d958177..6d522dc435d 100644
--- a/Build/source/libs/icu-xetex/test/iotest/iotest.h
+++ b/Build/source/libs/icu-xetex/test/iotest/iotest.h
@@ -27,6 +27,9 @@ addFileTest(TestNode** root);
U_CFUNC void
addTranslitTest(TestNode** root);
+U_CFUNC void
+addStreamTests(TestNode** root);
+
U_CDECL_BEGIN
extern const UChar NEW_LINE[];
extern const char C_NEW_LINE[];
diff --git a/Build/source/libs/icu-xetex/test/iotest/iotest.vcproj b/Build/source/libs/icu-xetex/test/iotest/iotest.vcproj
index 682f9a39258..68ea46e094a 100644
--- a/Build/source/libs/icu-xetex/test/iotest/iotest.vcproj
+++ b/Build/source/libs/icu-xetex/test/iotest/iotest.vcproj
@@ -29,6 +29,7 @@
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
DisableLanguageExtensions="TRUE"
+ TreatWChar_tAsBuiltInType="TRUE"
PrecompiledHeaderFile=".\Debug/iotest.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
@@ -90,6 +91,7 @@
StringPooling="TRUE"
RuntimeLibrary="2"
DisableLanguageExtensions="TRUE"
+ TreatWChar_tAsBuiltInType="TRUE"
PrecompiledHeaderFile=".\Release/iotest.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
@@ -139,23 +141,38 @@
Name="Source Files"
Filter="cpp;c;cxx">
<File
- RelativePath="filetst.c">
+ RelativePath=".\filetst.c">
</File>
<File
- RelativePath="iotest.cpp">
+ RelativePath=".\iotest.cpp">
</File>
<File
- RelativePath="strtst.c">
+ RelativePath=".\stream.cpp">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ DisableLanguageExtensions="FALSE"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ DisableLanguageExtensions="FALSE"/>
+ </FileConfiguration>
</File>
<File
- RelativePath="trnstst.c">
+ RelativePath=".\strtst.c">
+ </File>
+ <File
+ RelativePath=".\trnstst.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx">
<File
- RelativePath="iotest.h">
+ RelativePath=".\iotest.h">
</File>
</Filter>
</Files>
diff --git a/Build/source/libs/icu-xetex/test/iotest/stream.cpp b/Build/source/libs/icu-xetex/test/iotest/stream.cpp
new file mode 100644
index 00000000000..ccc70632235
--- /dev/null
+++ b/Build/source/libs/icu-xetex/test/iotest/stream.cpp
@@ -0,0 +1,135 @@
+/*
+**********************************************************************
+* Copyright (C) 2002-2006, International Business Machines
+* Corporation and others. All Rights Reserved.
+**********************************************************************
+* file name: iotest.cpp
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2002feb21
+* created by: George Rhoten
+*/
+
+
+#include "unicode/ustream.h"
+
+#include "unicode/ucnv.h"
+#include "unicode/ustring.h"
+#include "ustr_cnv.h"
+#include "iotest.h"
+
+#if U_IOSTREAM_SOURCE >= 199711
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define USE_SSTREAM 1
+#include <sstream>
+#else
+// <strstream> is deprecated on some platforms, and the compiler complains very loudly if you use it.
+#include <strstream>
+#endif
+using namespace std;
+#elif U_IOSTREAM_SOURCE >= 198506
+#include <strstream.h>
+#endif
+
+#include <string.h>
+
+U_CDECL_BEGIN
+#ifdef U_WINDOWS
+const UChar NEW_LINE[] = {0x0d,0x0a,0};
+const char C_NEW_LINE[] = {0x0d,0x0a,0};
+#define UTF8_NEW_LINE "\x0d\x0a"
+#else
+const UChar NEW_LINE[] = {0x0a,0};
+const char C_NEW_LINE[] = {'\n',0};
+#define UTF8_NEW_LINE "\x0a"
+#endif
+U_CDECL_END
+
+U_CDECL_BEGIN
+static void U_CALLCONV TestStream(void)
+{
+#if U_IOSTREAM_SOURCE >= 198506
+ const UChar thisMu[] = { 0x74, 0x48, 0x69, 0x73, 0x3BC, 0};
+ const UChar mu[] = { 0x6D, 0x75, 0};
+ UnicodeString str1 = UNICODE_STRING_SIMPLE("str1");
+ UnicodeString str2 = UNICODE_STRING_SIMPLE(" <<");
+ UnicodeString str3 = UNICODE_STRING_SIMPLE("2");
+ UnicodeString str4 = UNICODE_STRING_SIMPLE(" UTF-8 ");
+ UnicodeString inStr = UNICODE_STRING_SIMPLE(" UTF-8 ");
+ UnicodeString inStr2;
+ char defConvName[UCNV_MAX_CONVERTER_NAME_LENGTH*2];
+ char inStrC[128];
+ UErrorCode status = U_ZERO_ERROR;
+ UConverter *defConv;
+ static const char testStr[] = "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20\x73\x74\x72\x31\x20\x20\x20\x3C\x3C\x32\x31\x20" UTF8_NEW_LINE "\x20\x55\x54\x46\x2D\x38\x20\xCE\xBC\xF0\x90\x80\x81\xF0\x90\x80\x82";
+
+ str4.append((UChar32)0x03BC); /* mu */
+ str4.append((UChar32)0x10001);
+ str4.append((UChar32)0x10002);
+
+ /* release the default converter and use utf-8 for a bit */
+ defConv = u_getDefaultConverter(&status);
+ if (U_FAILURE(status)) {
+ log_err("Can't get default converter\n");
+ return;
+ }
+ ucnv_close(defConv);
+ strncpy(defConvName, ucnv_getDefaultName(), sizeof(defConvName)/sizeof(defConvName[0]));
+ ucnv_setDefaultName("UTF-8");
+
+ static const char * const TESTSTRING = "\x20\x74\x48\x69\x73\xCE\xBC\xE2\x80\x82\x20\x6D\x75\x20\x77\x6F\x72\x6C\x64";
+#ifdef USE_SSTREAM
+ ostringstream outTestStream;
+ istringstream inTestStream(TESTSTRING);
+#else
+ char testStreamBuf[512];
+ ostrstream outTestStream(testStreamBuf, sizeof(testStreamBuf));
+ istrstream inTestStream(TESTSTRING, 0);
+
+ /* initialize testStreamBuf */
+ memset(testStreamBuf, '*', sizeof(testStreamBuf));
+ testStreamBuf[sizeof(testStreamBuf)-1] = 0;
+#endif
+
+ outTestStream << "\x42\x65\x67\x69\x6E\x6E\x69\x6E\x67\x20\x6F\x66\x20\x74\x65\x73\x74\x20";
+ outTestStream << str1 << "\x20\x20" << str2 << str3 << "\x31\x20" << UTF8_NEW_LINE << str4 << ends;
+#ifdef USE_SSTREAM
+ string tempStr = outTestStream.str();
+ const char *testStreamBuf = tempStr.c_str();
+#endif
+ if (strcmp(testStreamBuf, testStr) != 0) {
+ log_err("Got: \"%s\", Expected: \"%s\"\n", testStreamBuf, testStr);
+ }
+
+ inTestStream >> inStr >> inStr2;
+ if (inStr.compare(thisMu) != 0) {
+ u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
+ inStrC[inStr.length()] = 0;
+ log_err("Got: \"%s\", Expected: \"tHis\\u03BC\"\n", inStrC);
+ }
+ if (inStr2.compare(mu) != 0) {
+ u_austrncpy(inStrC, inStr.getBuffer(), inStr.length());
+ inStrC[inStr.length()] = 0;
+ log_err("Got: \"%s\", Expected: \"mu\"\n", inStrC);
+ }
+
+ /* return the default converter to the original state. */
+ ucnv_setDefaultName(defConvName);
+ defConv = u_getDefaultConverter(&status);
+ if (U_FAILURE(status)) {
+ log_err("Can't get default converter");
+ return;
+ }
+ ucnv_close(defConv);
+#else
+ log_info("U_IOSTREAM_SOURCE is disabled\n");
+#endif
+}
+U_CDECL_END
+
+U_CFUNC void addStreamTests(TestNode** root) {
+ addTest(root, &TestStream, "stream/TestStream");
+}
+
diff --git a/Build/source/libs/icu-xetex/test/iotest/strtst.c b/Build/source/libs/icu-xetex/test/iotest/strtst.c
index 906f519d3c2..0412f25efb2 100644
--- a/Build/source/libs/icu-xetex/test/iotest/strtst.c
+++ b/Build/source/libs/icu-xetex/test/iotest/strtst.c
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 2004-2005, International Business Machines
+* Copyright (C) 2004-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: strtst.c
@@ -42,8 +42,11 @@ static void TestString(void) {
origPtr = (void *) INT64_C(0x1000200030004000);
} else if (sizeof(void *) == 16) {
/* iSeries */
- int32_t massiveBigEndianPtr[] = { 0x10002000, 0x30004000, 0x50006000, 0x70008000 };
- origPtr = *((void **)massiveBigEndianPtr);
+ union {
+ int32_t arr[4];
+ void *ptr;
+ } massiveBigEndianPtr = {{ 0x10002000, 0x30004000, 0x50006000, 0x70008000 }};
+ origPtr = massiveBigEndianPtr.ptr;
} else {
log_err("sizeof(void*)=%d hasn't been tested before", (int)sizeof(void*));
}
@@ -93,35 +96,35 @@ static void TestString(void) {
u_sprintf(uStringBuf, "Float f: %f", myFloat);
*newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Float f: %f", newDoubleValuePtr);
+ u_sscanf(uStringBuf, "Float f: %lf", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%f Got: %f, Expected: %f\n", *newDoubleValuePtr, myFloat);
}
u_sprintf(uStringBuf, "Lowercase float e: %e", myFloat);
*newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Lowercase float e: %e", newDoubleValuePtr);
+ u_sscanf(uStringBuf, "Lowercase float e: %le", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%e Got: %e, Expected: %e\n", *newDoubleValuePtr, myFloat);
}
u_sprintf(uStringBuf, "Uppercase float E: %E", myFloat);
*newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Uppercase float E: %E", newDoubleValuePtr);
+ u_sscanf(uStringBuf, "Uppercase float E: %lE", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%E Got: %E, Expected: %E\n", *newDoubleValuePtr, myFloat);
}
u_sprintf(uStringBuf, "Lowercase float g: %g", myFloat);
*newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Lowercase float g: %g", newDoubleValuePtr);
+ u_sscanf(uStringBuf, "Lowercase float g: %lg", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%g Got: %g, Expected: %g\n", *newDoubleValuePtr, myFloat);
}
u_sprintf(uStringBuf, "Uppercase float G: %G", myFloat);
*newDoubleValuePtr = -1.0;
- u_sscanf(uStringBuf, "Uppercase float G: %G", newDoubleValuePtr);
+ u_sscanf(uStringBuf, "Uppercase float G: %lG", newDoubleValuePtr);
if (myFloat != *newDoubleValuePtr) {
log_err("%%G Got: %G, Expected: %G\n", *newDoubleValuePtr, myFloat);
}
@@ -279,7 +282,7 @@ static void TestLocalizedString(void) {
u_fprintf(strFile, "%d", 1234);
u_frewind(strFile);
- numResult = -1;
+ numResult = -1;
u_fscanf(strFile, "%d", &numResult);
u_fclose(strFile);
u_uastrcpy(uBuffer,"1.234");
@@ -294,15 +297,15 @@ static void TestLocalizedString(void) {
strFile = u_fstropen(testStr, sizeof(testStr)/sizeof(testStr[0]), NULL);
u_fprintf(strFile, "%d", 1234);
u_frewind(strFile);
- numResult = -1;
+ numResult = -1;
u_fscanf(strFile, "%d", &numResult);
u_fclose(strFile);
if (numResult != 1234) {
- log_err("u_fscanf failed to work on a default locale string Got: %d, Expected: 1234\n", numResult);
+ log_err("u_fscanf failed to work on a default locale string Got: %d, Expected: 1234\n", numResult);
+ }
+ if (u_fstropen(testStr, -1, NULL) != NULL) {
+ log_err("u_fstropen returned a UFILE* on a negative buffer size\n", numResult);
}
- if (u_fstropen(testStr, -1, NULL) != NULL) {
- log_err("u_fstropen returned a UFILE* on a negative buffer size\n", numResult);
- }
#endif
}
@@ -728,9 +731,11 @@ static void TestVargs(void) {
static void TestCount(void) {
#if !UCONFIG_NO_FORMATTING
+ static const UChar x15[] = { 0x78, 0x31, 0x35, 0 };
UChar testStr[16];
+ UChar character;
int16_t i16 = -1;
- int32_t i32 = -1;
+ int32_t i32 = -1, actual_count, actual_result;
int64_t i64 = -1;
u_uastrcpy(testStr, "1233456789");
if (u_sscanf(testStr, "%*3[123]%n%*[1-9]", &i32) != 0) {
@@ -751,6 +756,19 @@ static void TestCount(void) {
if (i64 != 10) {
log_err("test 3: scanf did not return 10\n", i64);
}
+ actual_result = u_sscanf(x15, "%C%d%n", &character, &i32, &actual_count);
+ if (actual_result != 2) {
+ log_err("scanf should return 2, but returned %d\n", actual_result);
+ }
+ if (character != 0x78) {
+ log_err("scanf should return 0x78 for the character, but returned %X\n", character);
+ }
+ if (i32 != 15) {
+ log_err("scanf should return 15 for the number, but returned %d\n", i32);
+ }
+ if (actual_count != 3) {
+ log_err("scanf should return 3 for actual_count, but returned %d\n", actual_count);
+ }
#endif
}