chiark / gitweb /
buf: Fix two embarassing bugs found while writing Lisp bindings.
[mLib] / testrig.h
CommitLineData
0875b58f 1/* -*-c-*-
2 *
8656dc50 3 * $Id: testrig.h,v 1.7 2004/04/08 01:36:13 mdw Exp $
0875b58f 4 *
5 * Generic test driver
6 *
7 * (c) 1998 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
14 * mLib is free software; you can redistribute it and/or modify
c846879c 15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
0875b58f 18 *
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c846879c 22 * GNU Library General Public License for more details.
0875b58f 23 *
c846879c 24 * You should have received a copy of the GNU Library General Public
0bd98442 25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
0875b58f 28 */
29
dadc1afb 30#ifndef MLIB_TESTER_H
31#define MLIB_TESTER_H
0875b58f 32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/*----- Header files ------------------------------------------------------*/
38
39#include <stddef.h>
40
dadc1afb 41#include "bits.h"
0875b58f 42#include "dstr.h"
43
44/*----- Magical numbers ---------------------------------------------------*/
45
46#define TEST_FIELDMAX 16 /* Maximum fields in a line */
47
48/*----- Data structures ---------------------------------------------------*/
49
50/* --- Test field definition --- */
51
52typedef struct test_type {
53 void (*cvt)(const char *buf, dstr *d); /* Conversion function */
54 void (*dump)(dstr *d, FILE *fp); /* Dump function */
55} test_type;
56
57/* --- Test chunk definition --- */
58
59typedef struct test_chunk {
60 const char *name; /* Name of this chunk */
0319f58d 61 int (*test)(dstr /*dv*/[]); /* Test verification function */
d66299dc 62 const test_type *f[TEST_FIELDMAX]; /* Field definitions */
0875b58f 63} test_chunk;
64
65/*----- Predefined data types ---------------------------------------------*/
66
d66299dc 67extern const test_type type_hex;
68extern const test_type type_string;
69extern const test_type type_int;
dadc1afb 70extern const test_type type_long;
71extern const test_type type_ulong;
72extern const test_type type_uint32;
0875b58f 73
74/*----- Functions provided ------------------------------------------------*/
75
76/* --- @test_run@ --- *
77 *
78 * Arguments: @int argc@ = number of command line arguments
79 * @char *argv[]@ = pointer to command line arguments
80 * @const test_chunk chunk[]@ = pointer to chunk definitions
81 * @const char *def@ = name of default test vector file
82 *
83 * Returns: Doesn't.
84 *
85 * Use: Runs a set of test vectors to ensure that a component is
86 * working properly.
87 */
88
89extern void test_run(int /*argc*/, char */*argv*/[],
90 const test_chunk /*chunk*/[],
91 const char */*def*/);
92
93/*----- That's all, folks -------------------------------------------------*/
94
95#ifdef __cplusplus
96 }
97#endif
98
99#endif