math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
[catacomb] / symm / hash.h
index f492518..eb3cd75 100644 (file)
                                                                        \
   {                                                                    \
     uint32 _l = U32(_bsz);                                             \
-    uint32 _h = ((_bsz & ~MASK32) >> 16) >> 16;                                \
+    uint32 _h = ((_bsz & ~(size_t)MASK32) >> 16) >> 16;                        \
     _bctx->nh += _h;                                                   \
     _bctx->nl += _l;                                                   \
-    if (_bctx->nl < _l || _bctx->nl & ~MASK32)                         \
+    if (_bctx->nl < _l || _bctx->nl & ~(uint32)MASK32)                 \
       _bctx->nh++;                                                     \
   }                                                                    \
                                                                        \
 
 #define HASH_BUFLEN 100000
 
-#define HASH_TESTX(PRE, pre, name, fname)                              \
+#define HASH_VERIFY(PRE, pre) HASH_VERIFYX(PRE, pre, #pre)
+
+#define HASH_VERIFYX(PRE, pre, name)                                   \
                                                                        \
-static int verify(dstr *v)                                             \
+static int vrf_##pre(dstr *v, const test_type *msgty)                  \
 {                                                                      \
   pre##_ctx ctx;                                                       \
   int ok = 1;                                                          \
@@ -199,8 +201,9 @@ static int verify(dstr *v)                                          \
     }                                                                  \
     pre##_done(&ctx, d.buf);                                           \
     if (memcmp(d.buf, v[1].buf, PRE##_HASHSZ) != 0) {                  \
-      printf("\nfail:\n\tstep = %i\n\tinput = `%s'\n\texpected = ",    \
-            *ip, v[0].buf);                                            \
+      printf("\nfail:\n\tstep = %i\n\tinput = ", *ip);                 \
+      msgty->dump(&v[0], stdout);                                      \
+      printf("\n\texpected = ");                                       \
       type_hex.dump(&v[1], stdout);                                    \
       fputs("\n\tcomputed = ", stdout);                                        \
       type_hex.dump(&d, stdout);                                       \
@@ -213,7 +216,12 @@ static int verify(dstr *v)                                         \
   return (ok);                                                         \
 }                                                                      \
                                                                        \
-static int verifyrep(dstr *v)                                          \
+static int vrf_##pre##_hex(dstr *v)                                    \
+  { return vrf_##pre(v, &type_hex); }                                  \
+static int vrf_##pre##_lit(dstr *v)                                    \
+  { return vrf_##pre(v, &type_string); }                               \
+                                                                       \
+static int vrf_##pre##_rep(dstr *v)                                    \
 {                                                                      \
   pre##_ctx ctx;                                                       \
   size_t len = v[0].len;                                               \
@@ -248,12 +256,22 @@ static int verifyrep(dstr *v)                                             \
   xfree(p);                                                            \
   dstr_destroy(&d);                                                    \
   return (ok);                                                         \
-}                                                                      \
+}
+
+#define HASH_TESTDEFS(PRE, pre) HASH_TESTDEFSX(PRE, pre, #pre)
+
+#define HASH_TESTDEFSX(PRE, pre, name)                                 \
+  { name, vrf_##pre##_lit, { &type_string, &type_hex, 0 } },           \
+  { name "-hex", vrf_##pre##_hex, { &type_hex, &type_hex, 0 } },       \
+  { name "-rep", vrf_##pre##_rep,                                      \
+    { &type_string, &type_int, &type_hex, 0 } },
+
+#define HASH_TESTX(PRE, pre, name, fname)                              \
+                                                                       \
+HASH_VERIFYX(PRE, pre, name)                                           \
                                                                        \
 static test_chunk defs[] = {                                           \
-  { name, verify, { &type_string, &type_hex, 0 } },                    \
-  { name "-rep", verifyrep,                                            \
-    { &type_string, &type_int, &type_hex, 0 } },                       \
+  HASH_TESTDEFSX(PRE, pre, name)                                       \
   { 0, 0, { 0 } }                                                      \
 };                                                                     \
                                                                        \