Introduce golden file mechanism for tests

This commit is contained in:
2026-04-24 21:09:47 +02:00
parent 9ca72ef5bf
commit a89e61eedd
9 changed files with 66 additions and 24 deletions
+4 -17
View File
@@ -21,23 +21,10 @@ static void test_log_error(void) {
}
static void test_log_on_line(void) {
const char* expected =
"--- test.c ---\n"
"1| int main() []\n"
" ^^\n"
" unexpected token\n";
log_on_line("test.c", "int main() []", 1, 12, 13, "unexpected token");
assert_log(expected, "expected formatted error message");
}
static void test_log_on_line_format(void) {
const char* expected =
"--- test.c ---\n"
"1| int main() []\n"
" ^^\n"
" unexpected token 'x'\n";
assert_log_file("v0/tests/log_on_line.txt", "expected formatted error message");
log_clear();
log_on_line("test.c", "int main() []", 1, 12, 13, "unexpected token '%c'", 'x');
assert_log(expected, "expected formatted error message with variadic args");
}
assert_log_file("v0/tests/log_on_line_variadic.txt", "expected formatted error message with variadic args");
}