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
+12 -7
View File
@@ -4,6 +4,10 @@
#ifndef TEST_H
#define TEST_H
#include "token.h"
#include <stdbool.h>
typedef void (*Test)(void);
/**
@@ -39,21 +43,16 @@ void assert_str(const char* expected, const char* actual, const char* msg);
void assert_log(const char* expected, const char* msg);
/**
* Asserts that the logged output matches the content of a file.
* Asserts that the logged output matches the content of the file `v0/tests/xyz.log`, where xyz is the test name.
* If GENERATE_GOLDEN=1, the file is overwritten with the actual output.
*/
void assert_log_file(const char* filepath, const char* msg);
void assert_log_file(const char* msg);
/**
* Asserts that two integers are equal.
*/
void assert_int(int expected, int actual, const char* msg);
/**
* Reads the content of a file into a newly allocated string.
*/
char* read_file_content(const char* filepath);
/**
* Asserts that a condition is true.
*/
@@ -64,4 +63,10 @@ void assert_true(bool condition, const char* msg);
*/
void assert_false(bool condition, const char* msg);
/**
* Get the token stream used for this test.
* It reads from the `v0/tests/xyz.c2` file, where xyz is the test name.
*/
TokenStream* tokenstream_get_test(void);
#endif