ignore some files
[tridge/bind9.git] / contrib / idn / idnkit-1.0-src / lib / tests / testsuite.h
1 /* $Id: testsuite.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */
2 /*
3  * Copyright (c) 2002 Japan Network Information Center.
4  * All rights reserved.
5  *  
6  * By using this file, you agree to the terms and conditions set forth bellow.
7  * 
8  *                      LICENSE TERMS AND CONDITIONS 
9  * 
10  * The following License Terms and Conditions apply, unless a different
11  * license is obtained from Japan Network Information Center ("JPNIC"),
12  * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
13  * Chiyoda-ku, Tokyo 101-0047, Japan.
14  * 
15  * 1. Use, Modification and Redistribution (including distribution of any
16  *    modified or derived work) in source and/or binary forms is permitted
17  *    under this License Terms and Conditions.
18  * 
19  * 2. Redistribution of source code must retain the copyright notices as they
20  *    appear in each source code file, this License Terms and Conditions.
21  * 
22  * 3. Redistribution in binary form must reproduce the Copyright Notice,
23  *    this License Terms and Conditions, in the documentation and/or other
24  *    materials provided with the distribution.  For the purposes of binary
25  *    distribution the "Copyright Notice" refers to the following language:
26  *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
27  * 
28  * 4. The name of JPNIC may not be used to endorse or promote products
29  *    derived from this Software without specific prior written approval of
30  *    JPNIC.
31  * 
32  * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
33  *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
35  *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
36  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41  *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
42  *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
43  */
44
45 #ifndef IDN_TESTSUITE_H
46 #define IDN_TESTSUITE_H 1
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 /*
53  * Result codes for test case.
54  */
55 typedef enum {
56         idn_teststatus_pass,
57         idn_teststatus_fail,
58         idn_teststatus_skip
59 } idn_teststatus_t;
60
61 /*
62  * Testsuite manager type (opaque).
63  */
64 typedef struct idn_testsuite *idn_testsuite_t;
65
66 /*
67  * Testcase function type.
68  */
69 typedef void (*idn_testsuite_testproc_t)(idn_testsuite_t ctx);
70
71 /*
72  * Message handler type.
73  */
74 typedef void (*idn_testsuite_msgproc_t)(const char *msg);
75
76 /*
77  * Create a testsuite manager context.
78  *
79  * Create an empty context and store it in '*ctxp'.
80  * Return 1 on success.  Return 0 if memory is exhausted.
81  */
82 extern int
83 idn_testsuite_create(idn_testsuite_t *ctxp);
84
85 /*
86  * Destory the testsuite manager context.
87  *
88  * Destroy the context created by idn_testsuite_create(), and release
89  * memory allocated to the context.
90  */
91 extern void
92 idn_testsuite_destroy(idn_testsuite_t ctx);
93
94 /*
95  * Add a test case to the `group' test group.
96  * Return 1 on success.  Return 0 if memory is exhausted.
97  */
98 extern int
99 idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title,
100                           idn_testsuite_testproc_t proc);
101
102 /*
103  * Return the number of test cases registered in the context.
104  */
105 extern int
106 idn_testsuite_ntestcases(idn_testsuite_t ctx);
107
108 /*
109  * Run test cases registered in the context.
110  */
111 extern void
112 idn_testsuite_runall(idn_testsuite_t ctx);
113 extern void
114 idn_testsuite_run(idn_testsuite_t ctx, char *titles[]);
115
116 /*
117  * Return the string description of `status'.
118  */
119 extern const char *
120 idn_teststatus_tostring(idn_teststatus_t status);
121
122 /*
123  * Return the number of passed/failed/skipped test cases.
124  */
125 extern int
126 idn_testsuite_npassed(idn_testsuite_t ctx);
127 extern int
128 idn_testsuite_nfailed(idn_testsuite_t ctx);
129 extern int
130 idn_testsuite_nskipped(idn_testsuite_t ctx);
131
132 /*
133  * Set/Get status of the test case running currently.
134  *
135  * These functions must be called by test case function.
136  */
137 extern idn_teststatus_t
138 idn_testsuite_getstatus(idn_testsuite_t ctx);
139 extern void
140 idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status);
141
142 /*
143  * Enable/Disable verbose mode.
144  */
145 extern void
146 idn_testsuite_setverbose(idn_testsuite_t ctx);
147 extern void
148 idn_testsuite_unsetverbose(idn_testsuite_t ctx);
149
150 /*
151  * Generic assertion with message
152  */
153 extern void
154 idn_testsuite_assert(idn_testsuite_t ctx, const char *msg,
155                      const char *file, int lineno);
156
157 #define ASSERT_THRU(msg) \
158     idn_testsuite_assert(ctx__, msg, __FILE__, __LINE__)
159 #define ASSERT(msg) \
160   do { \
161     ASSERT_THRU(msg); \
162     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
163       goto EXIT__; \
164   } while (0)
165
166 /*
167  * Assertion function and macro to compare two `int' values.
168  * The assertion passes if `gotten' is equal to `expected'.
169  */
170 extern void
171 idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected,
172                         const char *file, int lineno);
173
174 #define ASSERT_INT(gotten, expected) \
175   do { \
176     idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \
177     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
178       goto EXIT__; \
179   } while (0)
180
181 /*
182  * Assertion function and macro to compare two strings.
183  * The assertion passes if `gotten' is lexically equal to `expected'.
184  */
185 extern void
186 idn_testsuite_assertstring(idn_testsuite_t ctx, const char *gotten, 
187                            const char *expected, const char *file, int lineno);
188
189 #define ASSERT_STRING(gotten, expected) \
190   do { \
191     idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \
192     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
193       goto EXIT__; \
194   } while (0)
195
196 /*
197  * Assertion function and macro to compare two pointers.
198  * The assertion passes if `gotten' is equal to `expected'.
199  */
200 extern void
201 idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten, 
202                         const void *expected, const char *file, int lineno);
203
204 #define ASSERT_PTR(gotten, expected) \
205   do { \
206     idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \
207     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
208       goto EXIT__; \
209   } while (0)
210
211 /*
212  * Assertion function and macro to compare two pointers.
213  * The assertion passes if `gotten' is NOT equal to `expected'.
214  */
215 extern void
216 idn_testsuite_assertptrne(idn_testsuite_t ctx, 
217                           const void *gotten, const void *unexpected,
218                           const char *file, int lineno);
219
220 #define ASSERT_PTR_NE(gotten, unexpected) \
221   do { \
222     idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \
223     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
224       goto EXIT__; \
225   } while (0)
226
227 /*
228  * Assertion function and macro to compare two `idn_result_t' values.
229  * The assertion passes if `gotten' is equal to `expected'.
230  */
231 extern void
232 idn_testsuite_assertresult(idn_testsuite_t ctx,
233                            idn_result_t gotten, idn_result_t expected,
234                            const char *file, int lineno);
235
236 #define ASSERT_RESULT(gotten, expected) \
237   do { \
238     idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \
239     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
240       goto EXIT__; \
241   } while (0)
242
243 /*
244  * Assertion function and macro to compare two UCS4 strings.
245  * The assertion passes if `gotten' is lexically equal to `expected'.
246  */
247 extern void
248 idn_testsuite_assertucs4string(idn_testsuite_t ctx,
249                                const unsigned long *gotten, 
250                                const unsigned long *expected,
251                                const char *file,
252                                int lineno);
253
254 #define ASSERT_UCS4STRING_THRU(gotten, expected) \
255   idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__)
256 #define ASSERT_UCS4STRING(gotten, expected) \
257   do { \
258     ASSERT_UCS4STRING_THRU(gotten, expected); \
259     if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
260       goto EXIT__; \
261   } while (0)
262
263 /* 
264  * Shorthands.
265  */
266 #define SKIP_TESTCASE \
267   do { \
268        idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \
269        goto EXIT__; \
270   } while (0)
271
272 #ifdef __cplusplus
273 }
274 #endif
275
276 #endif /* IDN_TESTSUITE_H */