]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ***************************************************************************************** | |
3 | * | |
4 | * Copyright (C) 1996-2000, International Business Machines | |
5 | * Corporation and others. All Rights Reserved. | |
6 | * | |
7 | ***************************************************************************************** | |
8 | */ | |
9 | ||
10 | ||
11 | #ifndef CTEST_H | |
12 | #define CTEST_H | |
13 | ||
14 | #include "unicode/utypes.h" | |
15 | ||
16 | /*Deals with imports and exports of the dynamic library*/ | |
17 | #if defined(_WIN32) || defined(U_CYGWIN) | |
18 | #define T_CTEST_EXPORT __declspec(dllexport) | |
19 | #define T_CTEST_IMPORT __declspec(dllimport) | |
20 | #else | |
21 | #define T_CTEST_EXPORT | |
22 | #define T_CTEST_IMPORT | |
23 | #endif | |
24 | ||
25 | #ifdef __cplusplus | |
26 | #define C_CTEST_API extern "C" | |
27 | #else | |
28 | #define C_CTEST_API | |
29 | #endif | |
30 | ||
31 | #ifdef T_CTEST_IMPLEMENTATION | |
32 | #define T_CTEST_API C_CTEST_API T_CTEST_EXPORT | |
33 | #define T_CTEST_EXPORT_API T_CTEST_EXPORT | |
34 | #else | |
35 | #define T_CTEST_API C_CTEST_API T_CTEST_IMPORT | |
36 | #define T_CTEST_EXPORT_API T_CTEST_IMPORT | |
37 | #endif | |
38 | ||
39 | ||
40 | ||
41 | /* True and false for sanity. (removes ICU dependancy) */ | |
42 | ||
43 | #ifndef FALSE | |
44 | #define FALSE 0 | |
45 | #endif | |
46 | #ifndef TRUE | |
47 | #define TRUE 1 | |
48 | #endif | |
49 | ||
50 | ||
51 | ||
52 | ||
53 | /* prototypes *********************************/ | |
54 | ||
55 | typedef void (*TestFunctionPtr)(void); | |
56 | typedef struct TestNode TestNode; | |
57 | ||
58 | /** | |
59 | * Set this to zero to disable log_verbose() messages. | |
60 | * Otherwise nonzero to see log_verbose() messages. | |
61 | * | |
62 | * @internal Internal APIs for testing purpose only | |
63 | */ | |
64 | T_CTEST_EXPORT_API extern int REPEAT_TESTS; | |
65 | ||
66 | /** | |
67 | * Set this to zero to disable log_verbose() messages. | |
68 | * Otherwise nonzero to see log_verbose() messages. | |
69 | * | |
70 | * @internal Internal APIs for testing purpose only | |
71 | */ | |
72 | T_CTEST_EXPORT_API extern int VERBOSITY; | |
73 | ||
74 | /** | |
75 | * Set this to zero to disable log_verbose() messages. | |
76 | * Otherwise nonzero to see log_verbose() messages. | |
77 | * | |
78 | * @internal Internal APIs for testing purpose only | |
79 | */ | |
80 | T_CTEST_EXPORT_API extern int ERR_MSG; | |
81 | ||
82 | /** | |
83 | * Set this to zero to disable some of the slower tests. | |
84 | * Otherwise nonzero to run the slower tests. | |
85 | * | |
86 | * @internal Internal APIs for testing purpose only | |
87 | */ | |
88 | T_CTEST_EXPORT_API extern int QUICK; | |
89 | ||
90 | /** | |
91 | * Set this to nonzero to warn (not error) on missing data. | |
92 | * Otherwise, zero will cause an error to be propagated when data is not available. | |
93 | * Affects the behavior of log_dataerr. | |
94 | * | |
95 | * @see log_data_err | |
96 | * @internal Internal APIs for testing purpose only | |
97 | */ | |
98 | T_CTEST_EXPORT_API extern int WARN_ON_MISSING_DATA; | |
99 | ||
100 | /** | |
101 | * Show the names of all nodes. | |
102 | * | |
103 | * @param root Subtree of tests. | |
104 | * @internal Internal APIs for testing purpose only | |
105 | */ | |
106 | T_CTEST_API void showTests ( const TestNode *root); | |
107 | ||
108 | /** | |
109 | * Run a subtree of tests. | |
110 | * | |
111 | * @param root Subtree of tests. | |
112 | * @internal Internal APIs for testing purpose only | |
113 | */ | |
114 | T_CTEST_API void runTests ( const TestNode* root); | |
115 | ||
116 | /** | |
117 | * Add a test to the subtree. | |
118 | * Example usage: | |
119 | * <PRE> | |
120 | * TestNode* root=NULL; | |
121 | * addTest(&root, &mytest, "/a/b/mytest" ); | |
122 | * </PRE> | |
123 | * @param root Pointer to the root pointer. | |
124 | * @param test Pointer to 'void function(void)' for actual test. | |
125 | * @param path Path from root under which test will be placed. Ex. '/a/b/mytest' | |
126 | * @internal Internal APIs for testing purpose only | |
127 | */ | |
128 | T_CTEST_API void addTest ( TestNode** root, | |
129 | TestFunctionPtr test, | |
130 | const char *path); | |
131 | ||
132 | T_CTEST_API void cleanUpTestTree(TestNode *tn); | |
133 | ||
134 | /** | |
135 | * Retreive a specific subtest. (subtree). | |
136 | * | |
137 | * @param root Pointer to the root. | |
138 | * @param path Path relative to the root, Ex. '/a/b' | |
139 | * @return The subtest, or NULL on failure. | |
140 | * @internal Internal APIs for testing purpose only | |
141 | */ | |
142 | T_CTEST_API const TestNode* getTest (const TestNode* root, | |
143 | const char *path); | |
144 | ||
145 | ||
146 | /** | |
147 | * Log an error message. (printf style) | |
148 | * @param pattern printf-style format string | |
149 | * @internal Internal APIs for testing purpose only | |
150 | */ | |
151 | T_CTEST_API void log_err(const char* pattern, ...); | |
152 | ||
153 | /** | |
154 | * Log an informational message. (printf style) | |
155 | * @param pattern printf-style format string | |
156 | * @internal Internal APIs for testing purpose only | |
157 | */ | |
158 | T_CTEST_API void log_info(const char* pattern, ...); | |
159 | ||
160 | /** | |
161 | * Log a verbose informational message. (printf style) | |
162 | * This message will only appear if the global VERBOSITY is nonzero | |
163 | * @param pattern printf-style format string | |
164 | * @internal Internal APIs for testing purpose only | |
165 | */ | |
166 | T_CTEST_API void log_verbose(const char* pattern, ...); | |
167 | ||
168 | /** | |
169 | * Log an error message concerning missing data. (printf style) | |
170 | * If WARN_ON_MISSING_DATA is nonzero, this will case a log_info (warning) to be | |
171 | * printed, but if it is zero this will produce an error (log_err). | |
172 | * @param pattern printf-style format string | |
173 | * @internal Internal APIs for testing purpose only | |
174 | */ | |
175 | T_CTEST_API void log_data_err(const char *pattern, ...); | |
176 | ||
177 | /** | |
178 | * Processes the command line arguments. | |
179 | * This is a sample implementation | |
180 | * <PRE>Usage: %s [ -l ] [ -v ] [ -? ] [ /path/to/test ] | |
181 | * -l List only, do not run\ | |
182 | * -v turn OFF verbosity | |
183 | * -? print this message</PRE> | |
184 | * @param root Testnode root with tests already attached to it | |
185 | * @param argv argument list from main (stdio.h) | |
186 | * @param argc argument list count from main (stdio.h) | |
187 | * @return positive for error count, 0 for success, negative for illegal argument | |
188 | * @internal Internal APIs for testing purpose only | |
189 | */ | |
190 | ||
191 | T_CTEST_API int processArgs(const TestNode* root, | |
192 | int argc, | |
193 | const char* const argv[]); | |
194 | ||
195 | ||
196 | T_CTEST_API | |
197 | const char* getTestName(void); | |
198 | ||
199 | ||
200 | ||
201 | #endif |