From 46ab2286ed273c2256a0378bb1a3cf5f829708db Mon Sep 17 00:00:00 2001 From: John Seghers Date: Thu, 27 Jul 2023 17:20:33 -0700 Subject: [PATCH] Add extra tests that iterators are invalidated (fixes are commented out) --- test/addons/src/SystemMisc.c | 8 ++++++++ test/api/src/Iter.c | 4 ++++ test/api/src/Query.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/test/addons/src/SystemMisc.c b/test/addons/src/SystemMisc.c index 2d9c96cff0..9748bb6527 100644 --- a/test/addons/src/SystemMisc.c +++ b/test/addons/src/SystemMisc.c @@ -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); } @@ -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); } @@ -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); } @@ -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); } diff --git a/test/api/src/Iter.c b/test/api/src/Iter.c index 5806a297aa..6cb1fb7a74 100644 --- a/test/api/src/Iter.c +++ b/test/api/src/Iter.c @@ -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); } diff --git a/test/api/src/Query.c b/test/api/src/Query.c index e0f5457467..4161544f5f 100644 --- a/test/api/src/Query.c +++ b/test/api/src/Query.c @@ -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); } @@ -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); }