/******************************************************************** * COPYRIGHT: * Copyright (c) 2002, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "uobjtest.h" #include #define TESTCLASSID_FACTORY(c, f) { delete testClass(f, #c, #f, c ::getStaticClassID()); if(U_FAILURE(status)) { errln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); status = U_ZERO_ERROR; } } #define TESTCLASSID_DEFAULT(c) delete testClass(new c, #c, "new " #c , c::getStaticClassID()) #define TESTCLASSID_ABSTRACT(c) testClass(NULL, #c, NULL, c::getStaticClassID()) #define MAX_CLASS_ID 100 UClassID ids[MAX_CLASS_ID]; const char *ids_factory[MAX_CLASS_ID]; 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) { uint32_t i; UnicodeString what = UnicodeString(className) + " * x= " + UnicodeString(factory?factory:" ABSTRACT ") + "; "; UClassID dynamicID = NULL; if(ids_count >= MAX_CLASS_ID) { char count[100]; sprintf(count, " (currently %d) ", MAX_CLASS_ID); errln(what + "FAIL: Fatal: Ran out of IDs! Increase MAX_CLASS_ID." + UnicodeString(count)); return obj; } { char tmp[500]; sprintf(tmp, " [static=0x%p] ", staticID); logln(what + tmp); } if(staticID == NULL) { errln( what + "FAIL: staticID == NULL!"); } if(factory != NULL) { /* NULL factory means: abstract */ if(!obj) { errln( what + "FAIL: ==NULL!"); return obj; } dynamicID = obj->getDynamicClassID(); if(dynamicID == NULL) { errln(what + "FAIL: dynamicID == NULL!"); } if(dynamicID != staticID) { errln(what + "FAIL: dynamicID != staticID!"); } } // Bail out if static ID is null if(staticID == NULL) { return obj; } for(i=0;i