1 /* $Id: testsuite.h,v 1.1.1.1 2003/06/04 00:27:03 marka Exp $ */
3 * Copyright (c) 2002 Japan Network Information Center.
6 * By using this file, you agree to the terms and conditions set forth bellow.
8 * LICENSE TERMS AND CONDITIONS
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.
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.
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.
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."
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
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.
45 #ifndef IDN_TESTSUITE_H
46 #define IDN_TESTSUITE_H 1
53 * Result codes for test case.
62 * Testsuite manager type (opaque).
64 typedef struct idn_testsuite *idn_testsuite_t;
67 * Testcase function type.
69 typedef void (*idn_testsuite_testproc_t)(idn_testsuite_t ctx);
72 * Message handler type.
74 typedef void (*idn_testsuite_msgproc_t)(const char *msg);
77 * Create a testsuite manager context.
79 * Create an empty context and store it in '*ctxp'.
80 * Return 1 on success. Return 0 if memory is exhausted.
83 idn_testsuite_create(idn_testsuite_t *ctxp);
86 * Destory the testsuite manager context.
88 * Destroy the context created by idn_testsuite_create(), and release
89 * memory allocated to the context.
92 idn_testsuite_destroy(idn_testsuite_t ctx);
95 * Add a test case to the `group' test group.
96 * Return 1 on success. Return 0 if memory is exhausted.
99 idn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title,
100 idn_testsuite_testproc_t proc);
103 * Return the number of test cases registered in the context.
106 idn_testsuite_ntestcases(idn_testsuite_t ctx);
109 * Run test cases registered in the context.
112 idn_testsuite_runall(idn_testsuite_t ctx);
114 idn_testsuite_run(idn_testsuite_t ctx, char *titles[]);
117 * Return the string description of `status'.
120 idn_teststatus_tostring(idn_teststatus_t status);
123 * Return the number of passed/failed/skipped test cases.
126 idn_testsuite_npassed(idn_testsuite_t ctx);
128 idn_testsuite_nfailed(idn_testsuite_t ctx);
130 idn_testsuite_nskipped(idn_testsuite_t ctx);
133 * Set/Get status of the test case running currently.
135 * These functions must be called by test case function.
137 extern idn_teststatus_t
138 idn_testsuite_getstatus(idn_testsuite_t ctx);
140 idn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status);
143 * Enable/Disable verbose mode.
146 idn_testsuite_setverbose(idn_testsuite_t ctx);
148 idn_testsuite_unsetverbose(idn_testsuite_t ctx);
151 * Generic assertion with message
154 idn_testsuite_assert(idn_testsuite_t ctx, const char *msg,
155 const char *file, int lineno);
157 #define ASSERT_THRU(msg) \
158 idn_testsuite_assert(ctx__, msg, __FILE__, __LINE__)
159 #define ASSERT(msg) \
162 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
167 * Assertion function and macro to compare two `int' values.
168 * The assertion passes if `gotten' is equal to `expected'.
171 idn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected,
172 const char *file, int lineno);
174 #define ASSERT_INT(gotten, expected) \
176 idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \
177 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
182 * Assertion function and macro to compare two strings.
183 * The assertion passes if `gotten' is lexically equal to `expected'.
186 idn_testsuite_assertstring(idn_testsuite_t ctx, const char *gotten,
187 const char *expected, const char *file, int lineno);
189 #define ASSERT_STRING(gotten, expected) \
191 idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \
192 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
197 * Assertion function and macro to compare two pointers.
198 * The assertion passes if `gotten' is equal to `expected'.
201 idn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten,
202 const void *expected, const char *file, int lineno);
204 #define ASSERT_PTR(gotten, expected) \
206 idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \
207 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
212 * Assertion function and macro to compare two pointers.
213 * The assertion passes if `gotten' is NOT equal to `expected'.
216 idn_testsuite_assertptrne(idn_testsuite_t ctx,
217 const void *gotten, const void *unexpected,
218 const char *file, int lineno);
220 #define ASSERT_PTR_NE(gotten, unexpected) \
222 idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \
223 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
228 * Assertion function and macro to compare two `idn_result_t' values.
229 * The assertion passes if `gotten' is equal to `expected'.
232 idn_testsuite_assertresult(idn_testsuite_t ctx,
233 idn_result_t gotten, idn_result_t expected,
234 const char *file, int lineno);
236 #define ASSERT_RESULT(gotten, expected) \
238 idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \
239 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
244 * Assertion function and macro to compare two UCS4 strings.
245 * The assertion passes if `gotten' is lexically equal to `expected'.
248 idn_testsuite_assertucs4string(idn_testsuite_t ctx,
249 const unsigned long *gotten,
250 const unsigned long *expected,
254 #define ASSERT_UCS4STRING_THRU(gotten, expected) \
255 idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__)
256 #define ASSERT_UCS4STRING(gotten, expected) \
258 ASSERT_UCS4STRING_THRU(gotten, expected); \
259 if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
266 #define SKIP_TESTCASE \
268 idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \
276 #endif /* IDN_TESTSUITE_H */