diff --git a/tests/generics_comprehensive.c b/tests/generics_comprehensive.c new file mode 100644 index 0000000..7c8a977 --- /dev/null +++ b/tests/generics_comprehensive.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +struct Box_string { + struct T value; +}; + +struct Option_bool_union { + struct Option_bool_Some some; + struct Option_bool_None none; +}; + +struct Option_int_union { + struct Option_int_Some some; + struct Option_int_None none; +}; + +struct Option_int_None { +}; + +struct Option_int { + int discriminant; + struct Option_int_union data; +}; + +struct Option_int_Some { + struct T field_0; +}; + +struct Option_bool_None { +}; + +struct Option_bool { + int discriminant; + struct Option_bool_union data; +}; + +struct Option_bool_Some { + struct T field_0; +}; + +struct Box_int { + struct T value; +}; + +int test_containers(void); + + +int test_containers(void) { + struct Box box_int = (struct Box){ .value = 42 }; + struct Box box_string = (struct Box){ .value = "Fermented" }; + struct Option some_int = (Option){ .discriminant = 0, .data = { .some = (Option_Some{ .field_0 = 10 }) } }; + struct Option some_bool = (Option){ .discriminant = 0, .data = { .some = (Option_Some{ .field_0 = true }) } }; + struct T unwrapped = unwrap(some_int); + struct T unwraped_bool = unwrap(some_bool); + return (box_int.value + unwrapped); +} +