5 * (c) 1998 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /*----- Header files ------------------------------------------------------*/
47 /*----- Magical numbers ---------------------------------------------------*/
49 #define TEST_FIELDMAX 16 /* Maximum fields in a line */
51 /*----- Data structures ---------------------------------------------------*/
53 typedef struct test_results
{
54 unsigned tests
, failed
;
57 /* --- Test field definition --- */
59 typedef struct test_type
{
60 void (*cvt
)(const char *buf
, dstr
*d
); /* Conversion function */
61 void (*dump
)(dstr
*d
, FILE *fp
); /* Dump function */
64 /* --- Test chunk definition --- */
66 typedef struct test_chunk
{
67 const char *name
; /* Name of this chunk */
68 int (*test
)(dstr
/*dv*/[]); /* Test verification function */
69 const test_type
*f
[TEST_FIELDMAX
]; /* Field definitions */
72 typedef struct test_suite
{
73 const char *name
; /* Name of this suite */
74 const test_chunk
*chunks
; /* Chunks contained in this suite */
77 /*----- Predefined data types ---------------------------------------------*/
79 extern const test_type type_hex
;
80 extern const test_type type_string
;
81 extern const test_type type_int
;
82 extern const test_type type_long
;
83 extern const test_type type_ulong
;
84 extern const test_type type_uint32
;
86 /*----- Functions provided ------------------------------------------------*/
88 /* --- @test_do@ --- *
90 * Arguments: @const test_suite suites[]@ = pointer to suite definitions
91 * @FILE *fp@ = test vector file, ready opened
92 * @test_results *results@ = where to put results
94 * Returns: Negative if something bad happened, or the number of
97 * Use: Runs a collection of tests against a file of test vectors and
98 * reports the results.
101 extern int test_do(const test_suite
/*suite*/[],
103 test_results */
*results*/
);
105 /* --- @test_run@ --- *
107 * Arguments: @int argc@ = number of command line arguments
108 * @char *argv[]@ = pointer to command line arguments
109 * @const test_chunk chunk[]@ = pointer to chunk definitions
110 * @const char *def@ = name of default test vector file
114 * Use: Runs a set of test vectors to ensure that a component is
118 extern void test_run(int /*argc*/, char */
*argv*/
[],
119 const test_chunk
/*chunk*/[],
120 const char */
*def*/
);
122 /*----- That's all, folks -------------------------------------------------*/