Skip to content

Commit

Permalink
Add extra tests that iterators are invalidated (fixes are commented out)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnse-hypixel committed Jul 28, 2023
1 parent 2305838 commit 46ab228
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/addons/src/SystemMisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,9 @@ void SystemMisc_rw_in_implicit_from_empty() {
test_assert(ecs_query_next(&it) == true);
test_assert(ecs_field_is_readonly(&it, 1) == false);
test_assert(ecs_field_is_readonly(&it, 2) == true);
// test_assert(ecs_query_next(&it) == false);

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand All @@ -997,7 +999,9 @@ void SystemMisc_rw_in_implicit_from_entity() {
test_assert(ecs_query_next(&it) == true);
test_assert(ecs_field_is_readonly(&it, 1) == false);
test_assert(ecs_field_is_readonly(&it, 2) == true);
// test_assert(ecs_query_next(&it) == false);

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand Down Expand Up @@ -1057,7 +1061,9 @@ void SystemMisc_rw_out_explicit_from_empty() {
test_assert(ecs_query_next(&it) == true);
test_assert(ecs_field_is_readonly(&it, 1) == false);
test_assert(ecs_field_is_readonly(&it, 2) == false);
// test_assert(ecs_query_next(&it) == false);

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand All @@ -1077,7 +1083,9 @@ void SystemMisc_rw_out_explicit_from_entity() {
test_assert(ecs_query_next(&it) == true);
test_assert(ecs_field_is_readonly(&it, 1) == false);
test_assert(ecs_field_is_readonly(&it, 2) == false);
// test_assert(ecs_query_next(&it) == false);

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand Down
4 changes: 4 additions & 0 deletions test/api/src/Iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,10 @@ void Iter_worker_iter_w_singleton() {
test_int(p[1].y, 50);

test_bool(ecs_worker_next(&wit_2), false);
// test_bool(ecs_worker_next(&wit_1), false);

test_assert(ECS_BIT_IS_SET(wit_2.flags, EcsIterIsValid) == false);
test_assert(ECS_BIT_IS_SET(wit_1.flags, EcsIterIsValid) == false);

ecs_fini(world);
}
Expand Down
8 changes: 8 additions & 0 deletions test/api/src/Query.c
Original file line number Diff line number Diff line change
Expand Up @@ -4735,12 +4735,16 @@ void Query_only_not_from_entity() {
test_assert(ecs_query_next(&it));
test_assert(ecs_field_src(&it, 1) == e);
test_assert(ecs_field_id(&it, 1) == Tag);
// test_assert(!ecs_query_next(&it));

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);

ecs_add(world, e, Tag);

it = ecs_query_iter(world, q);
test_assert(!ecs_query_next(&it));

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand All @@ -4756,12 +4760,16 @@ void Query_only_not_from_singleton() {
test_assert(ecs_query_next(&it));
test_assert(ecs_field_src(&it, 1) == e);
test_assert(ecs_field_id(&it, 1) == e);
// test_assert(!ecs_query_next(&it));

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);

ecs_add_id(world, e, e);

it = ecs_query_iter(world, q);
test_assert(!ecs_query_next(&it));

test_assert(ECS_BIT_IS_SET(it.flags, EcsIterIsValid) == false);
ecs_fini(world);
}

Expand Down

0 comments on commit 46ab228

Please sign in to comment.