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