Skip to content

Commit 364d048

Browse files
real-or-randomsipa
authored andcommitted
tests: Add debug helper for printing buffers
1 parent 54d34b6 commit 364d048

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tests.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ static int all_bytes_equal(const void* s, unsigned char value, size_t n) {
4444
return 1;
4545
}
4646

47+
/* Debug helper for printing arrays of unsigned char. */
48+
static void print_buf(const unsigned char *buf, size_t len) {
49+
size_t i;
50+
printf("{");
51+
for (i = 0; i < len; i++) {
52+
if (i % 8 == 0) {
53+
printf("\n ");
54+
} else {
55+
printf(" ");
56+
}
57+
printf("0x%02X,", buf[i]);
58+
}
59+
printf("\n}\n");
60+
}
61+
4762
/* TODO Use CHECK_ILLEGAL(_VOID) everywhere and get rid of the uncounting callback */
4863
/* CHECK that expr_or_stmt calls the illegal callback of ctx exactly once
4964
*

0 commit comments

Comments
 (0)