]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/cintltst.h
ICU-59173.0.1.tar.gz
[apple/icu.git] / 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 /********************************************************************
4 * COPYRIGHT:
5 * Copyright (c) 1997-2013, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
9 *
10 * File CINTLTST.H
11 *
12 * Madhu Katragadda Creation
13 * Modification History:
14 * Date Name Description
15 * 07/13/99 helena HPUX 11 CC port.
16 *********************************************************************************
17
18 The main root for C API tests
19 */
20
21 #ifndef _CINTLTST
22 #define _CINTLTST
23
24 #include "unicode/utypes.h"
25 #include "unicode/putil.h"
26 #include "unicode/ctest.h"
27
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"
31 #endif
32
33 #include <stdlib.h>
34
35 #ifndef U_USE_DEPRECATED_API
36 #define U_USE_DEPRECATED_API 1
37 #endif
38
39 U_CFUNC void addAllTests(TestNode** root);
40
41 /**
42 * Return the path to the icu/source/data/out directory
43 */
44 U_CFUNC const char* ctest_dataOutDir(void);
45
46 /**
47 * Return the path to the icu/source/data/ directory
48 * for out of source builds too returns the source directory
49 */
50 U_CFUNC const char* ctest_dataSrcDir(void);
51
52 /**
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.
55 */
56 U_CFUNC UChar* CharsToUChars(const char* chars);
57
58 /**
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
63 */
64
65 U_CFUNC char *austrdup(const UChar* unichars);
66
67 /**
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
73 */
74 U_CFUNC char *aescstrdup(const UChar* unichars, int32_t length);
75
76 /**
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).
81 * @see #ctst_freeAll
82 */
83 U_CFUNC void *ctst_malloc(size_t size);
84
85 /**
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.
88 */
89 U_CFUNC const char* loadTestData(UErrorCode* err);
90
91 /**
92 * function used to specify the error
93 * converts the errorcode to an error descriptive string(const char*)
94 * @param status the error code
95 */
96 #define myErrorName(errorCode) u_errorName(errorCode)
97
98
99 /**
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)
103 */
104 U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status);
105 /**
106 * Call this once get back the original timezone
107 */
108 U_CFUNC void ctest_resetTimeZone(void);
109
110 /**
111 * Call this once get ICU back to its original state with test arguments.
112 * This function calls u_cleanup.
113 */
114 U_CFUNC UBool ctest_resetICU(void);
115
116 /**
117 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
118 */
119 U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec);
120
121 /**
122 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
123 * Give data error if UErrorCode fails and possibleDataError is TRUE.
124 */
125 U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError);
126
127 /**
128 * Assert that the UBool is TRUE, and return TRUE if it does.
129 *
130 * NOTE: Use 'int condition' rather than 'UBool condition' so the
131 * compiler doesn't complain about integral conversion of expressions
132 * like 'p != 0'.
133 */
134 U_CFUNC UBool assertTrue(const char* msg, int condition);
135
136 /**
137 * Assert that the actualString equals the expectedString, and return
138 * TRUE if it does.
139 */
140 U_CFUNC UBool assertEquals(const char* msg, const char* expectedString,
141 const char* actualString);
142
143 /*
144 * note - isICUVersionBefore and isICUVersionAtLeast have been removed.
145 * use log_knownIssue() instead.
146 */
147
148 #endif