1 /********************************************************************
3 * Copyright (c) 1997-2010, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 * Copyright (C) 2010 , Yahoo! Inc.
6 ********************************************************************/
10 #include <typeinfo> // for 'typeid' to work
13 #include "cmemory.h" // UAlignedMemory
16 * Test for UObject, currently only the classID.
19 * TESTCLASSID_NONE_DEFAULT(Foo)
20 * -- Foo is expected to not support "poor man's RTTI".
21 * Beginning with ICU 4.6, we only use compiler RTTI in new class hierarchies.
23 * TESTCLASSID_NONE_CTOR(Foo, (1, 2, 3, status))
24 * -- Combines TESTCLASSID_NONE_DEFAULT() and TESTCLASSID_CTOR().
26 * TESTCLASSID_NONE_FACTORY(Foo, (1, 2, 3, status))
27 * -- Combines TESTCLASSID_NONE_DEFAULT() and TESTCLASSID_FACTORY().
29 * TESTCLASSID_ABSTRACT(Bar)
30 * -- Bar is expected to be abstract. Only the static ID will be tested.
32 * TESTCLASSID_DEFAULT(Foo)
33 * -- Foo will be default-constructed.
35 * TESTCLASSID_CTOR(Foo, (1, 2, 3, status))
36 * -- Second argument is (parenthesized) constructor argument.
37 * Will be called as: new Foo ( 1, 2, 3, status) [status is tested]
39 * TESTCLASSID_FACTORY(Foo, fooCreateFunction(status) )
40 * -- call fooCreateFunction. 'status' will be tested & reset
42 * TESTCLASSID_FACTORY_HIDDEN(class, factory)
43 * -- call factory. Class is not available from a header.
44 * 'status' will be tested & reset. This only tests uniqueness.
47 #define TESTCLASSID_NONE_DEFAULT(c) \
48 delete testClassNoClassID(new c, #c, "new " #c)
49 #define TESTCLASSID_NONE_CTOR(c, x) { \
50 delete testClassNoClassID(new c x, #c, "new " #c #x); \
51 if(U_FAILURE(status)) { \
52 dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
53 status = U_ZERO_ERROR; \
56 #define TESTCLASSID_NONE_FACTORY(c, f) { \
57 delete testClassNoClassID(f, #c, #f); \
58 if(U_FAILURE(status)) { \
59 dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
60 status = U_ZERO_ERROR; \
63 #define TESTCLASSID_FACTORY(c, f) { \
64 delete testClass(f, #c, #f, c ::getStaticClassID()); \
65 if(U_FAILURE(status)) { \
66 dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
67 status = U_ZERO_ERROR; \
70 #define TESTCLASSID_TRANSLIT(c, t) { \
71 delete testClass(Transliterator::createInstance(UnicodeString(t), UTRANS_FORWARD,parseError,status), #c, "Transliterator: " #t, c ::getStaticClassID()); \
72 if(U_FAILURE(status)) { \
73 dataerrln(UnicodeString(#c " - Transliterator: " #t " - got err status ") + UnicodeString(u_errorName(status))); \
74 status = U_ZERO_ERROR; \
77 #define TESTCLASSID_CTOR(c, x) { \
78 delete testClass(new c x, #c, "new " #c #x, c ::getStaticClassID()); \
79 if(U_FAILURE(status)) { \
80 dataerrln(UnicodeString(#c " - new " #x " - got err status ") + UnicodeString(u_errorName(status))); \
81 status = U_ZERO_ERROR; \
84 #define TESTCLASSID_DEFAULT(c) \
85 delete testClass(new c, #c, "new " #c , c::getStaticClassID())
86 #define TESTCLASSID_ABSTRACT(c) \
87 testClass(NULL, #c, NULL, c::getStaticClassID())
88 #define TESTCLASSID_FACTORY_HIDDEN(c, f) { \
89 UObject *objVar = f; \
90 delete testClass(objVar, #c, #f, objVar!=NULL? objVar->getDynamicClassID(): NULL); \
91 if(U_FAILURE(status)) { \
92 dataerrln(UnicodeString(#c " - " #f " - got err status ") + UnicodeString(u_errorName(status))); \
93 status = U_ZERO_ERROR; \
97 #define MAX_CLASS_ID 200
99 static UClassID ids
[MAX_CLASS_ID
];
100 static const char *ids_factory
[MAX_CLASS_ID
];
101 static const char *ids_class
[MAX_CLASS_ID
];
102 static uint32_t ids_count
= 0;
104 UObject
*UObjectTest::testClass(UObject
*obj
,
105 const char *className
, const char *factory
,
109 UnicodeString what
= UnicodeString(className
) + " * x= " + UnicodeString(factory
?factory
:" ABSTRACT ") + "; ";
110 UClassID dynamicID
= NULL
;
112 if(ids_count
>= MAX_CLASS_ID
) {
114 sprintf(count
, " (currently %d) ", MAX_CLASS_ID
);
115 errln("FAIL: Fatal: Ran out of IDs! Increase MAX_CLASS_ID." + UnicodeString(count
) + what
);
120 dynamicID
= obj
->getDynamicClassID();
125 sprintf(tmp
, " [static=%p, dynamic=%p] ", staticID
, dynamicID
);
129 if(staticID
== NULL
) {
130 dataerrln("FAIL: staticID == NULL! " + what
);
133 if(factory
!= NULL
) { /* NULL factory means: abstract */
135 dataerrln( "FAIL: ==NULL! " + what
);
139 if(dynamicID
== NULL
) {
140 errln("FAIL: dynamicID == NULL!" + what
);
143 if(dynamicID
!= staticID
) {
144 dataerrln("FAIL: dynamicID != staticID! " + what
);
148 // Bail out if static ID is null. Error message was already printed.
149 if(staticID
== NULL
) {
153 for(i
=0;i
<ids_count
;i
++) {
154 if(staticID
== ids
[i
]) {
155 if(!strcmp(ids_class
[i
], className
)) {
156 logln("OK: ID found is the same as " + UnicodeString(ids_class
[i
]) + UnicodeString(" *y= ") + ids_factory
[i
] + what
);
159 errln("FAIL: ID is the same as " + UnicodeString(ids_class
[i
]) + UnicodeString(" *y= ") + ids_factory
[i
] + what
);
165 ids
[ids_count
] = staticID
;
166 ids_factory
[ids_count
] = factory
;
167 ids_class
[ids_count
] = className
;
173 UObject
*UObjectTest::testClassNoClassID(UObject
*obj
, const char *className
, const char *factory
)
178 UnicodeString what
= UnicodeString(className
) + " * x= " + UnicodeString(factory
?factory
:" ABSTRACT ") + "; ";
179 UClassID dynamicID
= obj
->getDynamicClassID();
183 sprintf(tmp
, " [dynamic=%p] ", dynamicID
);
187 if(factory
!= NULL
) { /* NULL factory means: abstract */
189 dataerrln( "FAIL: ==NULL! " + what
);
193 if(dynamicID
!= NULL
) {
194 errln("FAIL: dynamicID != NULL! for non-poor-man's-RTTI " + what
);
201 // begin actual #includes for things to be tested
203 // The following script will generate the #includes needed here:
205 // find common i18n -name '*.h' -print | xargs fgrep ClassID | cut -d: -f1 | cut -d\/ -f2- | sort | uniq | sed -e 's%.*%#include "&"%'
208 #include "unicode/utypes.h"
210 // Internal Things (woo)
211 #include "cpdtrans.h"
213 #include "rbt_data.h"
214 #include "nultrans.h"
215 #include "anytrans.h"
216 #include "digitlst.h"
218 #include "funcrepl.h"
219 #include "servnotf.h"
222 #include "name2uni.h"
224 #include "nortrans.h"
226 #include "remtrans.h"
227 #include "strmatch.h"
229 #include "titletrn.h"
230 #include "tolowtrn.h"
231 #include "toupptrn.h"
232 #include "unesctrn.h"
233 #include "uni2name.h"
235 #include "uvectr32.h"
237 #include "buddhcal.h"
238 #include "islamcal.h"
239 #include "japancal.h"
240 #include "hebrwcal.h"
241 #include "persncal.h"
242 #include "taiwncal.h"
243 #include "indiancal.h"
244 #include "chnsecal.h"
245 #include "windtfmt.h"
246 #include "winnmfmt.h"
247 #include "ustrenum.h"
249 #include "reldtfmt.h"
252 #include "unicode/brkiter.h"
253 #include "unicode/calendar.h"
254 #include "unicode/caniter.h"
255 #include "unicode/chariter.h"
256 #include "unicode/choicfmt.h"
257 #include "unicode/coleitr.h"
258 #include "unicode/coll.h"
259 #include "unicode/curramt.h"
260 #include "unicode/datefmt.h"
261 #include "unicode/dcfmtsym.h"
262 #include "unicode/decimfmt.h"
263 #include "unicode/dtfmtsym.h"
264 #include "unicode/dtptngen.h"
265 #include "unicode/fieldpos.h"
266 #include "unicode/fmtable.h"
267 #include "unicode/format.h"
268 #include "unicode/gregocal.h"
269 #include "unicode/idna.h"
270 #include "unicode/locdspnm.h"
271 #include "unicode/locid.h"
272 #include "unicode/msgfmt.h"
273 #include "unicode/normlzr.h"
274 #include "unicode/normalizer2.h"
275 #include "unicode/numfmt.h"
276 #include "unicode/parsepos.h"
277 #include "unicode/plurrule.h"
278 #include "unicode/plurfmt.h"
279 #include "unicode/selfmt.h"
280 #include "unicode/rbbi.h"
281 #include "unicode/rbnf.h"
282 #include "unicode/regex.h"
283 #include "unicode/resbund.h"
284 #include "unicode/schriter.h"
285 #include "unicode/simpletz.h"
286 #include "unicode/smpdtfmt.h"
287 #include "unicode/sortkey.h"
288 #include "unicode/stsearch.h"
289 #include "unicode/tblcoll.h"
290 #include "unicode/timezone.h"
291 #include "unicode/translit.h"
292 #include "unicode/uchriter.h"
293 #include "unicode/unifilt.h"
294 #include "unicode/unifunct.h"
295 #include "unicode/uniset.h"
296 #include "unicode/unistr.h"
297 #include "unicode/uobject.h"
298 #include "unicode/usetiter.h"
299 //#include "unicode/bidi.h"
300 //#include "unicode/convert.h"
302 // END includes =============================================================
304 #define UOBJTEST_TEST_INTERNALS 0 /* do NOT test Internal things - their functions aren't exported on Win32 */
306 #if !UCONFIG_NO_SERVICE
307 /* The whole purpose of this class is to expose the constructor, and gain access to the superclasses RTTI. */
308 class TestLocaleKeyFactory
: public LocaleKeyFactory
{
310 TestLocaleKeyFactory(int32_t coverage
) : LocaleKeyFactory(coverage
) {}
314 void UObjectTest::testIDs()
317 UErrorCode status
= U_ZERO_ERROR
;
318 static const UChar SMALL_STR
[] = {0x51, 0x51, 0x51, 0}; // "QQQ"
320 #if !UCONFIG_NO_TRANSLITERATION || !UCONFIG_NO_FORMATTING
321 UParseError parseError
;
325 #if !UCONFIG_NO_NORMALIZATION
326 UnicodeString emptyString
;
327 TESTCLASSID_CTOR(Normalizer
, (emptyString
, UNORM_NONE
));
328 const Normalizer2
*noNormalizer2
= NULL
;
330 TESTCLASSID_NONE_CTOR(FilteredNormalizer2
, (*noNormalizer2
, emptySet
));
331 TESTCLASSID_FACTORY(CanonicalIterator
, new CanonicalIterator(UnicodeString("abc"), status
));
334 TESTCLASSID_NONE_FACTORY(IDNA
, IDNA::createUTS46Instance(0, status
));
336 //TESTCLASSID_DEFAULT(CollationElementIterator);
337 #if !UCONFIG_NO_COLLATION
338 TESTCLASSID_DEFAULT(CollationKey
);
339 TESTCLASSID_FACTORY(UStringEnumeration
, Collator::getKeywords(status
));
340 //TESTCLASSID_FACTORY_HIDDEN(CollationLocaleListEnumeration, Collator::getAvailableLocales());
342 //TESTCLASSID_FACTORY(CompoundTransliterator, Transliterator::createInstance(UnicodeString("Any-Jex;Hangul-Jamo"), UTRANS_FORWARD, parseError, status));
344 #if !UCONFIG_NO_FORMATTING
345 /* TESTCLASSID_FACTORY(NFSubstitution, NFSubstitution::makeSubstitution(8, */
346 /* TESTCLASSID_DEFAULT(DigitList); UMemory but not UObject*/
347 TESTCLASSID_ABSTRACT(NumberFormat
);
348 TESTCLASSID_CTOR(RuleBasedNumberFormat
, (UnicodeString("%default: -x: minus >>;"), parseError
, status
));
349 TESTCLASSID_CTOR(ChoiceFormat
, (UNICODE_STRING_SIMPLE("0#are no files|1#is one file|1<are many files"), status
));
350 TESTCLASSID_CTOR(MessageFormat
, (UnicodeString(), status
));
351 TESTCLASSID_CTOR(DateFormatSymbols
, (status
));
352 TESTCLASSID_CTOR(PluralFormat
, (status
));
353 TESTCLASSID_CTOR(PluralRules
, (status
));
354 TESTCLASSID_CTOR(SelectFormat
, (UnicodeString("feminine {feminineVerbValue} other{otherVerbValue}"), status
) );
355 TESTCLASSID_FACTORY(DateTimePatternGenerator
, DateTimePatternGenerator::createInstance(status
));
356 TESTCLASSID_FACTORY(RelativeDateFormat
, DateFormat::createDateInstance(DateFormat::kFullRelative
, Locale::getUS()));
357 TESTCLASSID_CTOR(DecimalFormatSymbols
, (status
));
358 TESTCLASSID_DEFAULT(FieldPosition
);
359 TESTCLASSID_DEFAULT(Formattable
);
360 TESTCLASSID_CTOR(CurrencyAmount
, (1.0, SMALL_STR
, status
));
361 TESTCLASSID_CTOR(CurrencyUnit
, (SMALL_STR
, status
));
362 TESTCLASSID_NONE_FACTORY(LocaleDisplayNames
, LocaleDisplayNames::createInstance("de"));
363 TESTCLASSID_FACTORY_HIDDEN(CurrencyFormat
, MeasureFormat::createCurrencyFormat(Locale::getUS(), status
));
364 TESTCLASSID_FACTORY(GregorianCalendar
, Calendar::createInstance(Locale("@calendar=gregorian"), status
));
365 TESTCLASSID_FACTORY(BuddhistCalendar
, Calendar::createInstance(Locale("@calendar=buddhist"), status
));
366 TESTCLASSID_FACTORY(IslamicCalendar
, Calendar::createInstance(Locale("@calendar=islamic"), status
));
367 TESTCLASSID_FACTORY(JapaneseCalendar
, Calendar::createInstance(Locale("@calendar=japanese"), status
));
368 TESTCLASSID_FACTORY(HebrewCalendar
, Calendar::createInstance(Locale("@calendar=hebrew"), status
));
369 TESTCLASSID_FACTORY(PersianCalendar
, Calendar::createInstance(Locale("@calendar=persian"), status
));
370 TESTCLASSID_FACTORY(IndianCalendar
, Calendar::createInstance(Locale("@calendar=indian"), status
));
371 TESTCLASSID_FACTORY(ChineseCalendar
, Calendar::createInstance(Locale("@calendar=chinese"), status
));
372 TESTCLASSID_FACTORY(TaiwanCalendar
, Calendar::createInstance(Locale("@calendar=roc"), status
));
374 TESTCLASSID_FACTORY(Win32DateFormat
, DateFormat::createDateInstance(DateFormat::kFull
, Locale("@compat=host")));
375 TESTCLASSID_FACTORY(Win32NumberFormat
, NumberFormat::createInstance(Locale("@compat=host"), status
));
379 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
380 /* TESTCLASSID_ABSTRACT(BreakIterator); No staticID! */
381 TESTCLASSID_FACTORY(RuleBasedBreakIterator
, BreakIterator::createLineInstance("mt",status
));
382 //TESTCLASSID_FACTORY(DictionaryBasedBreakIterator, BreakIterator::createLineInstance("th",status));
384 #if !UCONFIG_NO_SERVICE
385 TESTCLASSID_FACTORY_HIDDEN(ICULocaleService
, BreakIterator::getAvailableLocales());
389 //TESTCLASSID_DEFAULT(GregorianCalendar);
391 #if !UCONFIG_NO_TRANSLITERATION
392 TESTCLASSID_TRANSLIT(AnyTransliterator
, "Any-Latin");
393 TESTCLASSID_TRANSLIT(CompoundTransliterator
, "Latin-Greek");
394 TESTCLASSID_TRANSLIT(EscapeTransliterator
, "Any-Hex");
395 TESTCLASSID_TRANSLIT(LowercaseTransliterator
, "Lower");
396 TESTCLASSID_TRANSLIT(NameUnicodeTransliterator
, "Name-Any");
397 TESTCLASSID_TRANSLIT(NormalizationTransliterator
, "NFD");
398 TESTCLASSID_TRANSLIT(NullTransliterator
, "Null");
399 TESTCLASSID_TRANSLIT(RemoveTransliterator
, "Remove");
400 TESTCLASSID_FACTORY(RuleBasedTransliterator
, Transliterator::createFromRules(UnicodeString("abcd"),UnicodeString("a>b;"),UTRANS_FORWARD
,parseError
,status
));
401 TESTCLASSID_TRANSLIT(TitlecaseTransliterator
, "Title");
402 TESTCLASSID_TRANSLIT(UnescapeTransliterator
, "Hex-Any");
403 TESTCLASSID_TRANSLIT(UnicodeNameTransliterator
, "Any-Name");
404 TESTCLASSID_TRANSLIT(UppercaseTransliterator
, "Upper");
405 TESTCLASSID_ABSTRACT(CaseMapTransliterator
);
406 TESTCLASSID_ABSTRACT(Transliterator
);
407 TESTCLASSID_FACTORY_HIDDEN(TransliteratorRegistry::Enumeration
, Transliterator::getAvailableIDs(status
));
409 #if UOBJTEST_TEST_INTERNALS
410 TESTCLASSID_CTOR(Quantifier
, (NULL
, 0, 0));
411 TESTCLASSID_CTOR(FunctionReplacer
, (NULL
,NULL
));
412 TESTCLASSID_CTOR(StringMatcher
, (UnicodeString("x"), 0,0,0,TransliterationRuleData(status
)));
413 TESTCLASSID_CTOR(StringReplacer
,(UnicodeString(),new TransliterationRuleData(status
)));
417 TESTCLASSID_FACTORY(Locale
, new Locale("123"));
418 TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration
, Locale("@a=b").createKeywords(status
));
420 //TESTCLASSID_DEFAULT(NumeratorSubstitution);
422 #if !UCONFIG_NO_TRANSLITERATION
423 TESTCLASSID_DEFAULT(ParsePosition
);
428 //TESTCLASSID_DEFAULT(RegexCompile);
429 //TESTCLASSID_DEFAULT(RegexMatcher);
430 //TESTCLASSID_DEFAULT(RegexPattern);
432 //TESTCLASSID_DEFAULT(ReplaceableGlue);
433 TESTCLASSID_FACTORY(ResourceBundle
, new ResourceBundle(UnicodeString(), status
) );
434 //TESTCLASSID_DEFAULT(RuleBasedTransliterator);
436 //TESTCLASSID_DEFAULT(SimpleFwdCharIterator);
437 //TESTCLASSID_DEFAULT(StringReplacer);
438 //TESTCLASSID_DEFAULT(StringSearch);
440 //TESTCLASSID_DEFAULT(TestMultipleKeyStringFactory);
441 //TESTCLASSID_DEFAULT(TestReplaceable);
443 #if !UCONFIG_NO_FORMATTING
444 TESTCLASSID_ABSTRACT(TimeZone
);
445 TESTCLASSID_FACTORY(OlsonTimeZone
, TimeZone::createTimeZone(UnicodeString("America/Los_Angeles")));
446 TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration
, TimeZone::createEnumeration());
449 TESTCLASSID_DEFAULT(UnicodeString
);
450 TESTCLASSID_CTOR(UnicodeSet
, (0, 1));
451 TESTCLASSID_ABSTRACT(UnicodeFilter
);
452 TESTCLASSID_ABSTRACT(UnicodeFunctor
);
453 TESTCLASSID_CTOR(UnicodeSetIterator
,(UnicodeSet(0,1)));
454 TESTCLASSID_CTOR(UStack
, (status
));
455 TESTCLASSID_CTOR(UVector
, (status
));
456 TESTCLASSID_CTOR(UVector32
, (status
));
458 #if !UCONFIG_NO_SERVICE
459 TESTCLASSID_CTOR(SimpleFactory
, (NULL
, UnicodeString("foo")));
460 TESTCLASSID_DEFAULT(EventListener
);
461 TESTCLASSID_DEFAULT(ICUResourceBundleFactory
);
462 //TESTCLASSID_DEFAULT(Key); // does not exist?
463 UnicodeString
baz("baz");
464 UnicodeString
bat("bat");
465 TESTCLASSID_FACTORY(LocaleKey
, LocaleKey::createWithCanonicalFallback(&baz
, &bat
, LocaleKey::KIND_ANY
, status
));
466 TESTCLASSID_CTOR(SimpleLocaleKeyFactory
, (NULL
, UnicodeString("bar"), 8, 12) );
467 TESTCLASSID_CTOR(TestLocaleKeyFactory
, (42)); // Test replacement for LocaleKeyFactory
468 //#if UOBJTEST_TEST_INTERNALS
469 // TESTCLASSID_CTOR(LocaleKeyFactory, (42));
473 #if UOBJTEST_DUMP_IDS
475 for(i
=0;i
<ids_count
;i
++) {
477 sprintf(junk
, " %4d:\t%p\t%s\t%s\n",
478 i
, ids
[i
], ids_class
[i
], ids_factory
[i
]);
479 logln(UnicodeString(junk
));
484 void UObjectTest::testUMemory() {
485 // additional tests for code coverage
486 #if U_OVERRIDE_CXX_ALLOCATION && U_HAVE_PLACEMENT_NEW
488 UAlignedMemory align_
;
489 char bytes_
[sizeof(UnicodeString
)];
491 char *bytes
= stackMemory
.bytes_
;
495 p
=new(bytes
) UnicodeString(len
, (UChar32
)0x20ac, len
);
496 if((void *)p
!=(void *)bytes
) {
497 errln("placement new did not place the object at the expected address");
499 if(p
->length()!=len
|| p
->charAt(0)!=0x20ac || p
->charAt(len
-1)!=0x20ac) {
500 errln("constructor used with placement new did not work right");
504 * It is not possible to simply say
505 * delete(p, stackMemory);
506 * which results in a call to the normal, non-placement delete operator.
508 * Via a search on google.com for "c++ placement delete" I found
509 * http://cpptips.hyperformix.com/cpptips/placement_del3
512 * TITLE: using placement delete
514 * (Newsgroups: comp.std.c++, 27 Aug 97)
518 * > I do not completely understand how placement works on operator delete.
520 * There is no delete-expression which will invoke a placement
521 * form of operator delete. You can still call the function
522 * explicitly. Example:
524 * // destroy object and delete space manually
526 * operator delete(p, 12);
528 * ... so that's what I am doing here.
531 // destroy object and delete space manually
534 // You normally wouldn't call an operator delete for object placed on the
535 // stack with a placement new().
536 // This overload of delete is a nop, and is called here for code coverage purposes.
537 UnicodeString::operator delete(p
, bytes
);
539 // Jitterbug 4452, for coverage
540 UnicodeString
*pa
= new UnicodeString
[2];
541 if ( !pa
[0].isEmpty() || !pa
[1].isEmpty()){
542 errln("constructor used with array new did not work right");
547 // try to call the compiler-generated UMemory::operator=(class UMemory const &)
552 void UObjectTest::TestMFCCompatibility() {
553 #if U_HAVE_DEBUG_LOCATION_NEW
554 /* Make sure that it compiles with MFC's debuggable new usage. */
555 UnicodeString
*str
= new(__FILE__
, __LINE__
) UnicodeString();
556 str
->append((UChar
)0x0040); // Is it usable?
557 if(str
->charAt(0) != 0x0040) {
558 errln("debug new doesn't work.");
560 UnicodeString::operator delete(str
, __FILE__
, __LINE__
);
564 void UObjectTest::TestCompilerRTTI() {
565 UErrorCode errorCode
= U_ZERO_ERROR
;
566 NumberFormat
*nf
= NumberFormat::createInstance("de", errorCode
);
567 if (U_FAILURE(errorCode
)) {
568 dataerrln("NumberFormat::createInstance(de) failed - %s", u_errorName(errorCode
));
571 if (dynamic_cast<DecimalFormat
*>(nf
) == NULL
|| dynamic_cast<ChoiceFormat
*>(nf
) != NULL
) {
572 errln("dynamic_cast<>(NumberFormat) failed");
575 if (&typeid(*nf
) == NULL
|| typeid(*nf
) == typeid(UObject
) || typeid(*nf
) == typeid(Format
) ||
576 typeid(*nf
) != typeid(DecimalFormat
) || typeid(*nf
) == typeid(ChoiceFormat
) ||
577 typeid(*nf
) == typeid(emptySet
)
579 errln("typeid(NumberFormat) failed");
584 /* --------------- */
586 void UObjectTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /* par */ )
590 TESTCASE(0, testIDs
);
591 TESTCASE(1, testUMemory
);
592 TESTCASE(2, TestMFCCompatibility
);
593 TESTCASE(3, TestCompilerRTTI
);
595 default: name
= ""; break; //needed to end loop