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 */
5 * Copyright (c) 2002 Japan Network Information Center.
8 * By using this file, you agree to the terms and conditions set forth bellow.
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
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
55 * Result codes for test case.
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.
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.
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.
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.
108 idn_testsuite_ntestcases(idn_testsuite_t ctx
);
111 * Run test cases registered in the context.
114 idn_testsuite_runall(idn_testsuite_t ctx
);
116 idn_testsuite_run(idn_testsuite_t ctx
, char *titles
[]);
119 * Return the string description of `status'.
122 idn_teststatus_tostring(idn_teststatus_t status
);
125 * Return the number of passed/failed/skipped test cases.
128 idn_testsuite_npassed(idn_testsuite_t ctx
);
130 idn_testsuite_nfailed(idn_testsuite_t ctx
);
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
);
142 idn_testsuite_setstatus(idn_testsuite_t ctx
, idn_teststatus_t status
);
145 * Enable/Disable verbose mode.
148 idn_testsuite_setverbose(idn_testsuite_t ctx
);
150 idn_testsuite_unsetverbose(idn_testsuite_t ctx
);
153 * Generic assertion with message
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) \
164 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
166 } while (/*CONSTCOND*/0)
169 * Assertion function and macro to compare two `int' values.
170 * The assertion passes if `gotten' is equal to `expected'.
173 idn_testsuite_assertint(idn_testsuite_t ctx
, int gotten
, int expected
,
174 const char *file
, int lineno
);
176 #define ASSERT_INT(gotten, expected) \
178 idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \
179 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
181 } while (/*CONSTCOND*/0)
184 * Assertion function and macro to compare two strings.
185 * The assertion passes if `gotten' is lexically equal to `expected'.
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) \
193 idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \
194 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
196 } while (/*CONSTCOND*/0)
199 * Assertion function and macro to compare two pointers.
200 * The assertion passes if `gotten' is equal to `expected'.
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) \
208 idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \
209 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
211 } while (/*CONSTCOND*/0)
214 * Assertion function and macro to compare two pointers.
215 * The assertion passes if `gotten' is NOT equal to `expected'.
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) \
224 idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \
225 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
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'.
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) \
240 idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \
241 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
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'.
250 idn_testsuite_assertucs4string(idn_testsuite_t ctx
,
251 const unsigned long *gotten
,
252 const unsigned long *expected
,
256 #define ASSERT_UCS4STRING_THRU(gotten, expected) \
257 idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__)
258 #define ASSERT_UCS4STRING(gotten, expected) \
260 ASSERT_UCS4STRING_THRU(gotten, expected); \
261 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
263 } while (/*CONSTCOND*/0)
268 #define SKIP_TESTCASE \
270 idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \
272 } while (/*CONSTCOND*/0)
278 #endif /* IDN_TESTSUITE_H */