@@@ wip type definitions in manpage synopses
[mLib] / test / testrig.3
index b996617..07e1f48 100644 (file)
@@ -19,12 +19,43 @@ testrig \- generic test rig
 .nf
 .B "#include <mLib/testrig.h>"
 
-.BI "void test_do(const test_suite " suite [],
-.BI "             FILE *" fp ,
-.BI "             test_results *" results );
-.BI "void test_run(int " argc ", char *" argv [],
-.BI "              const test_chunk " chunk [],
-.BI "              const char *" def );
+.B "#define TEST_FIELDMAX ..."
+
+.B "typedef struct {"
+.B "\h'4n'unsigned tests, failed;"
+.B "} test_results";
+
+.B "typedef struct {"
+.BI "\h'4n'void (*cvt)(const char *" buf ", dstr *" d );
+.BI "\h'4n'void (*dump)(dstr *" d ", FILE *" fp );
+.B "} test_type";
+
+.B "typedef struct {"
+.B "\h'4n'const char *name;"
+.BI "\h'4n'void (*test)(dstr " dv "[]);"
+.B "\h'4n'const test_type *f[TEST_FIELDMAX];"
+.B "} test_chunk";
+
+.B "typedef struct {"
+.B "\h'4n'const char *name;"
+.B "\h'4n'const test_chunk *chunks;"
+.B "} test_suite";
+
+.B "const test_type type_hex;"
+.B "const test_type type_string;"
+.B "const test_type type_int;"
+.B "const test_type type_long;"
+.B "const test_type type_ulong;"
+.B "const test_type type_uint32;"
+
+.ds mT \fBint test_do(
+.BI "\*(mTconst test_suite " suite [],
+.BI "\h'\w'\*(mT'u'FILE *" fp ,
+.BI "\h'\w'\*(mT'u'test_results *" results );
+.ds mT \fBvoid test_run(
+.BI "\*(mTint " argc ", char *" argv [],
+.BI "\h'\w'\*(mT'u'const test_chunk " chunk [],
+.BI "\h'\w'\*(mT'u'const char *" def );
 .fi
 .SH DESCRIPTION
 .SS Structure
@@ -121,14 +152,9 @@ following character.
 .SS "Suite definitions"
 A
 .I suite definition
-is described by the structure
-.VS
-typedef struct test_suite {
-  const char *name;             /* Name of this suite */
-  const test_chunk *chunks;     /* Pointer to chunks */
-} test_suite;
-.VE
-The
+is described by the
+.B test_suite
+structure.  The
 .I suite
 argument to
 .B test_do
@@ -143,21 +169,15 @@ required and the function to call in order to test the system against
 that test vector.  The array is terminated by a chunk definition whose
 name field is a null pointer.
 .PP
-A chunk definition is described by the following structure:
-.VS
-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 */
-} test_chunk;
-.VE
-The members of this structure are as follows:
+A chunk definition is described by the
+.B test_chunk
+structure.  The members of this structure are as follows:
 .TP
 .B "const char *name"
 The name of the chunk described by this chunk definition, or null if
 this is the termination marker.
 .TP
-.B "int (*test)(dstr dv[])"
+.BI "int (*test)(dstr " dv "[])"
 The test function.  It is passed an array of dynamic strings, one for
 each field, and must return nonzero if the test succeeded or zero if the
 test failed.  On success, the function should not write anything to
@@ -175,14 +195,9 @@ designated field type, and then passing the completed array of fields to
 the test function.
 .SS "Field types"
 A field type describes how a field is to be read and written.  A field
-type is described by a structure:
-.VS
-typedef struct test_type {
-  void (*cvt)(const char *buf, dstr *d);
-  void (*dump)(dstr *d, FILE *fp);
-} test_type;
-.VE
-The
+type is described by a
+.B test_type
+structure.  The
 .B cvt
 member is a function called to read an input string stored in
 .B buf