home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / tools / ctestfw / ctest.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  4.3 KB  |  153 lines

  1. /*  
  2. *****************************************************************************************
  3. *                                                                                       *
  4. * COPYRIGHT:                                                                            *
  5. *   (C) Copyright Taligent, Inc.,  1996, 1997                                           *
  6. *   (C) Copyright International Business Machines Corporation,  1999                    *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.                  *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure             *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                              *
  10. *                                                                                       *
  11. *****************************************************************************************
  12. */
  13.  
  14.  
  15. #ifndef CTEST_H
  16. #define CTEST_H
  17.  
  18.  
  19. /*Deals with imports and exports of the dynamic library*/
  20. #ifdef _WIN32
  21.     #define T_CTEST_EXPORT __declspec(dllexport)
  22.     #define T_CTEST_IMPORT __declspec(dllimport)
  23. #else
  24.     #define T_CTEST_EXPORT
  25.     #define T_CTEST_IMPORT
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29.     #define C_CTEST_API extern "C"
  30. #else
  31.     #define C_CTEST_API
  32. #endif 
  33.  
  34. #ifdef T_CTEST_IMPLEMENTATION
  35.     #define T_CTEST_API C_CTEST_API  T_CTEST_EXPORT
  36.     #define T_CTEST_EXPORT_API T_CTEST_EXPORT
  37. #else
  38.     #define T_CTEST_API C_CTEST_API  T_CTEST_IMPORT
  39.     #define T_CTEST_EXPORT_API T_CTEST_IMPORT
  40. #endif
  41.  
  42.  
  43.  
  44. /* True and false for sanity. (removes ICU dependancy) */
  45.  
  46. #ifndef FALSE
  47. #define FALSE 0
  48. #endif
  49. #ifndef TRUE
  50. #define TRUE 1
  51. #endif
  52.  
  53.  
  54.  
  55.  
  56. /* prototypes *********************************/
  57.  
  58. typedef void (*TestFunctionPtr)();
  59. typedef struct TestNode TestNode;
  60.  
  61. /**
  62.  * Count of errors from all tests. May be reset.
  63.  */
  64. T_CTEST_EXPORT_API extern int ERROR_COUNT;
  65.  
  66. /**
  67.  * Set this to zero to disable log_verbose() messages, otherwise
  68.  * nonzero to see log_verbose() messages.
  69.  */
  70. T_CTEST_EXPORT_API extern int VERBOSITY;  
  71. /**
  72.  * Set this to zero to disable log_verbose() messages, otherwise
  73.  * nonzero to see log_verbose() messages.
  74.  */
  75. T_CTEST_EXPORT_API extern int ERR_MSG; 
  76. /**
  77.  * Show the names of all nodes.
  78.  * @param root Subtree of tests.
  79.  */
  80. T_CTEST_API void showTests ( const TestNode *root);
  81.  
  82. /**
  83.  * Run a subtree of tests.
  84.  * @param root Subtree of tests.
  85.  */
  86. T_CTEST_API void runTests ( const TestNode* root);
  87.  
  88. /**
  89.  * Add a test to the subtree.
  90.  * Example usage:
  91.  * <PRE>
  92.  *     TestNode* root=NULL;
  93.  *     addTest(&root, &mytest, "/a/b/mytest" );
  94.  * </PRE>
  95.  * @param root Pointer to the root pointer.
  96.  * @param test Pointer to 'void function(void)' for actual test.
  97.  * @param path Path from root under which test will be placed. Ex. '/a/b/mytest'
  98.  */
  99. T_CTEST_API void addTest ( TestNode** root,
  100.            TestFunctionPtr test,
  101.            const char *path);
  102.  
  103. /**
  104.  * Retreive a specific subtest (subtree)
  105.  * @param root Pointer to the root.
  106.  * @param path Path relative to the root, Ex. '/a/b'
  107.  * @return The subtest, or NULL on failure.
  108.  */
  109. T_CTEST_API const TestNode* getTest (const TestNode* root,
  110.                                      const char *path);
  111.  
  112.  
  113. /**
  114.  * Log an error message. (printf style)
  115.  * @param pattern printf-style format string
  116.  */
  117. T_CTEST_API void log_err(const char* pattern, ...);
  118.  
  119. /**
  120.  * Log an informational message. (printf style)
  121.  * @param pattern printf-style format string
  122.  */
  123. T_CTEST_API void log_info(const char* pattern, ...);
  124.  
  125. /**
  126.  * Log a verbose informational message. (printf style)
  127.  * This message will only appear if the global VERBOSITY is nonzero
  128.  * @param pattern printf-style format string
  129.  */
  130. T_CTEST_API void log_verbose(const char* pattern, ...);
  131.  
  132. /**
  133.  * Processes the command line arguments.
  134.  * This is a sample implementation
  135.  * <PRE>Usage: %s [ -l ] [ -v ] [ -? ] [ /path/to/test ]
  136.  *        -l List only, do not run\
  137.  *        -v turn OFF verbosity
  138.  *        -? print this message</PRE>
  139.  * @param root Testnode root with tests already attached to it
  140.  * @param argv argument list from main (stdio.h)
  141.  * @param argc argument list count from main (stdio.h)
  142.  * @return positive for error count, 0 for success, negative for illegal argument
  143.  */
  144.  
  145. T_CTEST_API int processArgs(const TestNode* root,
  146.                              int argc,
  147.                              const char** argv);
  148.  
  149.  
  150.  
  151.  
  152. #endif
  153.