aboutsummaryrefslogtreecommitdiff
path: root/tests/parser_test.c
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-31 19:58:56 +0200
committerhachem <im@hachem.wtf>2026-08-31 19:58:56 +0200
commit5b06b0e4b8effaacd23308d6a6b26c525e7d3af4 (patch)
tree351155777028e604845d3dfec27d3caf3b22257f /tests/parser_test.c
parentcbdb9073480c3e4d8a088b306c23406cf42e25c0 (diff)
feat: add enums and structs
Diffstat (limited to 'tests/parser_test.c')
-rw-r--r--tests/parser_test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/parser_test.c b/tests/parser_test.c
index 5a45e9e..71e1433 100644
--- a/tests/parser_test.c
+++ b/tests/parser_test.c
@@ -267,6 +267,27 @@ static void test_parse_register_size_suffix(struct TestContext* context)
free_program(&program);
}
+static void test_parse_enum_struct(struct TestContext* context)
+{
+ struct Lexer lexer = create_lexer(
+ "enum Color\n{\nRed,\nGreen,\nBlue\n}\nstruct Point\n{\nx\ny: byte\n}\n");
+ struct Program program;
+
+ check(context, parse_program(&lexer, &program));
+ check(context, program.enum_count == 1);
+ check(context, text_is(program.enums[0].name, "Color"));
+ check(context, program.enums[0].member_count == 3);
+ check(context, text_is(program.enums[0].members[1], "Green"));
+
+ check(context, program.struct_count == 1);
+ check(context, text_is(program.structs[0].name, "Point"));
+ check(context, program.structs[0].field_count == 2);
+ check(context, program.structs[0].fields[0].size == STORE_SIZE_QWORD);
+ check(context, program.structs[0].fields[1].size == STORE_SIZE_BYTE);
+
+ free_program(&program);
+}
+
static void test_parse_errors(struct TestContext* context)
{
struct Program program;
@@ -300,5 +321,6 @@ void run_parser_tests(struct TestContext* context)
test_parse_directives(context);
test_parse_bad_directive(context);
test_parse_register_size_suffix(context);
+ test_parse_enum_struct(context);
test_parse_errors(context);
}