diff --git a/icu4c/source/common/unicode/uobject.h b/icu4c/source/common/unicode/uobject.h index d457db0677b..d4c01ebcb8d 100644 --- a/icu4c/source/common/unicode/uobject.h +++ b/icu4c/source/common/unicode/uobject.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 2002, International Business Machines +* Copyright (C) 2002-2003, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -118,6 +118,9 @@ public: static inline void operator delete(void *, void *) {} #endif /* U_HAVE_PLACEMENT_NEW */ #endif /* U_OVERRIDE_CXX_ALLOCATION */ + +private: + UMemory &UMemory::operator=(const UMemory &); // not implemented }; /** @@ -190,6 +193,9 @@ protected: // see also UObject class documentation. // virtual UObject *clone() const; #endif + +private: + UObject &UObject::operator=(const UObject &); // not implemented }; U_NAMESPACE_END diff --git a/icu4c/source/test/cintltst/custrtrn.c b/icu4c/source/test/cintltst/custrtrn.c index 304dc546906..17b413efc24 100644 --- a/icu4c/source/test/cintltst/custrtrn.c +++ b/icu4c/source/test/cintltst/custrtrn.c @@ -19,9 +19,10 @@ #include #include "unicode/utypes.h" #include "unicode/ustring.h" +#include "ustr_imp.h" #include "cintltst.h" -#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) +#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) void addUCharTransformTest(TestNode** root); @@ -610,6 +611,44 @@ static void Test_UChar_WCHART_API(void){ free(uDest); } -} + /* + * Test u_terminateWChars(). + * All u_terminateXYZ() use the same implementation macro; + * we test this function to improve API coverage. + */ + { + wchar_t buffer[10]; - + err=U_ZERO_ERROR; + buffer[3]=0x20ac; + wDestLen=u_terminateWChars(buffer, LENGTHOF(buffer), 3, &err); + if(err!=U_ZERO_ERROR || wDestLen!=3 || buffer[3]!=0) { + log_err("u_terminateWChars(buffer, all, 3, zero) failed: %s length %d [3]==U+%04x\n", + u_errorName(err), wDestLen, buffer[3]); + } + + err=U_ZERO_ERROR; + buffer[3]=0x20ac; + wDestLen=u_terminateWChars(buffer, 3, 3, &err); + if(err!=U_STRING_NOT_TERMINATED_WARNING || wDestLen!=3 || buffer[3]!=0x20ac) { + log_err("u_terminateWChars(buffer, 3, 3, zero) failed: %s length %d [3]==U+%04x\n", + u_errorName(err), wDestLen, buffer[3]); + } + + err=U_STRING_NOT_TERMINATED_WARNING; + buffer[3]=0x20ac; + wDestLen=u_terminateWChars(buffer, LENGTHOF(buffer), 3, &err); + if(err!=U_ZERO_ERROR || wDestLen!=3 || buffer[3]!=0) { + log_err("u_terminateWChars(buffer, all, 3, not-terminated) failed: %s length %d [3]==U+%04x\n", + u_errorName(err), wDestLen, buffer[3]); + } + + err=U_ZERO_ERROR; + buffer[3]=0x20ac; + wDestLen=u_terminateWChars(buffer, 2, 3, &err); + if(err!=U_BUFFER_OVERFLOW_ERROR || wDestLen!=3 || buffer[3]!=0x20ac) { + log_err("u_terminateWChars(buffer, 2, 3, zero) failed: %s length %d [3]==U+%04x\n", + u_errorName(err), wDestLen, buffer[3]); + } + } +} diff --git a/icu4c/source/test/cintltst/usettest.c b/icu4c/source/test/cintltst/usettest.c index 5a2e1c0a20f..28e400748bb 100644 --- a/icu4c/source/test/cintltst/usettest.c +++ b/icu4c/source/test/cintltst/usettest.c @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2002, International Business Machines +* Copyright (c) 2002-2003, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * $Source: /xsrl/Nsvn/icu/icu/source/test/cintltst/usettest.c,v $ @@ -12,10 +12,13 @@ #include #include +#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) + #define TEST(x) addTest(root, &x, "uset/" # x) static void TestAPI(void); static void Testj2269(void); +static void TestSerialized(void); void addUSetTest(TestNode** root); @@ -34,6 +37,7 @@ void addUSetTest(TestNode** root) { TEST(TestAPI); TEST(Testj2269); + TEST(TestSerialized); } /*------------------------------------------------------------------ @@ -362,4 +366,42 @@ static void expectItems(const USet* set, } } +static void +TestSerialized() { + uint16_t buffer[1000]; + USerializedSet sset; + USet *set; + UErrorCode errorCode; + UChar32 c; + int32_t length; + + /* use a pattern that generates both BMP and supplementary code points */ + U_STRING_DECL(pattern, "[:Cf:]", 6); + U_STRING_INIT(pattern, "[:Cf:]", 6); + + errorCode=U_ZERO_ERROR; + set=uset_openPattern(pattern, -1, &errorCode); + if(U_FAILURE(errorCode)) { + log_err("unable to uset_open([:Cf:]) - %s\n", u_errorName(errorCode)); + return; + } + + length=uset_serialize(set, buffer, LENGTHOF(buffer), &errorCode); + if(U_FAILURE(errorCode)) { + log_err("unable to uset_serialize([:Cf:]) - %s\n", u_errorName(errorCode)); + uset_close(set); + return; + } + + uset_getSerializedSet(&sset, buffer, length); + for(c=0; c<=0x10ffff; ++c) { + if(uset_contains(set, c)!=uset_serializedContains(&sset, c)) { + log_err("uset_contains(U+%04x)!=uset_serializedContains(U+%04x)\n", c); + break; + } + } + + uset_close(set); +} + /*eof*/ diff --git a/icu4c/source/test/intltest/normconf.cpp b/icu4c/source/test/intltest/normconf.cpp index 189160a9494..dbb469acd70 100644 --- a/icu4c/source/test/intltest/normconf.cpp +++ b/icu4c/source/test/intltest/normconf.cpp @@ -286,7 +286,7 @@ void NormalizerConformanceTest::TestConformance(FileStream *input, int32_t optio UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, const char *line, int32_t options) { - UBool pass = TRUE; + UBool pass = TRUE, result; UErrorCode status = U_ZERO_ERROR; UnicodeString out, fcd; int32_t fieldNum; @@ -342,7 +342,13 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field, pass = FALSE; } - if(!Normalizer::isNormalized(field[1], UNORM_NFC, options, status)) { + // branch on options==0 for better code coverage + if(options==0) { + result = Normalizer::isNormalized(field[1], UNORM_NFC, status); + } else { + result = Normalizer::isNormalized(field[1], UNORM_NFC, options, status); + } + if(!result) { errln("Normalizer error: isNormalized(NFC(s), UNORM_NFC) is FALSE"); pass = FALSE; }