Implement tokenstream_get_test and simplified assert_log_file using test names

This commit is contained in:
2026-04-26 20:31:17 +02:00
parent e910c01348
commit 9449f16e02
36 changed files with 106 additions and 92 deletions
+15 -6
View File
@@ -22,7 +22,7 @@ static void test_log_error(void) {
static void test_log_on_line(void) {
Location loc = {
.filename = "test.c",
.filename = "v0/tests/log_on_line.c2",
.line_text = { "int main() []", 13 },
.line = 1,
.column_start = 12,
@@ -30,9 +30,18 @@ static void test_log_on_line(void) {
};
log_on_line(&loc, 13, "unexpected token");
assert_log_file("v0/tests/log_on_line.txt", "expected formatted error message");
log_clear();
log_on_line(&loc, 13, "unexpected token '%c'", 'x');
assert_log_file("v0/tests/log_on_line_variadic.txt", "expected formatted error message with variadic args");
assert_log_file("expected formatted error message");
}
static void test_log_on_line_variadic(void) {
Location loc = {
.filename = "v0/tests/log_on_line_variadic.c2",
.line_text = { "int main() []", 13 },
.line = 1,
.column_start = 12,
.column_end = 13
};
log_on_line(&loc, 13, "unexpected token '%c'", 'x');
assert_log_file("expected formatted error message with variadic args");
}