Introduce golden file mechanism for tests
This commit is contained in:
+4
-17
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user