X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/test/iotest/stream.cpp?ds=sidebyside diff --git a/icuSources/test/iotest/stream.cpp b/icuSources/test/iotest/stream.cpp index 8fb3cf5a..e54e8b6a 100644 --- a/icuSources/test/iotest/stream.cpp +++ b/icuSources/test/iotest/stream.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2002-2010, International Business Machines +* Copyright (C) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * file name: iotest.cpp @@ -18,6 +18,7 @@ #include "unicode/ucnv.h" #include "unicode/ustring.h" #include "ustr_cnv.h" +#include "cmemory.h" #include "iotest.h" #if U_IOSTREAM_SOURCE >= 199711 @@ -31,16 +32,11 @@ #include #include using namespace std; -#elif U_IOSTREAM_SOURCE >= 198506 -#define USE_OLD_IOSTREAM 1 -#include -#include -#endif #include U_CDECL_BEGIN -#ifdef U_WINDOWS +#if U_PLATFORM_USES_ONLY_WIN32_API const UChar NEW_LINE[] = {0x0d,0x0a,0}; const char C_NEW_LINE[] = {0x0d,0x0a,0}; #define UTF8_NEW_LINE "\x0d\x0a" @@ -51,11 +47,9 @@ const char C_NEW_LINE[] = {'\n',0}; #endif U_CDECL_END -#if U_IOSTREAM_SOURCE 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"); @@ -81,7 +75,7 @@ static void U_CALLCONV TestStream(void) return; } ucnv_close(defConv); - strncpy(defConvName, ucnv_getDefaultName(), sizeof(defConvName)/sizeof(defConvName[0])); + strncpy(defConvName, ucnv_getDefaultName(), UPRV_LENGTHOF(defConvName)); 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"; @@ -158,7 +152,7 @@ static void U_CALLCONV TestStream(void) ostrstream outLargeStream(testLargeStreamBuf, sizeof(testLargeStreamBuf)); #endif UChar large_array[200]; - int32_t large_array_length = sizeof(large_array)/sizeof(UChar); + int32_t large_array_length = UPRV_LENGTHOF(large_array); for (int32_t i = 0; i < large_array_length; i++) { large_array[i] = 0x41; } @@ -182,9 +176,6 @@ static void U_CALLCONV TestStream(void) log_err("Error converting string for large stream buffer testing.\n"); } ucnv_close(defConv); -#else - log_info("U_IOSTREAM_SOURCE is disabled\n"); -#endif } #define IOSTREAM_GOOD_SHIFT 3 @@ -248,12 +239,7 @@ testString( if (getBitStatus(sstrm) != expectedStatus) { printBits(sstrm); -#ifdef USE_OLD_IOSTREAM - log_info("Warning. Expected status %d, Got %d. This maybe caused by the fact that the non-standardized iostream is being used.\n", expectedStatus, getBitStatus(sstrm)); - log_info("See verbose output for details.\n"); -#else log_err("Expected status %d, Got %d. See verbose output for details\n", expectedStatus, getBitStatus(sstrm)); -#endif } if (str != UnicodeString(expectedString)) { log_err("Did not get expected results from \"%s\", expected \"%s\"\n", testString, expectedString); @@ -271,11 +257,6 @@ static void U_CALLCONV TestStreamEOF(void) strstream ss; #endif -#ifdef USE_OLD_IOSTREAM - log_info("Old non-standardized iostream being used. This may result in inconsistent state flag settings. (e.g. failbit may not be set properly)\n"); - log_info("In such a case, warnings will be issued instead of errors.\n"); -#endif - fs << "EXAMPLE"; fs.seekg(0); ss << "EXAMPLE";