164339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// Copyright (C) 2016 and later: Unicode, Inc. and others.
264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html
3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/********************************************************************
48393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * COPYRIGHT:
554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Copyright (c) 1997-2012, International Business Machines Corporation and
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * others. All Rights Reserved.
78393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * Copyright (C) 2010 , Yahoo! Inc.
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ********************************************************************/
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1027f654740f2a26ad62a5c155af9199af9e69b889claireho#include <stdio.h>
1127f654740f2a26ad62a5c155af9199af9e69b889claireho#include <string.h>
1254dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius#include "utypeinfo.h"  // for 'typeid' to work
1327f654740f2a26ad62a5c155af9199af9e69b889claireho
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uobjtest.h"
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cmemory.h" // UAlignedMemory
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Test for UObject, currently only the classID.
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Usage
2127f654740f2a26ad62a5c155af9199af9e69b889claireho *   TESTCLASSID_NONE_DEFAULT(Foo)
2227f654740f2a26ad62a5c155af9199af9e69b889claireho *      --  Foo is expected to not support "poor man's RTTI".
2327f654740f2a26ad62a5c155af9199af9e69b889claireho *          Beginning with ICU 4.6, we only use compiler RTTI in new class hierarchies.
2427f654740f2a26ad62a5c155af9199af9e69b889claireho *
2527f654740f2a26ad62a5c155af9199af9e69b889claireho *   TESTCLASSID_NONE_CTOR(Foo, (1, 2, 3, status))
2627f654740f2a26ad62a5c155af9199af9e69b889claireho *      -- Combines TESTCLASSID_NONE_DEFAULT() and TESTCLASSID_CTOR().
2727f654740f2a26ad62a5c155af9199af9e69b889claireho *
2827f654740f2a26ad62a5c155af9199af9e69b889claireho *   TESTCLASSID_NONE_FACTORY(Foo, (1, 2, 3, status))
2927f654740f2a26ad62a5c155af9199af9e69b889claireho *      -- Combines TESTCLASSID_NONE_DEFAULT() and TESTCLASSID_FACTORY().
3027f654740f2a26ad62a5c155af9199af9e69b889claireho *
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   TESTCLASSID_ABSTRACT(Bar)
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      --  Bar is expected to be abstract. Only the static ID will be tested.
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   TESTCLASSID_DEFAULT(Foo)
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      --  Foo will be default-constructed.
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   TESTCLASSID_CTOR(Foo, (1, 2, 3, status))
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      -- Second argument is (parenthesized) constructor argument.
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *          Will be called as:   new Foo ( 1, 2, 3, status)  [status is tested]
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   TESTCLASSID_FACTORY(Foo, fooCreateFunction(status) )
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      -- call fooCreateFunction.  'status' will be tested & reset
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *   TESTCLASSID_FACTORY_HIDDEN(class, factory)
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      -- call factory.  Class is not available from a header.
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *      'status' will be tested & reset. This only tests uniqueness.
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
4927f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_NONE_DEFAULT(c) \
5027f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClassNoClassID(new c, #c, "new " #c)
5127f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_NONE_CTOR(c, x) { \
5227f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClassNoClassID(new c x, #c, "new " #c #x); \
5327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
5427f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
5527f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
5627f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
5727f654740f2a26ad62a5c155af9199af9e69b889claireho}
5827f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_NONE_FACTORY(c, f) { \
5927f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClassNoClassID(f, #c, #f); \
6027f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
6127f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
6227f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
6327f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
6427f654740f2a26ad62a5c155af9199af9e69b889claireho}
6527f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_FACTORY(c, f) { \
6627f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClass(f, #c, #f, c ::getStaticClassID()); \
6727f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
6827f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
6927f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
7027f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
7127f654740f2a26ad62a5c155af9199af9e69b889claireho}
7227f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_TRANSLIT(c, t) { \
7327f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClass(Transliterator::createInstance(UnicodeString(t), UTRANS_FORWARD,parseError,status), #c, "Transliterator: " #t, c ::getStaticClassID()); \
7427f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
7527f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - Transliterator: " #t " - got err status ") + UnicodeString(u_errorName(status))); \
7627f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
7727f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
7827f654740f2a26ad62a5c155af9199af9e69b889claireho}
7927f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_CTOR(c, x) { \
8027f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClass(new c x, #c, "new " #c #x, c ::getStaticClassID()); \
8127f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
8227f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
8327f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
8427f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
8527f654740f2a26ad62a5c155af9199af9e69b889claireho}
8627f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_DEFAULT(c) \
8727f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClass(new c, #c, "new " #c , c::getStaticClassID())
8827f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_ABSTRACT(c) \
8927f654740f2a26ad62a5c155af9199af9e69b889claireho    testClass(NULL, #c, NULL, c::getStaticClassID())
9027f654740f2a26ad62a5c155af9199af9e69b889claireho#define TESTCLASSID_FACTORY_HIDDEN(c, f) { \
9127f654740f2a26ad62a5c155af9199af9e69b889claireho    UObject *objVar = f; \
9227f654740f2a26ad62a5c155af9199af9e69b889claireho    delete testClass(objVar, #c, #f, objVar!=NULL? objVar->getDynamicClassID(): NULL); \
9327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(status)) { \
9427f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln(UnicodeString(#c " - " #f " - got err status ")  + UnicodeString(u_errorName(status))); \
9527f654740f2a26ad62a5c155af9199af9e69b889claireho        status = U_ZERO_ERROR; \
9627f654740f2a26ad62a5c155af9199af9e69b889claireho    } \
9727f654740f2a26ad62a5c155af9199af9e69b889claireho}
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define MAX_CLASS_ID 200
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic UClassID    ids[MAX_CLASS_ID];
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const char *ids_factory[MAX_CLASS_ID];
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const char *ids_class[MAX_CLASS_ID];
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic uint32_t    ids_count = 0;
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUObject *UObjectTest::testClass(UObject *obj,
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                const char *className, const char *factory,
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UClassID staticID)
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint32_t i;
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString what = UnicodeString(className) + " * x= " + UnicodeString(factory?factory:" ABSTRACT ") + "; ";
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UClassID dynamicID = NULL;
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(ids_count >= MAX_CLASS_ID) {
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char count[100];
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        sprintf(count, " (currently %d) ", MAX_CLASS_ID);
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: Fatal: Ran out of IDs! Increase MAX_CLASS_ID." + UnicodeString(count) + what);
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return obj;
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(obj) {
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        dynamicID = obj->getDynamicClassID();
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char tmp[500];
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        sprintf(tmp, " [static=%p, dynamic=%p] ", staticID, dynamicID);
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(what + tmp);
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(staticID == NULL) {
1326d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln("FAIL: staticID == NULL! " + what);
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(factory != NULL) {  /* NULL factory means: abstract */
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!obj) {
1376d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln( "FAIL: ==NULL! " + what);
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return obj;
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(dynamicID == NULL) {
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            errln("FAIL: dynamicID == NULL!" + what);
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(dynamicID != staticID) {
1466d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("FAIL: dynamicID != staticID! " + what);
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Bail out if static ID is null. Error message was already printed.
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(staticID == NULL) {
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return obj;
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(i=0;i<ids_count;i++) {
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(staticID == ids[i]) {
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if(!strcmp(ids_class[i], className)) {
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                logln("OK: ID found is the same as " + UnicodeString(ids_class[i]) + UnicodeString(" *y= ") + ids_factory[i] + what);
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                return obj;
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errln("FAIL: ID is the same as " + UnicodeString(ids_class[i]) + UnicodeString(" *y= ") + ids_factory[i] + what);
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                return obj;
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ids[ids_count] = staticID;
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ids_factory[ids_count] = factory;
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ids_class[ids_count] = className;
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ids_count++;
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return obj;
173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17527f654740f2a26ad62a5c155af9199af9e69b889clairehoUObject *UObjectTest::testClassNoClassID(UObject *obj, const char *className, const char *factory)
17627f654740f2a26ad62a5c155af9199af9e69b889claireho{
17727f654740f2a26ad62a5c155af9199af9e69b889claireho    if (!obj) {
17827f654740f2a26ad62a5c155af9199af9e69b889claireho        return NULL;
17927f654740f2a26ad62a5c155af9199af9e69b889claireho    }
18027f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString what = UnicodeString(className) + " * x= " + UnicodeString(factory?factory:" ABSTRACT ") + "; ";
18127f654740f2a26ad62a5c155af9199af9e69b889claireho    UClassID dynamicID = obj->getDynamicClassID();
18227f654740f2a26ad62a5c155af9199af9e69b889claireho
18327f654740f2a26ad62a5c155af9199af9e69b889claireho    {
18427f654740f2a26ad62a5c155af9199af9e69b889claireho        char tmp[500];
18527f654740f2a26ad62a5c155af9199af9e69b889claireho        sprintf(tmp, " [dynamic=%p] ", dynamicID);
18627f654740f2a26ad62a5c155af9199af9e69b889claireho        logln(what + tmp);
18727f654740f2a26ad62a5c155af9199af9e69b889claireho    }
18827f654740f2a26ad62a5c155af9199af9e69b889claireho
18927f654740f2a26ad62a5c155af9199af9e69b889claireho    if(factory != NULL) {  /* NULL factory means: abstract */
19027f654740f2a26ad62a5c155af9199af9e69b889claireho        if(!obj) {
19127f654740f2a26ad62a5c155af9199af9e69b889claireho            dataerrln( "FAIL: ==NULL! " + what);
19227f654740f2a26ad62a5c155af9199af9e69b889claireho            return obj;
19327f654740f2a26ad62a5c155af9199af9e69b889claireho        }
19427f654740f2a26ad62a5c155af9199af9e69b889claireho
19527f654740f2a26ad62a5c155af9199af9e69b889claireho        if(dynamicID != NULL) {
19627f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("FAIL: dynamicID != NULL! for non-poor-man's-RTTI " + what);
19727f654740f2a26ad62a5c155af9199af9e69b889claireho        }
19827f654740f2a26ad62a5c155af9199af9e69b889claireho    }
19927f654740f2a26ad62a5c155af9199af9e69b889claireho
20027f654740f2a26ad62a5c155af9199af9e69b889claireho    return obj;
20127f654740f2a26ad62a5c155af9199af9e69b889claireho}
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// begin actual #includes for things to be tested
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// The following script will generate the #includes needed here:
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//    find common i18n -name '*.h' -print | xargs fgrep ClassID | cut -d: -f1 | cut -d\/ -f2-  | sort | uniq | sed -e 's%.*%#include "&"%'
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Internal Things (woo)
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cpdtrans.h"
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "rbt.h"
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "rbt_data.h"
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "nultrans.h"
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "anytrans.h"
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "digitlst.h"
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "esctrn.h"
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "funcrepl.h"
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "servnotf.h"
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "serv.h"
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "servloc.h"
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "name2uni.h"
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "nfsubs.h"
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "nortrans.h"
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "quant.h"
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "remtrans.h"
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "strmatch.h"
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "strrepl.h"
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "titletrn.h"
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "tolowtrn.h"
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "toupptrn.h"
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unesctrn.h"
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uni2name.h"
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uvector.h"
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uvectr32.h"
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "currfmt.h"
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "buddhcal.h"
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "islamcal.h"
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "japancal.h"
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "hebrwcal.h"
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "persncal.h"
244c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "taiwncal.h"
245c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "indiancal.h"
246c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "chnsecal.h"
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "windtfmt.h"
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "winnmfmt.h"
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ustrenum.h"
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "olsontz.h"
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "reldtfmt.h"
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// External Things
254b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/appendable.h"
255b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/alphaindex.h"
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/brkiter.h"
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/calendar.h"
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/caniter.h"
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/chariter.h"
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/choicfmt.h"
261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/coleitr.h"
262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/coll.h"
263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/curramt.h"
264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/datefmt.h"
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/dcfmtsym.h"
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/decimfmt.h"
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/dtfmtsym.h"
268c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "unicode/dtptngen.h"
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/fieldpos.h"
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/fmtable.h"
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/format.h"
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/gregocal.h"
27327f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/idna.h"
27427f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/locdspnm.h"
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/locid.h"
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/msgfmt.h"
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/normlzr.h"
27827f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/normalizer2.h"
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/numfmt.h"
280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/parsepos.h"
281c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "unicode/plurrule.h"
282c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru#include "unicode/plurfmt.h"
28350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#include "unicode/selfmt.h"
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/rbbi.h"
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/rbnf.h"
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/regex.h"
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/resbund.h"
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/schriter.h"
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/simpletz.h"
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/smpdtfmt.h"
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/sortkey.h"
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/stsearch.h"
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/tblcoll.h"
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/timezone.h"
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/translit.h"
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uchriter.h"
297b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "unicode/uloc.h"
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/unifilt.h"
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/unifunct.h"
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uniset.h"
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/unistr.h"
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uobject.h"
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/usetiter.h"
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//#include "unicode/bidi.h"
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//#include "unicode/convert.h"
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// END includes =============================================================
308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UOBJTEST_TEST_INTERNALS 0   /* do NOT test Internal things - their functions aren't exported on Win32 */
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_SERVICE
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* The whole purpose of this class is to expose the constructor, and gain access to the superclasses RTTI. */
313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass TestLocaleKeyFactory : public LocaleKeyFactory {
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TestLocaleKeyFactory(int32_t coverage) : LocaleKeyFactory(coverage) {}
316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
319b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho// Appendable is abstract; we define a subclass to verify that there is no "poor man's RTTI".
320b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehoclass DummyAppendable : public Appendable {
321b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehopublic:
322b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    virtual UBool appendCodeUnit(UChar /*c*/) { return TRUE; }
323b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho};
324b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid UObjectTest::testIDs()
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ids_count = 0;
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
3308393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    TESTCLASSID_NONE_CTOR(UObject, ());
3318393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_TRANSLITERATION || !UCONFIG_NO_FORMATTING
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UParseError parseError;
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_NORMALIZATION
33827f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString emptyString;
33927f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCLASSID_CTOR(Normalizer, (emptyString, UNORM_NONE));
34027f654740f2a26ad62a5c155af9199af9e69b889claireho    const Normalizer2 *noNormalizer2 = NULL;
34127f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeSet emptySet;
34227f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCLASSID_NONE_CTOR(FilteredNormalizer2, (*noNormalizer2, emptySet));
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(CanonicalIterator, new CanonicalIterator(UnicodeString("abc"), status));
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
34527f654740f2a26ad62a5c155af9199af9e69b889claireho#if !UCONFIG_NO_IDNA
34627f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCLASSID_NONE_FACTORY(IDNA, IDNA::createUTS46Instance(0, status));
34727f654740f2a26ad62a5c155af9199af9e69b889claireho#endif
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(CollationElementIterator);
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_COLLATION
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(CollationKey);
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(UStringEnumeration, Collator::getKeywords(status));
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_FACTORY_HIDDEN(CollationLocaleListEnumeration, Collator::getAvailableLocales());
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_FACTORY(CompoundTransliterator, Transliterator::createInstance(UnicodeString("Any-Jex;Hangul-Jamo"), UTRANS_FORWARD, parseError, status));
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* TESTCLASSID_FACTORY(NFSubstitution,  NFSubstitution::makeSubstitution(8, */
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* TESTCLASSID_DEFAULT(DigitList);  UMemory but not UObject*/
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(NumberFormat);
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(RuleBasedNumberFormat, (UnicodeString("%default: -x: minus >>;"), parseError, status));
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(ChoiceFormat, (UNICODE_STRING_SIMPLE("0#are no files|1#is one file|1<are many files"), status));
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(MessageFormat, (UnicodeString(), status));
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(DateFormatSymbols, (status));
364c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_CTOR(PluralFormat, (status));
365c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_CTOR(PluralRules, (status));
36650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    TESTCLASSID_CTOR(SelectFormat, (UnicodeString("feminine {feminineVerbValue} other{otherVerbValue}"), status) );
367c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_FACTORY(DateTimePatternGenerator, DateTimePatternGenerator::createInstance(status));
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(RelativeDateFormat, DateFormat::createDateInstance(DateFormat::kFullRelative, Locale::getUS()));
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(DecimalFormatSymbols, (status));
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(FieldPosition);
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(Formattable);
372b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
373b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    static const UChar SMALL_STR[] = {0x51, 0x51, 0x51, 0}; // "QQQ"
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(CurrencyAmount, (1.0, SMALL_STR, status));
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(CurrencyUnit, (SMALL_STR, status));
37627f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCLASSID_NONE_FACTORY(LocaleDisplayNames, LocaleDisplayNames::createInstance("de"));
377c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_FACTORY_HIDDEN(CurrencyFormat, MeasureFormat::createCurrencyFormat(Locale::getUS(), status));
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(GregorianCalendar, Calendar::createInstance(Locale("@calendar=gregorian"), status));
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(BuddhistCalendar, Calendar::createInstance(Locale("@calendar=buddhist"), status));
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(IslamicCalendar, Calendar::createInstance(Locale("@calendar=islamic"), status));
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(JapaneseCalendar, Calendar::createInstance(Locale("@calendar=japanese"), status));
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(HebrewCalendar, Calendar::createInstance(Locale("@calendar=hebrew"), status));
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(PersianCalendar, Calendar::createInstance(Locale("@calendar=persian"), status));
384c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_FACTORY(IndianCalendar, Calendar::createInstance(Locale("@calendar=indian"), status));
385c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_FACTORY(ChineseCalendar, Calendar::createInstance(Locale("@calendar=chinese"), status));
386c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_FACTORY(TaiwanCalendar, Calendar::createInstance(Locale("@calendar=roc"), status));
387103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#if U_PLATFORM_HAS_WIN32_API
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(Win32DateFormat, DateFormat::createDateInstance(DateFormat::kFull, Locale("@compat=host")));
389103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#if U_PLATFORM_USES_ONLY_WIN32_API
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(Win32NumberFormat, NumberFormat::createInstance(Locale("@compat=host"), status));
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
393103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
39550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* TESTCLASSID_ABSTRACT(BreakIterator); No staticID!  */
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(RuleBasedBreakIterator, BreakIterator::createLineInstance("mt",status));
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_FACTORY(DictionaryBasedBreakIterator, BreakIterator::createLineInstance("th",status));
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_SERVICE
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY_HIDDEN(ICULocaleService, BreakIterator::getAvailableLocales());
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(GregorianCalendar);
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_TRANSLITERATION
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(AnyTransliterator, "Any-Latin");
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(CompoundTransliterator, "Latin-Greek");
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(EscapeTransliterator, "Any-Hex");
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(LowercaseTransliterator, "Lower");
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(NameUnicodeTransliterator, "Name-Any");
413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(NormalizationTransliterator, "NFD");
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(NullTransliterator, "Null");
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(RemoveTransliterator, "Remove");
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(RuleBasedTransliterator, Transliterator::createFromRules(UnicodeString("abcd"),UnicodeString("a>b;"),UTRANS_FORWARD,parseError,status));
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(TitlecaseTransliterator, "Title");
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(UnescapeTransliterator, "Hex-Any");
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(UnicodeNameTransliterator, "Any-Name");
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_TRANSLIT(UppercaseTransliterator, "Upper");
421c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(CaseMapTransliterator);
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(Transliterator);
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY_HIDDEN(TransliteratorRegistry::Enumeration, Transliterator::getAvailableIDs(status));
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if UOBJTEST_TEST_INTERNALS
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(Quantifier, (NULL, 0, 0));
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(FunctionReplacer, (NULL,NULL));
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(StringMatcher, (UnicodeString("x"), 0,0,0,TransliterationRuleData(status)));
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(StringReplacer,(UnicodeString(),new TransliterationRuleData(status)));
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(Locale, new Locale("123"));
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration, Locale("@a=b").createKeywords(status));
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(NumeratorSubstitution);
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_TRANSLITERATION
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(ParsePosition);
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// NO_REG_EX
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(RegexCompile);
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(RegexMatcher);
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(RegexPattern);
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(ReplaceableGlue);
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(ResourceBundle, new ResourceBundle(UnicodeString(), status) );
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(RuleBasedTransliterator);
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(SimpleFwdCharIterator);
453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(StringReplacer);
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(StringSearch);
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(TestMultipleKeyStringFactory);
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(TestReplaceable);
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(TimeZone);
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(OlsonTimeZone, TimeZone::createTimeZone(UnicodeString("America/Los_Angeles")));
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration, TimeZone::createEnumeration());
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
464b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
465b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    TESTCLASSID_NONE_DEFAULT(DummyAppendable);
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(UnicodeString);
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(UnicodeSet, (0, 1));
468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(UnicodeFilter);
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_ABSTRACT(UnicodeFunctor);
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(UnicodeSetIterator,(UnicodeSet(0,1)));
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(UStack, (status));
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(UVector, (status));
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(UVector32, (status));
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_SERVICE
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(SimpleFactory, (NULL, UnicodeString("foo")));
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(EventListener);
478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_DEFAULT(ICUResourceBundleFactory);
479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //TESTCLASSID_DEFAULT(Key); // does not exist?
480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString baz("baz");
481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString bat("bat");
482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_FACTORY(LocaleKey, LocaleKey::createWithCanonicalFallback(&baz, &bat, LocaleKey::KIND_ANY, status));
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(SimpleLocaleKeyFactory, (NULL, UnicodeString("bar"), 8, 12) );
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    TESTCLASSID_CTOR(TestLocaleKeyFactory, (42));   // Test replacement for LocaleKeyFactory
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//#if UOBJTEST_TEST_INTERNALS
486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//    TESTCLASSID_CTOR(LocaleKeyFactory, (42));
487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//#endif
488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
489103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius
490103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION
491b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    TESTCLASSID_NONE_CTOR(AlphabeticIndex, (Locale::getEnglish(), status));
492103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if UOBJTEST_DUMP_IDS
495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int i;
496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for(i=0;i<ids_count;i++) {
497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char junk[800];
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        sprintf(junk, " %4d:\t%p\t%s\t%s\n",
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            i, ids[i], ids_class[i], ids_factory[i]);
500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(UnicodeString(junk));
501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid UObjectTest::testUMemory() {
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // additional tests for code coverage
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if U_OVERRIDE_CXX_ALLOCATION && U_HAVE_PLACEMENT_NEW
50827f654740f2a26ad62a5c155af9199af9e69b889claireho    union {
50927f654740f2a26ad62a5c155af9199af9e69b889claireho        UAlignedMemory   align_;
51027f654740f2a26ad62a5c155af9199af9e69b889claireho        char             bytes_[sizeof(UnicodeString)];
51127f654740f2a26ad62a5c155af9199af9e69b889claireho    } stackMemory;
51227f654740f2a26ad62a5c155af9199af9e69b889claireho    char *bytes = stackMemory.bytes_;
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString *p;
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum { len=20 };
515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
51627f654740f2a26ad62a5c155af9199af9e69b889claireho    p=new(bytes) UnicodeString(len, (UChar32)0x20ac, len);
51727f654740f2a26ad62a5c155af9199af9e69b889claireho    if((void *)p!=(void *)bytes) {
518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("placement new did not place the object at the expected address");
519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(p->length()!=len || p->charAt(0)!=0x20ac || p->charAt(len-1)!=0x20ac) {
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("constructor used with placement new did not work right");
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * It is not possible to simply say
526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     delete(p, stackMemory);
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * which results in a call to the normal, non-placement delete operator.
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * Via a search on google.com for "c++ placement delete" I found
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * http://cpptips.hyperformix.com/cpptips/placement_del3
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * which says:
532b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * TITLE: using placement delete
534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * (Newsgroups: comp.std.c++, 27 Aug 97)
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ISJ: isj@image.dk
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * > I do not completely understand how placement works on operator delete.
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * > ...
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * There is no delete-expression which will invoke a placement
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * form of operator delete. You can still call the function
543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * explicitly. Example:
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ...
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     // destroy object and delete space manually
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     p->~T();
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *     operator delete(p, 12);
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * ... so that's what I am doing here.
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     * markus 20031216
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // destroy object and delete space manually
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    p->~UnicodeString();
55427f654740f2a26ad62a5c155af9199af9e69b889claireho
55527f654740f2a26ad62a5c155af9199af9e69b889claireho    // You normally wouldn't call an operator delete for object placed on the
55627f654740f2a26ad62a5c155af9199af9e69b889claireho    // stack with a placement new().
55727f654740f2a26ad62a5c155af9199af9e69b889claireho    // This overload of delete is a nop, and is called here for code coverage purposes.
55827f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString::operator delete(p, bytes);
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Jitterbug 4452, for coverage
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString *pa = new UnicodeString[2];
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if ( !pa[0].isEmpty() || !pa[1].isEmpty()){
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("constructor used with array new did not work right");
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    delete [] pa;
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // try to call the compiler-generated UMemory::operator=(class UMemory const &)
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UMemory m, n;
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    m=n;
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid UObjectTest::TestMFCCompatibility() {
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if U_HAVE_DEBUG_LOCATION_NEW
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* Make sure that it compiles with MFC's debuggable new usage. */
576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString *str = new(__FILE__, __LINE__) UnicodeString();
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    str->append((UChar)0x0040); // Is it usable?
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(str->charAt(0) != 0x0040) {
579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("debug new doesn't work.");
580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString::operator delete(str, __FILE__, __LINE__);
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
58527f654740f2a26ad62a5c155af9199af9e69b889clairehovoid UObjectTest::TestCompilerRTTI() {
586b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#if !UCONFIG_NO_FORMATTING
58727f654740f2a26ad62a5c155af9199af9e69b889claireho    UErrorCode errorCode = U_ZERO_ERROR;
58827f654740f2a26ad62a5c155af9199af9e69b889claireho    NumberFormat *nf = NumberFormat::createInstance("de", errorCode);
58927f654740f2a26ad62a5c155af9199af9e69b889claireho    if (U_FAILURE(errorCode)) {
59027f654740f2a26ad62a5c155af9199af9e69b889claireho        dataerrln("NumberFormat::createInstance(de) failed - %s", u_errorName(errorCode));
59127f654740f2a26ad62a5c155af9199af9e69b889claireho        return;
59227f654740f2a26ad62a5c155af9199af9e69b889claireho    }
59327f654740f2a26ad62a5c155af9199af9e69b889claireho    if (dynamic_cast<DecimalFormat *>(nf) == NULL || dynamic_cast<ChoiceFormat *>(nf) != NULL) {
59427f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("dynamic_cast<>(NumberFormat) failed");
59527f654740f2a26ad62a5c155af9199af9e69b889claireho    }
59627f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeSet emptySet;
59727f654740f2a26ad62a5c155af9199af9e69b889claireho    if (&typeid(*nf) == NULL || typeid(*nf) == typeid(UObject) || typeid(*nf) == typeid(Format) ||
59827f654740f2a26ad62a5c155af9199af9e69b889claireho        typeid(*nf) != typeid(DecimalFormat) || typeid(*nf) == typeid(ChoiceFormat) ||
59927f654740f2a26ad62a5c155af9199af9e69b889claireho        typeid(*nf) == typeid(emptySet)
60027f654740f2a26ad62a5c155af9199af9e69b889claireho    ) {
60127f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("typeid(NumberFormat) failed");
60227f654740f2a26ad62a5c155af9199af9e69b889claireho    }
60327f654740f2a26ad62a5c155af9199af9e69b889claireho    delete nf;
604b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#endif
60527f654740f2a26ad62a5c155af9199af9e69b889claireho}
606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
60727f654740f2a26ad62a5c155af9199af9e69b889claireho/* --------------- */
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid UObjectTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /* par */ )
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (index) {
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
61327f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE(0, testIDs);
61427f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE(1, testUMemory);
61527f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE(2, TestMFCCompatibility);
61627f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE(3, TestCompilerRTTI);
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    default: name = ""; break; //needed to end loop
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
621