lib/wind/test-normalize.c: Dump failing vectors
If a Unicode string fails a normalization test, dump it so we can figure out why its failing.
This commit is contained in:
@@ -67,6 +67,18 @@ parse_vector(char *buf, uint32_t *v)
|
|||||||
return ret;
|
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
|
static int
|
||||||
test(char *buf, unsigned lineno)
|
test(char *buf, unsigned lineno)
|
||||||
{
|
{
|
||||||
@@ -109,11 +121,15 @@ test(char *buf, unsigned lineno)
|
|||||||
}
|
}
|
||||||
if (out_len != norm_len) {
|
if (out_len != norm_len) {
|
||||||
printf("%u: wrong out len (%s)\n", lineno, c);
|
printf("%u: wrong out len (%s)\n", lineno, c);
|
||||||
|
dump_vector("Expected", out, out_len);
|
||||||
|
dump_vector("Received", tmp, norm_len);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (memcmp(out, tmp, out_len * sizeof(uint32_t)) != 0) {
|
if (memcmp(out, tmp, out_len * sizeof(uint32_t)) != 0) {
|
||||||
printf("%u: wrong out data (%s)\n", lineno, c);
|
printf("%u: wrong out data (%s)\n", lineno, c);
|
||||||
|
dump_vector("Expected", out, out_len);
|
||||||
|
dump_vector("Received", tmp, norm_len);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user