]>
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"
30 #ifndef U_USE_DEPRECATED_API
31 #define U_USE_DEPRECATED_API 1
34 U_CFUNC
void addAllTests(TestNode
** root
);
37 * Return the path to the icu/source/data/out directory
39 U_CFUNC
const char* ctest_dataOutDir(void);
42 * Return the path to the icu/source/data/ directory
43 * for out of source builds too returns the source directory
45 U_CFUNC
const char* ctest_dataSrcDir(void);
48 * Convert a char string into a UChar string, with unescaping
49 * The result buffer has been malloc()'ed (not ctst_malloc) and needs to be free()'ed by the caller.
51 U_CFUNC UChar
* CharsToUChars(const char* chars
);
54 * Convert a const UChar* into a char*
55 * Result is allocated with ctst_malloc and will be freed at the end of the test.
56 * @param unichars UChars (null terminated) to be converted
57 * @return new char* to the unichars in host format
60 U_CFUNC
char *austrdup(const UChar
* unichars
);
63 * Convert a const UChar* into an escaped char*
64 * Result is allocated with ctst_malloc and will be freed at the end of the test.
65 * @param unichars UChars to be converted
66 * @param length length of chars
67 * @return new char* to the unichars in host format
69 U_CFUNC
char *aescstrdup(const UChar
* unichars
, int32_t length
);
72 * Special memory allocation function for test use. At the end of cintltst,
73 * or every few thousand allocations, memory allocated by this function will be freed.
74 * Do not manually free memory returned by this function, and do not retain a pointer
75 * outside of a single instruction scope (i.e. long enough to display the value).
78 U_CFUNC
void *ctst_malloc(size_t size
);
81 * Return the path to cintltst's data ( icu/source/data/testdata ) directory.
82 * Return value is allocated by ctst_malloc and should not be deleted.
84 U_CFUNC
const char* loadTestData(UErrorCode
* err
);
87 * function used to specify the error
88 * converts the errorcode to an error descriptive string(const char*)
89 * @param status the error code
91 #define myErrorName(errorCode) u_errorName(errorCode)
95 * Call this once to get a consistent timezone. Use ctest_resetTimeZone to set it back to the original value.
96 * @param optionalTimeZone Set this to a requested timezone.
97 * Set to NULL to use the standard test timezone (Pacific Time)
99 U_CFUNC
void ctest_setTimeZone(const char *optionalTimeZone
, UErrorCode
*status
);
101 * Call this once get back the original timezone
103 U_CFUNC
void ctest_resetTimeZone(void);
106 * Call this once get ICU back to its original state with test arguments.
107 * This function calls u_cleanup.
109 U_CFUNC UBool
ctest_resetICU(void);
112 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
114 U_CFUNC UBool
assertSuccess(const char* msg
, UErrorCode
* ec
);
117 * Assert that the given UErrorCode succeeds, and return TRUE if it does.
118 * Give data error if UErrorCode fails and possibleDataError is TRUE.
120 U_CFUNC UBool
assertSuccessCheck(const char* msg
, UErrorCode
* ec
, UBool possibleDataError
);
123 * Assert that the UBool is TRUE, and return TRUE if it does.
125 * NOTE: Use 'int condition' rather than 'UBool condition' so the
126 * compiler doesn't complain about integral conversion of expressions
129 U_CFUNC UBool
assertTrue(const char* msg
, int condition
);
132 * Assert that the actualString equals the expectedString, and return
135 U_CFUNC UBool
assertEquals(const char* msg
, const char* expectedString
,
136 const char* actualString
);
139 * Assert that the actualString equals the expectedString, and return
142 U_CFUNC UBool
assertUEquals(const char* msg
, const UChar
* expectedString
,
143 const UChar
* actualString
);
146 * Assert that two 64-bit integers are equal, returning TRUE if they do.
148 U_CFUNC UBool
assertIntEquals(const char* msg
, int64_t expected
, int64_t actual
);
151 * note - isICUVersionBefore and isICUVersionAtLeast have been removed.
152 * use log_knownIssue() instead.