/* -*-c-*-
*
- * $Id: testrig.c,v 1.7 1999/11/21 13:01:39 mdw Exp $
+ * $Id: testrig.c,v 1.8 1999/12/10 23:41:37 mdw Exp $
*
* Generic test driver
*
/*----- Revision history --------------------------------------------------*
*
* $Log: testrig.c,v $
+ * Revision 1.8 1999/12/10 23:41:37 mdw
+ * Support for different sizes and types of integers.
+ *
* Revision 1.7 1999/11/21 13:01:39 mdw
* Allow more characters to start words in test vector files.
*
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
/* -*-c-*-
*
- * $Id: testrig.h,v 1.5 1999/11/16 15:03:31 mdw Exp $
+ * $Id: testrig.h,v 1.6 1999/12/10 23:41:37 mdw Exp $
*
* Generic test driver
*
/*----- Revision history --------------------------------------------------*
*
* $Log: testrig.h,v $
+ * Revision 1.6 1999/12/10 23:41:37 mdw
+ * Support for different sizes and types of integers.
+ *
* Revision 1.5 1999/11/16 15:03:31 mdw
* Mark test types as constant.
*
*
*/
-#ifndef TESTER_H
-#define TESTER_H
+#ifndef MLIB_TESTER_H
+#define MLIB_TESTER_H
#ifdef __cplusplus
extern "C" {
#include <stddef.h>
+#include "bits.h"
#include "dstr.h"
/*----- Magical numbers ---------------------------------------------------*/
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 ------------------------------------------------*/