X-Git-Url: https://git.distorted.org.uk/~mdw/mLib/blobdiff_plain/0319f58d7cd0491452c0d43213bafe0914927bed..e109873133d224df7973bceedae82172924cd69e:/testrig.h diff --git a/testrig.h b/testrig.h index f026f4b..3729794 100644 --- a/testrig.h +++ b/testrig.h @@ -1,13 +1,11 @@ /* -*-c-*- * - * $Id: testrig.h,v 1.4 1999/07/06 19:15:28 mdw Exp $ - * * Generic test driver * * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the mLib utilities library. * @@ -15,37 +13,20 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * mLib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with mLib; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: testrig.h,v $ - * Revision 1.4 1999/07/06 19:15:28 mdw - * Comment out argument in structure definition. - * - * Revision 1.3 1999/05/06 19:51:35 mdw - * Reformatted the LGPL notice a little bit. - * - * Revision 1.2 1999/05/05 18:50:31 mdw - * Change licensing conditions to LGPL. - * - * Revision 1.1.1.1 1998/06/17 23:44:42 mdw - * Initial version of mLib - * - */ - -#ifndef TESTER_H -#define TESTER_H +#ifndef MLIB_TESTER_H +#define MLIB_TESTER_H #ifdef __cplusplus extern "C" { @@ -55,6 +36,7 @@ #include +#include "bits.h" #include "dstr.h" /*----- Magical numbers ---------------------------------------------------*/ @@ -63,6 +45,10 @@ /*----- Data structures ---------------------------------------------------*/ +typedef struct test_results { + unsigned tests, failed; +} test_results; + /* --- Test field definition --- */ typedef struct test_type { @@ -75,17 +61,42 @@ typedef struct test_type { typedef struct test_chunk { const char *name; /* Name of this chunk */ int (*test)(dstr /*dv*/[]); /* Test verification function */ - test_type *f[TEST_FIELDMAX]; /* Field definitions */ + const test_type *f[TEST_FIELDMAX]; /* Field definitions */ } test_chunk; +typedef struct test_suite { + const char *name; /* Name of this suite */ + const test_chunk *chunks; /* Chunks contained in this suite */ +} test_suite; + /*----- Predefined data types ---------------------------------------------*/ -extern test_type type_hex; -extern test_type type_string; -extern test_type type_int; +extern const test_type type_hex; +extern const test_type type_string; +extern const test_type type_int; +extern const test_type type_long; +extern const test_type type_ulong; +extern const test_type type_uint32; /*----- Functions provided ------------------------------------------------*/ +/* --- @test_do@ --- * + * + * Arguments: @const test_suite suites[]@ = pointer to suite definitions + * @FILE *fp@ = test vector file, ready opened + * @test_results *results@ = where to put results + * + * Returns: Negative if something bad happened, or the number of + * failures. + * + * Use: Runs a collection of tests against a file of test vectors and + * reports the results. + */ + +extern int test_do(const test_suite /*suite*/[], + FILE */*fp*/, + test_results */*results*/); + /* --- @test_run@ --- * * * Arguments: @int argc@ = number of command line arguments