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 18The 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#include <stdlib.h> 29 30#ifndef U_USE_DEPRECATED_API 31#define U_USE_DEPRECATED_API 1 32#endif 33 34U_CFUNC void addAllTests(TestNode** root); 35 36/** 37 * Return the path to the icu/source/data/out directory 38 */ 39U_CFUNC const char* ctest_dataOutDir(void); 40 41/** 42 * Return the path to the icu/source/data/ directory 43 * for out of source builds too returns the source directory 44 */ 45U_CFUNC const char* ctest_dataSrcDir(void); 46 47/** 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. 50 */ 51U_CFUNC UChar* CharsToUChars(const char* chars); 52 53/** 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 58 */ 59 60U_CFUNC char *austrdup(const UChar* unichars); 61 62/** 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 68 */ 69U_CFUNC char *aescstrdup(const UChar* unichars, int32_t length); 70 71/** 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). 76 * @see #ctst_freeAll 77 */ 78U_CFUNC void *ctst_malloc(size_t size); 79 80/** 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. 83 */ 84U_CFUNC const char* loadTestData(UErrorCode* err); 85 86/** 87 * function used to specify the error 88 * converts the errorcode to an error descriptive string(const char*) 89 * @param status the error code 90 */ 91#define myErrorName(errorCode) u_errorName(errorCode) 92 93 94/** 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) 98 */ 99U_CFUNC void ctest_setTimeZone(const char *optionalTimeZone, UErrorCode *status); 100/** 101 * Call this once get back the original timezone 102 */ 103U_CFUNC void ctest_resetTimeZone(void); 104 105/** 106 * Call this once get ICU back to its original state with test arguments. 107 * This function calls u_cleanup. 108 */ 109U_CFUNC UBool ctest_resetICU(void); 110 111/** 112 * Assert that the given UErrorCode succeeds, and return TRUE if it does. 113 */ 114U_CFUNC UBool assertSuccess(const char* msg, UErrorCode* ec); 115 116/** 117 * Assert that the given UErrorCode succeeds, and return TRUE if it does. 118 * Give data error if UErrorCode fails and possibleDataError is TRUE. 119 */ 120U_CFUNC UBool assertSuccessCheck(const char* msg, UErrorCode* ec, UBool possibleDataError); 121 122/** 123 * Assert that the UBool is TRUE, and return TRUE if it does. 124 * 125 * NOTE: Use 'int condition' rather than 'UBool condition' so the 126 * compiler doesn't complain about integral conversion of expressions 127 * like 'p != 0'. 128 */ 129U_CFUNC UBool assertTrue(const char* msg, int condition); 130 131/** 132 * Assert that the actualString equals the expectedString, and return 133 * TRUE if it does. 134 */ 135U_CFUNC UBool assertEquals(const char* msg, const char* expectedString, 136 const char* actualString); 137 138/* 139 * note - isICUVersionBefore and isICUVersionAtLeast have been removed. 140 * use log_knownIssue() instead. 141 */ 142 143#endif 144