5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* $Id: testsuite.h,v 1.1 2003/06/04 00:27:03 marka Exp $ */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright (c) 2002 Japan Network Information Center.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * By using this file, you agree to the terms and conditions set forth bellow.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LICENSE TERMS AND CONDITIONS
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The following License Terms and Conditions apply, unless a different
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * license is obtained from Japan Network Information Center ("JPNIC"),
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Chiyoda-ku, Tokyo 101-0047, Japan.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 1. Use, Modification and Redistribution (including distribution of any
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * modified or derived work) in source and/or binary forms is permitted
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * under this License Terms and Conditions.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 2. Redistribution of source code must retain the copyright notices as they
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * appear in each source code file, this License Terms and Conditions.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 3. Redistribution in binary form must reproduce the Copyright Notice,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * this License Terms and Conditions, in the documentation and/or other
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * materials provided with the distribution. For the purposes of binary
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * distribution the "Copyright Notice" refers to the following language:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 4. The name of JPNIC may not be used to endorse or promote products
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * derived from this Software without specific prior written approval of
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * JPNIC.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifndef IDN_TESTSUITE_H
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define IDN_TESTSUITE_H 1
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef __cplusplus
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern "C" {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#endif
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Result codes for test case.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef enum {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_teststatus_pass,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_teststatus_fail,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_teststatus_skip
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews} idn_teststatus_t;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Testsuite manager type (opaque).
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef struct idn_testsuite *idn_testsuite_t;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Testcase function type.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef void (*idn_testsuite_testproc_t)(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Message handler type.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstypedef void (*idn_testsuite_msgproc_t)(const char *msg);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Create a testsuite manager context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Create an empty context and store it in '*ctxp'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Return 1 on success. Return 0 if memory is exhausted.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_create(idn_testsuite_t *ctxp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Destory the testsuite manager context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Destroy the context created by idn_testsuite_create(), and release
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * memory allocated to the context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_destroy(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Add a test case to the `group' test group.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Return 1 on success. Return 0 if memory is exhausted.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_addtestcase(idn_testsuite_t ctx, const char *title,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_testproc_t proc);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Return the number of test cases registered in the context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_ntestcases(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Run test cases registered in the context.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_runall(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_run(idn_testsuite_t ctx, char *titles[]);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Return the string description of `status'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern const char *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_teststatus_tostring(idn_teststatus_t status);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Return the number of passed/failed/skipped test cases.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_npassed(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_nfailed(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern int
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_nskipped(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Set/Get status of the test case running currently.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * These functions must be called by test case function.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern idn_teststatus_t
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_getstatus(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_setstatus(idn_testsuite_t ctx, idn_teststatus_t status);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Enable/Disable verbose mode.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_setverbose(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_unsetverbose(idn_testsuite_t ctx);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Generic assertion with message
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assert(idn_testsuite_t ctx, const char *msg,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_THRU(msg) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assert(ctx__, msg, __FILE__, __LINE__)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT(msg) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_THRU(msg); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two `int' values.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertint(idn_testsuite_t ctx, int gotten, int expected,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_INT(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertint(ctx__, gotten, expected, __FILE__, __LINE__); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two strings.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is lexically equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertstring(idn_testsuite_t ctx, const char *gotten,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *expected, const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_STRING(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertstring(ctx__, gotten, expected, __FILE__, __LINE__); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two pointers.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertptr(idn_testsuite_t ctx, const void *gotten,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const void *expected, const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_PTR(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertptr(ctx__, gotten, expected, __FILE__, __LINE__); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two pointers.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is NOT equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertptrne(idn_testsuite_t ctx,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const void *gotten, const void *unexpected,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_PTR_NE(gotten, unexpected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertptrne(ctx__, gotten, unexpected, __FILE__, __LINE__); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two `idn_result_t' values.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertresult(idn_testsuite_t ctx,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_result_t gotten, idn_result_t expected,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *file, int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_RESULT(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertresult(ctx__, gotten, expected, __FILE__, __LINE__); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Assertion function and macro to compare two UCS4 strings.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The assertion passes if `gotten' is lexically equal to `expected'.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsextern void
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsidn_testsuite_assertucs4string(idn_testsuite_t ctx,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long *gotten,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const unsigned long *expected,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews const char *file,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int lineno);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_UCS4STRING_THRU(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_assertucs4string(ctx__, gotten, expected, __FILE__, __LINE__)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define ASSERT_UCS4STRING(gotten, expected) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ASSERT_UCS4STRING_THRU(gotten, expected); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (idn_testsuite_getstatus(ctx__) != idn_teststatus_pass) \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Shorthands.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#define SKIP_TESTCASE \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do { \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews idn_testsuite_setstatus(ctx__, idn_teststatus_skip); \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto EXIT__; \
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#ifdef __cplusplus
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews}
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#endif
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#endif /* IDN_TESTSUITE_H */