]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/cintltst.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2013, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
12 * Madhu Katragadda Creation
13 * Modification History:
14 * Date Name Description
15 * 07/13/99 helena HPUX 11 CC port.
16 *********************************************************************************
18 The main root for C API tests
24 #include "unicode/utypes.h"
25 #include "unicode/putil.h"
26 #include "unicode/ctest.h"
28 #if U_NO_DEFAULT_INCLUDE_UTF_HEADERS
29 /* deprecated - make tests pass with U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
30 #include "unicode/utf_old.h"
35 #ifndef U_USE_DEPRECATED_API
36 #define U_USE_DEPRECATED_API 1
39 U_CFUNC
void addAllTests(TestNode
** root
);
42 * Return the path to the icu/source/data/out directory
44 U_CFUNC
const char* ctest_dataOutDir(void);
47 * Return the path to the icu/source/data/ directory
48 * for out of source builds too returns the source directory
50 U_CFUNC
const char* ctest_dataSrcDir(void);
53 * Convert a char string into a UChar string, with unescaping
54 * The result buffer has been malloc()'ed (not ctst_malloc) and needs to be free()'ed by the caller.
56 U_CFUNC UChar
* CharsToUChars(const char* chars
);
59 * Convert a const UChar* into a char*
60 * Result is allocated with ctst_malloc and will be freed at the end of the test.
61 * @param unichars UChars (null terminated) to be converted
62 * @return new char* to the unichars in host format
65 U_CFUNC
char *austrdup(const UChar
* unichars
);
68 * Convert a const UChar* into an escaped char*
69 * Result is allocated with ctst_malloc and will be freed at the end of the test.
70 * @param unichars UChars to be converted
71 * @param length length of chars
72 * @return new char* to the unichars in host format
74 U_CFUNC
char *aescstrdup(const UChar
* unichars
, int32_t length
);
77 * Special memory allocation function for test use. At the end of cintltst,
78 * or every few thousand allocations, memory allocated by this function will be freed.
79 * Do not manually free memory returned by this function, and do not retain a pointer
80 * outside of a single instruction scope (i.e. long enough to display the value).
83 U_CFUNC
void *ctst_malloc(size_t size
);
86 * Return the path to cintltst's data ( icu/source/data/testdata ) directory.
87 * Return value is allocated by ctst_malloc and should not be deleted.
89 U_CFUNC
const char* loadTestData(UErrorCode
* err
);
92 * function used to specify the error
93 * converts the errorcode to an error descriptive string(const char*)
94 * @param status the error code
96 #define myErrorName(errorCode) u_errorName(errorCode)
100 * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value.
101 * @param optionalTimeZone Set this to a requested timezone.
102 * Set to NULL to use the standard test timezone (Pacific Time)
104 U_CFUNC
void ctest_setTimeZone(const char *optionalTimeZone
, UErrorCode
*status
);
106 * Call this once get back the original timezone
108 U_CFUNC
void ctest_resetTimeZone(void);
111 * Call this once get ICU back to its original state with test arguments.
112 * This function calls u_cleanup.
114 U_CFUNC UBool
ctest_resetICU(void);
117 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
119 U_CFUNC UBool
assertSuccess(const char* msg
, UErrorCode
* ec
);
122 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
123 * Give data error if UErrorCode fails and possibleDataError is TRUE.
125 U_CFUNC UBool
assertSuccessCheck(const char* msg
, UErrorCode
* ec
, UBool possibleDataError
);
128 * Assert that the UBool is TRUE, and return TRUE if it does.
130 * NOTE: Use 'int condition' rather than 'UBool condition' so the
131 * compiler doesn't complain about integral conversion of expressions
134 U_CFUNC UBool
assertTrue(const char* msg
, int condition
);
137 * Assert that the actualString equals the expectedString, and return
140 U_CFUNC UBool
assertEquals(const char* msg
, const char* expectedString
,
141 const char* actualString
);
144 * note - isICUVersionBefore and isICUVersionAtLeast have been removed.
145 * use log_knownIssue() instead.