lib/wind/test-normalize.c: Dump failing vectors
authorAsanka Herath <asanka@secure-endpoints.com>
Fri, 18 Jun 2010 21:27:28 +0000 (17:27 -0400)
committerAsanka Herath <asanka@secure-endpoints.com>
Fri, 20 Aug 2010 17:09:48 +0000 (13:09 -0400)
If a Unicode string fails a normalization test, dump it so we can
figure out why its failing.

lib/wind/test-normalize.c

index 3c8f70fddc9c630ae054df0a57825befbe2ed9df..df3438593aba41a899bf1307ed028c461bbf67b7 100644 (file)
@@ -67,6 +67,18 @@ parse_vector(char *buf, uint32_t *v)
     return ret;
 }
 
+static void
+dump_vector(const char * msg, uint32_t * v, size_t len)
+{
+    size_t i;
+
+    printf("%s: (%d) ", msg, len);
+    for (i=0; i < len; i++) {
+       printf("%s%x", (i > 0? " ":""), v[i]);
+    }
+    printf("\n");
+}
+
 static int
 test(char *buf, unsigned lineno)
 {
@@ -109,11 +121,15 @@ test(char *buf, unsigned lineno)
     }
     if (out_len != norm_len) {
        printf("%u: wrong out len (%s)\n", lineno, c);
+       dump_vector("Expected", out, out_len);
+       dump_vector("Received", tmp, norm_len);
        free(tmp);
        return 1;
     }
     if (memcmp(out, tmp, out_len * sizeof(uint32_t)) != 0) {
        printf("%u: wrong out data (%s)\n", lineno, c);
+       dump_vector("Expected", out, out_len);
+       dump_vector("Received", tmp, norm_len);
        free(tmp);
        return 1;
     }