Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

add struct test with array member #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/serialize/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"struct",
"nested_struct",
"struct_bool_i32",
"struct_i32_bool"
"struct_i32_bool",
"struct_array_member"
]
}, {
"id": "Enum",
Expand Down
25 changes: 25 additions & 0 deletions test/serialize/src/Struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ ECS_STRUCT(i32_bool, {
bool b;
});

ECS_ARRAY(Color, float, 4);

ECS_STRUCT(StructWithArray,
{
Line line;
Color color;
});

void Struct_struct() {
ecs_world_t *world = ecs_init();

Expand Down Expand Up @@ -88,3 +96,20 @@ void Struct_struct_i32_bool() {

ecs_fini(world);
}

void Struct_array_member() {
ecs_world_t *world = ecs_init();

ECS_IMPORT(world, FlecsMeta);

ECS_META(world, StructWithArray);

{
StructWithArray value = { 0 };
char *str = ecs_ptr_to_str(world, ecs_entity(StructWithArray), &value);
test_str(str, "{x = 10, y = 20}");
ecs_os_free(str);
}

ecs_fini(world);
}
7 changes: 6 additions & 1 deletion test/serialize/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void Struct_struct(void);
void Struct_nested_struct(void);
void Struct_struct_bool_i32(void);
void Struct_struct_i32_bool(void);
void Struct_array_member(void);

// Testsuite 'Enum'
void Enum_enum(void);
Expand Down Expand Up @@ -173,6 +174,10 @@ bake_test_case Struct_testcases[] = {
{
"struct_i32_bool",
Struct_struct_i32_bool
},
{
"struct_array_member",
Struct_array_member
}
};

Expand Down Expand Up @@ -375,7 +380,7 @@ static bake_test_suite suites[] = {
"Struct",
NULL,
NULL,
4,
5,
Struct_testcases
},
{
Expand Down