chiark / gitweb /
Expunge revision histories in files.
[mLib] / testrig.c
index df7a0313496e3492af3b6c5071a102492b4dffef..4b6980192d7785ec0c6728c3568ceadc8f1ea086 100644 (file)
--- a/testrig.c
+++ b/testrig.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: testrig.c,v 1.7 1999/11/21 13:01:39 mdw Exp $
+ * $Id: testrig.c,v 1.10 2004/04/08 01:36:13 mdw Exp $
  *
  * Generic test driver
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: testrig.c,v $
- * Revision 1.7  1999/11/21 13:01:39  mdw
- * Allow more characters to start words in test vector files.
- *
- * Revision 1.6  1999/11/16 15:03:23  mdw
- * Mark test types as constant.
- *
- * Revision 1.5  1999/05/21 22:14:30  mdw
- * Take advantage of the new dynamic string macros.
- *
- * Revision 1.4  1999/05/19 19:02:17  mdw
- * Aesthetic changes: fix spelling of `initialize'; use uppercase token
- * constants; abandon old double-underscore convention for internal
- * functions and variables.
- *
- * 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
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <ctype.h>
@@ -70,7 +42,7 @@
 
 /*----- Static variables --------------------------------------------------*/
 
-static dstr tok;
+static dstr tok = DSTR_INIT;
 
 enum {
   TOK_EOF = 0x100,
@@ -255,17 +227,62 @@ const test_type type_string = { cvt_string, dump_string };
 
 static void cvt_int(const char *s, dstr *d)
 {
-  DENSURE(d, sizeof(long));
-  sscanf(s, "%i", (int *)d->buf + d->len);
+  DENSURE(d, sizeof(int));
+  sscanf(s, "%i", (int *)d->buf);
 }
 
 static void dump_int(dstr *d, FILE *fp)
 {
-  fprintf(fp, "%i", *(int *)(d->buf));
+  fprintf(fp, "%i", *(int *)d->buf);
 }
 
 const test_type type_int = { cvt_int, dump_int };
 
+/* --- @type_long@ --- */
+
+static void cvt_long(const char *s, dstr *d)
+{
+  DENSURE(d, sizeof(long));
+  *(long *)d->buf = strtol(s, 0, 0);
+}
+
+static void dump_long(dstr *d, FILE *fp)
+{
+  fprintf(fp, "%li", *(long *)d->buf);
+}
+
+const test_type type_long = { cvt_long, dump_long };
+
+/* --- @type_ulong@ --- */
+
+static void cvt_ulong(const char *s, dstr *d)
+{
+  DENSURE(d, sizeof(unsigned long));
+  *(unsigned long *)d->buf = strtoul(s, 0, 0);
+}
+
+static void dump_ulong(dstr *d, FILE *fp)
+{
+  fprintf(fp, "%lu", *(unsigned long *)d->buf);
+}
+
+const test_type type_ulong = { cvt_ulong, dump_ulong };
+
+/* --- @type_uint32@ --- */
+
+static void cvt_uint32(const char *buf, dstr *d)
+{
+  DENSURE(d, sizeof(uint32));
+  *(uint32 *)d->buf = strtoul(buf, 0, 0);
+}
+
+static void dump_uint32(dstr *d, FILE *fp)
+{
+  fprintf(fp, "%lu\n", (unsigned long)*(uint32 *)d->buf);
+}
+
+const test_type type_uint32 = { cvt_uint32, dump_uint32 };
+
 /* --- @test_run@ --- *
  *
  * Arguments:  @int argc@ = number of command line arguments