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