1 /********************************************************************
3 * Copyright (c) 1997-2013, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /********************************************************************************
10 * Madhu Katragadda Creation
11 * Modification History:
12 * Date Name Description
13 * 07/13/99 helena HPUX 11 CC port.
14 *********************************************************************************
16 The main root for C API tests
22 #include "unicode/utypes.h"
23 #include "unicode/putil.h"
24 #include "unicode/ctest.h"
26 #if U_NO_DEFAULT_INCLUDE_UTF_HEADERS
27 /* deprecated - make tests pass with U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
28 #include "unicode/utf_old.h"
33 #ifndef U_USE_DEPRECATED_API
34 #define U_USE_DEPRECATED_API 1
37 U_CFUNC void addAllTests(TestNode** root);
40 * Return the path to the icu/source/data/out directory
42 U_CFUNC const char* ctest_dataOutDir(void);
45 * Return the path to the icu/source/data/ directory
46 * for out of source builds too returns the source directory
48 U_CFUNC const char* ctest_dataSrcDir(void);
51 * Convert a char string into a UChar string, with unescaping
52 * The result buffer has been malloc()'ed (not ctst_malloc) and needs to be free()'ed by the caller.
54 U_CFUNC UChar* CharsToUChars(const char* chars);
57 * Convert a const UChar* into a char*
58 * Result is allocated with ctst_malloc and will be freed at the end of the test.
59 * @param unichars UChars (null terminated) to be converted
60 * @return new char* to the unichars in host format
63 U_CFUNC char *austrdup(const UChar* unichars);
66 * Convert a const UChar* into an escaped char*
67 * Result is allocated with ctst_malloc and will be freed at the end of the test.
68 * @param unichars UChars to be converted
69 * @param length length of chars
70 * @return new char* to the unichars in host format
72 U_CFUNC char *aescstrdup(const UChar* unichars, int32_t length);
75 * Special memory allocation function for test use. At the end of cintltst,
76 * or every few thousand allocations, memory allocated by this function will be freed.
77 * Do not manually free memory returned by this function, and do not retain a pointer
78 * outside of a single instruction scope (i.e. long enough to display the value).
81 U_CFUNC void *ctst_malloc(size_t size);
84 * Return the path to cintltst's data ( icu/source/data/testdata ) directory.
85 * Return value is allocated by ctst_malloc and should not be deleted.
87 U_CFUNC const char* loadTestData(UErrorCode* err);
90 * function used to specify the error
91 * converts the errorcode to an error descriptive string(const char*)
92 * @param status the error code
94 #define myErrorName(errorCode) u_errorName(errorCode)
98 * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value.
99 * @param optionalTimeZone Set this to a requested timezone.
100 * Set to NULL to use the standard test timezone (Pacific Time)
102 U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status);
104 * Call this once get back the original timezone
106 U_CFUNC void ctest_resetTimeZone(void);
109 * Call this once get ICU back to its original state with test arguments.
110 * This function calls u_cleanup.
112 U_CFUNC UBool ctest_resetICU(void);
115 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
117 U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec);
120 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
121 * Give data error if UErrorCode fails and possibleDataError is TRUE.
123 U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError);
126 * Assert that the UBool is TRUE, and return TRUE if it does.
128 * NOTE: Use 'int condition' rather than 'UBool condition' so the
129 * compiler doesn't complain about integral conversion of expressions
132 U_CFUNC UBool assertTrue(const char* msg, int condition);
135 * Assert that the actualString equals the expectedString, and return
138 U_CFUNC UBool assertEquals(const char* msg, const char* expectedString,
139 const char* actualString);
142 * note - isICUVersionBefore and isICUVersionAtLeast have been removed.
143 * use log_knownIssue() instead.