summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2024-02-14 11:30:18 +0100
committerLinnnus <[email protected]>2024-02-14 11:30:18 +0100
commitc4f8c14ae8a8301d698d150a97700b2d1a1d8f4c (patch)
treedfc600c41cc967f08efca9c3e15351f1edff2011
parent22f2b6a44d670039c7dca399e665ad115bd8436d (diff)
test(creole): Show input markup on failing tests
This patch also introduces print_escaped_ze() – an alternative to print_escaped() that takes a zero-terminated string. I do this because I almost made a silly copy/paste mistake with a line like: print_escaped(stdout, tests[i].input, strlen(tests[i].output));
-rw-r--r--src/creole-test.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/creole-test.c b/src/creole-test.c
index 3020c51..50ccd8b 100644
--- a/src/creole-test.c
+++ b/src/creole-test.c
@@ -303,6 +303,10 @@ next_char:
return 0;
}
+int print_escaped_ze(FILE *fp, const char *string) {
+ return print_escaped(fp, string, strlen(string));
+}
+
int main(void) {
for (size_t i = 0; i < COUNT(tests); ++i) {
printf("Running test: \x1b[1m%s\x1b[0m... ", tests[i].name);
@@ -315,8 +319,11 @@ int main(void) {
if (!strneq(buffer, tests[i].output, buffer_length)) {
printf("\x1b[31merror\x1b[0m\n");
+ printf("├──── markup: ");
+ print_escaped_ze(stdout, tests[i].input);
+ putchar('\n');
printf("├── expected: ");
- print_escaped(stdout, tests[i].output, strlen(tests[i].output));
+ print_escaped_ze(stdout, tests[i].output);
putchar('\n');
printf("└─────── got: ");
print_escaped(stdout, buffer, buffer_length);