X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..374ca955a76ecab1204ca8bfa63ff9238d998416:/icuSources/test/intltest/uobjtest.cpp diff --git a/icuSources/test/intltest/uobjtest.cpp b/icuSources/test/intltest/uobjtest.cpp index 8607c025..8354871c 100644 --- a/icuSources/test/intltest/uobjtest.cpp +++ b/icuSources/test/intltest/uobjtest.cpp @@ -1,11 +1,13 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2002-2003, International Business Machines Corporation and + * Copyright (c) 2002-2004, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "uobjtest.h" +#include "cmemory.h" // UAlignedMemory #include +#include /** * @@ -41,8 +43,8 @@ const char *ids_class[MAX_CLASS_ID]; uint32_t ids_count = 0; UObject *UObjectTest::testClass(UObject *obj, - const char *className, const char *factory, - UClassID staticID) + const char *className, const char *factory, + UClassID staticID) { uint32_t i; UnicodeString what = UnicodeString(className) + " * x= " + UnicodeString(factory?factory:" ABSTRACT ") + "; "; @@ -92,11 +94,11 @@ UObject *UObjectTest::testClass(UObject *obj, for(i=0;ilength()!=len || p->charAt(0)!=0x20ac || p->charAt(len-1)!=0x20ac) { + errln("constructor used with placement new did not work right"); + } + + /* + * It is not possible to simply say + * delete(p, stackMemory); + * which results in a call to the normal, non-placement delete operator. + * + * Via a search on google.com for "c++ placement delete" I found + * http://cpptips.hyperformix.com/cpptips/placement_del3 + * which says: + * + * TITLE: using placement delete + * + * (Newsgroups: comp.std.c++, 27 Aug 97) + * + * ISJ: isj@image.dk + * + * > I do not completely understand how placement works on operator delete. + * > ... + * There is no delete-expression which will invoke a placement + * form of operator delete. You can still call the function + * explicitly. Example: + * ... + * // destroy object and delete space manually + * p->~T(); + * operator delete(p, 12); + * + * ... so that's what I am doing here. + * markus 20031216 + */ + // destroy object and delete space manually + p->~UnicodeString(); + UnicodeString::operator delete(p, stackMemory); +#endif + + // try to call the compiler-generated UMemory::operator=(class UMemory const &) + UMemory m, n; + m=n; +} + /* --------------- */ #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break; @@ -350,6 +404,7 @@ void UObjectTest::runIndexedTest( int32_t index, UBool exec, const char* &name, switch (index) { CASE(0, testIDs); + CASE(1, testUMemory); default: name = ""; break; //needed to end loop }