1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4 * COPYRIGHT:
5 * Copyright (c) 1997-2015, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
9 *
10 * File CINTLTST.C
11 *
12 * Modification History:
13 * Name Description
14 * Madhu Katragadda Creation
15 *********************************************************************************
16 */
17
18 /*The main root for C API tests*/
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include "unicode/utypes.h"
24 #include "unicode/putil.h"
25 #include "cstring.h"
26 #include "cintltst.h"
27 #include "uassert.h"
28 #include "cmemory.h"
29 #include "unicode/uchar.h"
30 #include "unicode/ustring.h"
31 #include "unicode/ucnv.h"
32 #include "unicode/ures.h"
33 #include "unicode/uclean.h"
34 #include "unicode/ucal.h"
35 #include "uoptions.h"
36 #include "putilimp.h" /* for uprv_getRawUTCtime() */
37 #ifdef URES_DEBUG
38 #include "uresimp.h" /* for ures_dumpCacheContents() */
39 #endif
40
41 #ifdef XP_MAC_CONSOLE
42 # include <console.h>
43 #endif
44
45 #define CTST_MAX_ALLOC 8192
46 /* Array used as a queue */
47 static void * ctst_allocated_stuff[CTST_MAX_ALLOC] = {0};
48 static int ctst_allocated = 0;
49 static UBool ctst_free = FALSE;
50 static int ctst_allocated_total = 0;
51
52 #define CTST_LEAK_CHECK 1
53
54 #ifdef CTST_LEAK_CHECK
55 static void ctst_freeAll(void);
56 #endif
57
58 /*
59 * Forward Declarations
60 */
61 void ctest_setICU_DATA(void);
62
63
64
65 #if UCONFIG_NO_LEGACY_CONVERSION
66 # define TRY_CNV_1 "iso-8859-1"
67 # define TRY_CNV_2 "ibm-1208"
68 #else
69 # define TRY_CNV_1 "iso-8859-7"
70 # define TRY_CNV_2 "sjis"
71 #endif
72
73 static int gOrigArgc;
74 static const char* const * gOrigArgv;
75
76 #ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
77 U_CAPI void unistr_printLengths();
78 #endif
79
main(int argc,const char * const argv[])80 int main(int argc, const char* const argv[])
81 {
82 int nerrors = 0;
83 UBool defaultDataFound;
84 TestNode *root;
85 const char *warnOrErr = "Failure";
86 UDate startTime, endTime;
87 int32_t diffTime;
88
89 /* initial check for the default converter */
90 UErrorCode errorCode = U_ZERO_ERROR;
91 UResourceBundle *rb;
92 UConverter *cnv;
93
94 U_MAIN_INIT_ARGS(argc, argv);
95
96 startTime = uprv_getRawUTCtime();
97
98 gOrigArgc = argc;
99 gOrigArgv = argv;
100 if (!initArgs(argc, argv, NULL, NULL)) {
101 /* Error already displayed. */
102 return -1;
103 }
104
105 /* Check whether ICU will initialize without forcing the build data directory into
106 * the ICU_DATA path. Success here means either the data dll contains data, or that
107 * this test program was run with ICU_DATA set externally. Failure of this check
108 * is normal when ICU data is not packaged into a shared library.
109 *
110 * Whether or not this test succeeds, we want to cleanup and reinitialize
111 * with a data path so that data loading from individual files can be tested.
112 */
113 defaultDataFound = TRUE;
114 u_init(&errorCode);
115 if (U_FAILURE(errorCode)) {
116 fprintf(stderr,
117 "#### Note: ICU Init without build-specific setDataDirectory() failed. %s\n", u_errorName(errorCode));
118 defaultDataFound = FALSE;
119 }
120 u_cleanup();
121 #ifdef URES_DEBUG
122 fprintf(stderr, "After initial u_cleanup: RB cache %s empty.\n", ures_dumpCacheContents()?"WAS NOT":"was");
123 #endif
124
125 while (getTestOption(REPEAT_TESTS_OPTION) > 0) { /* Loop runs once per complete execution of the tests
126 * used for -r (repeat) test option. */
127 if (!initArgs(argc, argv, NULL, NULL)) {
128 /* Error already displayed. */
129 return -1;
130 }
131 errorCode = U_ZERO_ERROR;
132
133 /* Initialize ICU */
134 if (!defaultDataFound) {
135 ctest_setICU_DATA(); /* u_setDataDirectory() must happen Before u_init() */
136 }
137 u_init(&errorCode);
138 if (U_FAILURE(errorCode)) {
139 fprintf(stderr,
140 "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
141 "*** Check the ICU_DATA environment variable and \n"
142 "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
143 if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
144 fprintf(stderr, "*** Exiting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
145 u_cleanup();
146 return 1;
147 }
148 }
149
150
151
152 /* try more data */
153 cnv = ucnv_open(TRY_CNV_2, &errorCode);
154 if(cnv != 0) {
155 /* ok */
156 ucnv_close(cnv);
157 } else {
158 fprintf(stderr,
159 "*** %s! The converter for " TRY_CNV_2 " cannot be opened.\n"
160 "*** Check the ICU_DATA environment variable and \n"
161 "*** check that the data files are present.\n", warnOrErr);
162 if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
163 fprintf(stderr, "*** Exiting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
164 u_cleanup();
165 return 1;
166 }
167 }
168
169 rb = ures_open(NULL, "en", &errorCode);
170 if(U_SUCCESS(errorCode)) {
171 /* ok */
172 ures_close(rb);
173 } else {
174 fprintf(stderr,
175 "*** %s! The \"en\" locale resource bundle cannot be opened.\n"
176 "*** Check the ICU_DATA environment variable and \n"
177 "*** check that the data files are present.\n", warnOrErr);
178 if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
179 fprintf(stderr, "*** Exiting. Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
180 u_cleanup();
181 return 1;
182 }
183 }
184
185 errorCode = U_ZERO_ERROR;
186 rb = ures_open(NULL, NULL, &errorCode);
187 if(U_SUCCESS(errorCode)) {
188 /* ok */
189 if (errorCode == U_USING_DEFAULT_WARNING || errorCode == U_USING_FALLBACK_WARNING) {
190 fprintf(stderr,
191 "#### Note: The default locale %s is not available\n", uloc_getDefault());
192 }
193 ures_close(rb);
194 } else {
195 fprintf(stderr,
196 "*** %s! Can not open a resource bundle for the default locale %s\n", warnOrErr, uloc_getDefault());
197 if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
198 fprintf(stderr, "*** Exiting. Use the '-w' option if data files were\n"
199 "*** purposely removed, to continue test anyway.\n");
200 u_cleanup();
201 return 1;
202 }
203 }
204 fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());
205
206 /* Build a tree of all tests.
207 * Subsequently will be used to find / iterate the tests to run */
208 root = NULL;
209 addAllTests(&root);
210
211 /* Tests actually run HERE. TODO: separate command line option parsing & setting from test execution!! */
212 nerrors = runTestRequest(root, argc, argv);
213
214 setTestOption(REPEAT_TESTS_OPTION, DECREMENT_OPTION_VALUE);
215 if (getTestOption(REPEAT_TESTS_OPTION) > 0) {
216 printf("Repeating tests %d more time(s)\n", getTestOption(REPEAT_TESTS_OPTION));
217 }
218 cleanUpTestTree(root);
219
220 #ifdef CTST_LEAK_CHECK
221 ctst_freeAll();
222 /* To check for leaks */
223 u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
224
225 if(getTestOption(VERBOSITY_OPTION) && ctst_allocated_total>0) {
226 fprintf(stderr,"ctst_freeAll(): cleaned up after %d allocations (queue of %d)\n", ctst_allocated_total, CTST_MAX_ALLOC);
227 }
228 #ifdef URES_DEBUG
229 if(ures_dumpCacheContents()) {
230 fprintf(stderr, "Error: After final u_cleanup, RB cache was not empty.\n");
231 nerrors++;
232 } else {
233 fprintf(stderr,"OK: After final u_cleanup, RB cache was empty.\n");
234 }
235 #endif
236 #endif
237
238 } /* End of loop that repeats the entire test, if requested. (Normally doesn't loop) */
239
240 #ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
241 unistr_printLengths();
242 #endif
243
244 endTime = uprv_getRawUTCtime();
245 diffTime = (int32_t)(endTime - startTime);
246 printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
247 (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
248 (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
249 (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
250 (int)(diffTime%U_MILLIS_PER_SECOND));
251
252 #ifdef ZERO_EXIT_CODE_FOR_FAILURES
253 return 0;
254 #else
255 return nerrors ? 1 : 0;
256 #endif
257 }
258
259 /*
260 static void ctest_appendToDataDirectory(const char *toAppend)
261 {
262 const char *oldPath ="";
263 char newBuf [1024];
264 char *newPath = newBuf;
265 int32_t oldLen;
266 int32_t newLen;
267
268 if((toAppend == NULL) || (*toAppend == 0)) {
269 return;
270 }
271
272 oldPath = u_getDataDirectory();
273 if( (oldPath==NULL) || (*oldPath == 0)) {
274 u_setDataDirectory(toAppend);
275 } else {
276 oldLen = strlen(oldPath);
277 newLen = strlen(toAppend)+1+oldLen;
278
279 if(newLen > 1022)
280 {
281 newPath = (char *)ctst_malloc(newLen);
282 }
283
284 strcpy(newPath, oldPath);
285 strcpy(newPath+oldLen, U_PATH_SEP_STRING);
286 strcpy(newPath+oldLen+1, toAppend);
287
288 u_setDataDirectory(newPath);
289
290 if(newPath != newBuf)
291 {
292 free(newPath);
293 }
294 }
295 }
296 */
297
298 /* ctest_setICU_DATA - if the ICU_DATA environment variable is not already
299 * set, try to deduce the directory in which ICU was built,
300 * and set ICU_DATA to "icu/source/data" in that location.
301 * The intent is to allow the tests to have a good chance
302 * of running without requiring that the user manually set
303 * ICU_DATA. Common data isn't a problem, since it is
304 * picked up via a static (build time) reference, but the
305 * tests dynamically load some data.
306 */
ctest_setICU_DATA()307 void ctest_setICU_DATA() {
308 // Android-changed: Do not u_setDataDirectory because libicuuc.so initializes itself.
309 #if !defined(ANDROID_USE_ICU_REG)
310 u_setDataDirectory(ctest_dataOutDir());
311 #endif
312 }
313
314 /* These tests do cleanup and reinitialize ICU in the course of their operation.
315 * The ICU data directory must be preserved across these operations.
316 * Here is a helper function to assist with that.
317 */
safeGetICUDataDirectory()318 static char *safeGetICUDataDirectory() {
319 const char *dataDir = u_getDataDirectory(); /* Returned string vanashes with u_cleanup */
320 char *retStr = NULL;
321 if (dataDir != NULL) {
322 retStr = (char *)malloc(strlen(dataDir)+1);
323 strcpy(retStr, dataDir);
324 }
325 return retStr;
326 }
327
ctest_resetICU()328 UBool ctest_resetICU() {
329 UErrorCode status = U_ZERO_ERROR;
330 char *dataDir = safeGetICUDataDirectory();
331
332 u_cleanup();
333 if (!initArgs(gOrigArgc, gOrigArgv, NULL, NULL)) {
334 /* Error already displayed. */
335 return FALSE;
336 }
337 ctest_setICU_DATA();
338 free(dataDir);
339 u_init(&status);
340 if (U_FAILURE(status)) {
341 log_err_status(status, "u_init failed with %s\n", u_errorName(status));
342 return FALSE;
343 }
344 return TRUE;
345 }
346
CharsToUChars(const char * str)347 UChar* CharsToUChars(const char* str) {
348 /* Might be faster to just use uprv_strlen() as the preflight len - liu */
349 int32_t len = u_unescape(str, 0, 0); /* preflight */
350 /* Do NOT use malloc() - we are supposed to be acting like user code! */
351 UChar *buf = (UChar*) malloc(sizeof(UChar) * (len + 1));
352 u_unescape(str, buf, len + 1);
353 return buf;
354 }
355
austrdup(const UChar * unichars)356 char *austrdup(const UChar* unichars)
357 {
358 int length;
359 char *newString;
360
361 length = u_strlen ( unichars );
362 /*newString = (char*)malloc ( sizeof( char ) * 4 * ( length + 1 ) );*/ /* this leaks for now */
363 newString = (char*)ctst_malloc ( sizeof( char ) * 4 * ( length + 1 ) ); /* this shouldn't */
364
365 if ( newString == NULL )
366 return NULL;
367
368 u_austrcpy ( newString, unichars );
369
370 return newString;
371 }
372
aescstrdup(const UChar * unichars,int32_t length)373 char *aescstrdup(const UChar* unichars,int32_t length){
374 char *newString,*targetLimit,*target;
375 UConverterFromUCallback cb;
376 const void *p;
377 UErrorCode errorCode = U_ZERO_ERROR;
378 #if U_CHARSET_FAMILY==U_EBCDIC_FAMILY
379 # if U_PLATFORM == U_PF_OS390
380 static const char convName[] = "ibm-1047";
381 # else
382 static const char convName[] = "ibm-37";
383 # endif
384 #else
385 static const char convName[] = "US-ASCII";
386 #endif
387 UConverter* conv = ucnv_open(convName, &errorCode);
388 if(length==-1){
389 length = u_strlen( unichars);
390 }
391 newString = (char*)ctst_malloc ( sizeof(char) * 8 * (length +1));
392 target = newString;
393 targetLimit = newString+sizeof(char) * 8 * (length +1);
394 ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C, &cb, &p, &errorCode);
395 ucnv_fromUnicode(conv,&target,targetLimit, &unichars, (UChar*)(unichars+length),NULL,TRUE,&errorCode);
396 ucnv_close(conv);
397 *target = '\0';
398 return newString;
399 }
400
loadTestData(UErrorCode * err)401 const char* loadTestData(UErrorCode* err) {
402 return ctest_loadTestData(err);
403 }
404
405 /**
406 * Returns the path to icu/source/test/testdata/
407 * Note: this function is parallel with C++ getSourceTestData in intltest.cpp
408 */
loadSourceTestData(UErrorCode * err)409 const char *loadSourceTestData(UErrorCode* err) {
410 (void)err;
411 const char *srcDataDir = NULL;
412 #ifdef U_TOPSRCDIR
413 srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
414 #else
415 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
416 FILE *f = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING "rbbitst.txt", "r");
417 if (f) {
418 /* We're in icu/source/test/intltest/ */
419 fclose(f);
420 }
421 else {
422 /* We're in icu/source/test/intltest/Platform/(Debug|Release) */
423 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING
424 "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
425 }
426 #endif
427 return srcDataDir;
428 }
429
430 #define CTEST_MAX_TIMEZONE_SIZE 256
431 static UChar gOriginalTimeZone[CTEST_MAX_TIMEZONE_SIZE] = {0};
432
433 /**
434 * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value.
435 * @param optionalTimeZone Set this to a requested timezone.
436 * Set to NULL to use the standard test timezone (Pacific Time)
437 */
ctest_setTimeZone(const char * optionalTimeZone,UErrorCode * status)438 U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status) {
439 #if !UCONFIG_NO_FORMATTING
440 UChar zoneID[CTEST_MAX_TIMEZONE_SIZE];
441
442 if (optionalTimeZone == NULL) {
443 optionalTimeZone = "America/Los_Angeles";
444 }
445 if (gOriginalTimeZone[0]) {
446 log_data_err("*** Error: time zone saved twice. New value will be %s (Are you missing data?)\n",
447 optionalTimeZone);
448 }
449 ucal_getDefaultTimeZone(gOriginalTimeZone, CTEST_MAX_TIMEZONE_SIZE, status);
450 if (U_FAILURE(*status)) {
451 log_err("*** Error: Failed to save default time zone: %s\n",
452 u_errorName(*status));
453 *status = U_ZERO_ERROR;
454 }
455
456 u_uastrncpy(zoneID, optionalTimeZone, CTEST_MAX_TIMEZONE_SIZE-1);
457 zoneID[CTEST_MAX_TIMEZONE_SIZE-1] = 0;
458 ucal_setDefaultTimeZone(zoneID, status);
459 if (U_FAILURE(*status)) {
460 log_err("*** Error: Failed to set default time zone to \"%s\": %s\n",
461 optionalTimeZone, u_errorName(*status));
462 }
463 #endif
464 }
465
466 /**
467 * Call this once get back the original timezone
468 */
ctest_resetTimeZone(void)469 U_CFUNC void ctest_resetTimeZone(void) {
470 #if !UCONFIG_NO_FORMATTING
471 UErrorCode status = U_ZERO_ERROR;
472
473 ucal_setDefaultTimeZone(gOriginalTimeZone, &status);
474 if (U_FAILURE(status)) {
475 log_err("*** Error: Failed to reset default time zone: %s\n",
476 u_errorName(status));
477 }
478 /* Set to an empty state */
479 gOriginalTimeZone[0] = 0;
480 #endif
481 }
482
483
ctst_malloc(size_t size)484 void *ctst_malloc(size_t size) {
485 ctst_allocated_total++;
486 if(ctst_allocated >= CTST_MAX_ALLOC - 1) {
487 ctst_allocated = 0;
488 ctst_free = TRUE;
489 }
490 if(ctst_allocated_stuff[ctst_allocated]) {
491 free(ctst_allocated_stuff[ctst_allocated]);
492 }
493 return ctst_allocated_stuff[ctst_allocated++] = malloc(size);
494 }
495
496 #ifdef CTST_LEAK_CHECK
ctst_freeAll()497 static void ctst_freeAll() {
498 int i;
499 if(ctst_free == FALSE) { /* only free up to the allocated mark */
500 for(i=0; i<ctst_allocated; i++) {
501 free(ctst_allocated_stuff[i]);
502 ctst_allocated_stuff[i] = NULL;
503 }
504 } else { /* free all */
505 for(i=0; i<CTST_MAX_ALLOC; i++) {
506 free(ctst_allocated_stuff[i]);
507 ctst_allocated_stuff[i] = NULL;
508 }
509 }
510 ctst_allocated = 0;
511 }
512
513 #define VERBOSE_ASSERTIONS
514
assertSuccessCheck(const char * msg,UErrorCode * ec,UBool possibleDataError)515 U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError) {
516 U_ASSERT(ec!=NULL);
517 if (U_FAILURE(*ec)) {
518 if (possibleDataError) {
519 log_data_err("FAIL: %s (%s)\n", msg, u_errorName(*ec));
520 } else {
521 log_err_status(*ec, "FAIL: %s (%s)\n", msg, u_errorName(*ec));
522 }
523 return FALSE;
524 }
525 return TRUE;
526 }
527
assertSuccess(const char * msg,UErrorCode * ec)528 U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec) {
529 U_ASSERT(ec!=NULL);
530 return assertSuccessCheck(msg, ec, FALSE);
531 }
532
533 /* if 'condition' is a UBool, the compiler complains bitterly about
534 expressions like 'a > 0' which it evaluates as int */
assertTrue(const char * msg,int condition)535 U_CFUNC UBool assertTrue(const char* msg, int /*not UBool*/ condition) {
536 if (!condition) {
537 log_err("FAIL: assertTrue() failed: %s\n", msg);
538 }
539 #ifdef VERBOSE_ASSERTIONS
540 else {
541 log_verbose("Ok: %s\n", msg);
542 }
543 #endif
544 return (UBool)condition;
545 }
546
assertEquals(const char * message,const char * expected,const char * actual)547 U_CFUNC UBool assertEquals(const char* message, const char* expected,
548 const char* actual) {
549 if (expected == NULL) {
550 expected = "(null)";
551 }
552 if (actual == NULL) {
553 actual = "(null)";
554 }
555 if (uprv_strcmp(expected, actual) != 0) {
556 log_err("FAIL: %s; got \"%s\"; expected \"%s\"\n",
557 message, actual, expected);
558 return FALSE;
559 }
560 #ifdef VERBOSE_ASSERTIONS
561 else {
562 log_verbose("Ok: %s; got \"%s\"\n", message, actual);
563 }
564 #endif
565 return TRUE;
566 }
567
assertUEquals(const char * message,const UChar * expected,const UChar * actual)568 U_CFUNC UBool assertUEquals(const char* message, const UChar* expected,
569 const UChar* actual) {
570 if (expected == NULL) {
571 expected = u"(null)";
572 }
573 if (actual == NULL) {
574 actual = u"(null)";
575 }
576 for (int32_t i=0;; i++) {
577 if (expected[i] != actual[i]) {
578 log_err("FAIL: %s; got \"%s\"; expected \"%s\"\n",
579 message, austrdup(actual), austrdup(expected));
580 return FALSE;
581 }
582 UChar curr = expected[i];
583 U_ASSERT(curr == actual[i]);
584 if (curr == 0) {
585 break;
586 }
587 }
588 #ifdef VERBOSE_ASSERTIONS
589 log_verbose("Ok: %s; got \"%s\"\n", message, austrdup(actual));
590 #endif
591 return TRUE;
592 }
593
assertIntEquals(const char * message,int64_t expected,int64_t actual)594 U_CFUNC UBool assertIntEquals(const char* message, int64_t expected, int64_t actual) {
595 if (expected != actual) {
596 log_err("FAIL: %s; got \"%d\"; expected \"%d\"\n",
597 message, actual, expected);
598 return FALSE;
599 }
600 #ifdef VERBOSE_ASSERTIONS
601 else {
602 log_verbose("Ok: %s; got \"%d\"\n", message, actual);
603 }
604 #endif
605 return TRUE;
606 }
607
assertPtrEquals(const char * message,const void * expected,const void * actual)608 U_CFUNC UBool assertPtrEquals(const char* message, const void* expected, const void* actual) {
609 if (expected != actual) {
610 log_err("FAIL: %s; got 0x%llx; expected 0x%llx\n",
611 message, actual, expected);
612 return FALSE;
613 }
614 #ifdef VERBOSE_ASSERTIONS
615 else {
616 log_verbose("Ok: %s; got 0x%llx\n", message, actual);
617 }
618 #endif
619 return TRUE;
620 }
621
assertDoubleEquals(const char * message,double expected,double actual)622 U_CFUNC UBool assertDoubleEquals(const char *message, double expected, double actual) {
623 if (expected != actual) {
624 log_err("FAIL: %s; got \"%f\"; expected \"%f\"\n", message, actual, expected);
625 return FALSE;
626 }
627 #ifdef VERBOSE_ASSERTIONS
628 else {
629 log_verbose("Ok: %s; got \"%f\"\n", message, actual);
630 }
631 #endif
632 return TRUE;
633 }
634
635 #endif
636