1 /******************************************************************** 2 * COPYRIGHT: 3 * Copyright (c) 1997-2005, International Business Machines Corporation and 4 * others. All Rights Reserved. 5 ********************************************************************/ 6 /******************************************************************************** 7 * 8 * File CINTLTST.H 9 * 10 * Madhu Katragadda Creation 11 * Modification History: 12 * Date Name Description 13 * 07/13/99 helena HPUX 11 CC port. 14 ********************************************************************************* 15 16 The main root for C API tests 17 */ 18 19 #ifndef _CINTLTST 20 #define _CINTLTST 21 22 #include "unicode/utypes.h" 23 #include "unicode/putil.h" 24 #include "unicode/ctest.h" 25 #include <stdlib.h> 26 27 #ifndef U_USE_DEPRECATED_API 28 #define U_USE_DEPRECATED_API 1 29 #endif 30 31 U_CFUNC void addAllTests(TestNode** root); 32 33 /** 34 * Return the path to the icu/source/data/out directory 35 */ 36 U_CFUNC const char* ctest_dataOutDir(void); 37 38 /** 39 * Return the path to the icu/source/data/ directory 40 * for out of source builds too returns the source directory 41 */ 42 U_CFUNC const char* ctest_dataSrcDir(void); 43 44 U_CFUNC UChar* CharsToUChars(const char* chars); 45 46 /** 47 * Convert a const UChar* into a char* 48 * Caller owns storage, but in practice this function 49 * LEAKS so be aware of that. 50 * @param unichars UChars (null terminated) to be converted 51 * @return new char* to the unichars in host format 52 */ 53 54 U_CFUNC char *austrdup(const UChar* unichars); 55 U_CFUNC char *aescstrdup(const UChar* unichars, int32_t length); 56 U_CFUNC void *ctst_malloc(size_t size); 57 U_CFUNC void ctst_freeAll(void); 58 59 U_CFUNC const char* loadTestData(UErrorCode* err); 60 61 /** 62 * function used to specify the error 63 * converts the errorcode to an error descriptive string(const char*) 64 * @param status the error code 65 */ 66 #define myErrorName(errorCode) u_errorName(errorCode) 67 68 69 /** 70 * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value. 71 * @param optionalTimeZone Set this to a requested timezone. 72 * Set to NULL to use the standard test timezone (Pacific Time) 73 */ 74 U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status); 75 /** 76 * Call this once get back the original timezone 77 */ 78 U_CFUNC void ctest_resetTimeZone(void); 79 80 /** 81 * Call this once get ICU back to its original state with test arguments. 82 * This function calls u_cleanup. 83 */ 84 U_CFUNC UBool ctest_resetICU(void); 85 86 /** 87 * Assert that the given UErrorCode succeeds, and return TRUE if it does. 88 */ 89 U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec); 90 91 /** 92 * Assert that the UBool is TRUE, and return TRUE if it does. 93 * 94 * NOTE: Use 'int condition' rather than 'UBool condition' so the 95 * compiler doesn't complain about integral conversion of expressions 96 * like 'p != 0'. 97 */ 98 U_CFUNC UBool assertTrue(const char* msg, int condition); 99 100 /** 101 * Assert that the actualString equals the expectedString, and return 102 * TRUE if it does. 103 */ 104 U_CFUNC UBool assertEquals(const char* msg, const char* expectedString, 105 const char* actualString); 106 107 /** 108 * Time bomb - allows temporary behavior that expires at a given 109 * release 110 * 111 */ 112 U_CFUNC UBool isICUVersionAtLeast(const UVersionInfo x); 113 114 #endif 115