Skip to content

Commit

Permalink
#766 add (quarantined) test for inherited union relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Aug 1, 2022
1 parent 3759710 commit 74fe4ba
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@
"query_for_switch_filter_term",
"query_switch_from_nothing",
"query_case_from_nothing",
"query_case_inherited",
"query_disabled_from_nothing",
"query_only_2_or",
"query_only_3_or",
Expand Down
38 changes: 38 additions & 0 deletions test/api/src/Query.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,44 @@ void Query_query_case_from_nothing() {
ecs_fini(world);
}

void Query_query_case_inherited() {
test_quarantine("Aug 1st 2022");

ecs_world_t *world = ecs_mini();

ECS_ENTITY(world, Movement, Union);
ECS_TAG(world, Walking);
ECS_TAG(world, Running);

ecs_entity_t base_1 = ecs_new_w_pair(world, Movement, Walking);
ecs_entity_t inst_1 = ecs_new_w_pair(world, EcsIsA, base_1);

ecs_entity_t base_2 = ecs_new_w_pair(world, Movement, Running);
ecs_entity_t inst_2 = ecs_new_w_pair(world, EcsIsA, base_2);

ecs_query_t *q = ecs_query_init(world, &(ecs_query_desc_t){ .filter = {
.terms = {
{ ecs_pair(Movement, Walking) }
}
}});
test_assert(q != NULL);

ecs_iter_t it = ecs_query_iter(world, q);
test_bool(true, ecs_query_next(&it));
test_int(it.count, 1);
test_uint(it.entities[0], base_1);
test_uint(ecs_field_id(&it, 1), ecs_pair(Movement, Walking));

test_bool(true, ecs_query_next(&it));
test_int(it.count, 1);
test_uint(it.entities[0], inst_1);
test_uint(ecs_field_id(&it, 1), ecs_pair(Movement, Walking));

test_bool(false, ecs_query_next(&it));

ecs_fini(world);
}

void Query_query_disabled_from_nothing() {
ecs_world_t *world = ecs_mini();

Expand Down
7 changes: 6 additions & 1 deletion test/api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ void Query_query_for_case_new(void);
void Query_query_for_switch_filter_term(void);
void Query_query_switch_from_nothing(void);
void Query_query_case_from_nothing(void);
void Query_query_case_inherited(void);
void Query_query_disabled_from_nothing(void);
void Query_query_only_2_or(void);
void Query_query_only_3_or(void);
Expand Down Expand Up @@ -6630,6 +6631,10 @@ bake_test_case Query_testcases[] = {
"query_case_from_nothing",
Query_query_case_from_nothing
},
{
"query_case_inherited",
Query_query_case_inherited
},
{
"query_disabled_from_nothing",
Query_query_disabled_from_nothing
Expand Down Expand Up @@ -10494,7 +10499,7 @@ static bake_test_suite suites[] = {
"Query",
NULL,
NULL,
175,
176,
Query_testcases
},
{
Expand Down

0 comments on commit 74fe4ba

Please sign in to comment.