Skip to content

Commit 64c41de

Browse files
tests: Add debug helper for printing buffers
1 parent ca6a760 commit 64c41de

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/tests.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ 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 = 0;
50+
printf("{");
51+
while (i < len) {
52+
if (i % 8 == 0) {
53+
printf("\n ");
54+
} else {
55+
printf(" ");
56+
}
57+
printf("0x%02X,", buf[i]);
58+
i++;
59+
}
60+
printf("\n}\n");
61+
}
62+
4763
/* TODO Use CHECK_ILLEGAL(_VOID) everywhere and get rid of the uncounting callback */
4864
/* CHECK that expr_or_stmt calls the illegal callback of ctx exactly once
4965
*

0 commit comments

Comments
 (0)