Skip to content

Commit

Permalink
Remove usages of ecs_field with index 0 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroErrors authored and SanderMertens committed Jul 12, 2023
1 parent 3ba680a commit d24a9e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
23 changes: 7 additions & 16 deletions test/addons/src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,15 @@ void probe_system_w_ctx(
test_assert(e != 0);
}

if (it->entities) {
ecs_entity_t *e = ecs_field(it, ecs_entity_t, 0);
if (e) {
test_assert(e != NULL);
test_assert(it->entities != NULL);
test_assert(it->entities == e);

for (i = 0; i < it->count; i ++) {
if (i + ctx->count < 256) {
ctx->e[i + ctx->count] = e[i];
} else {
/* can't store more than that, tests shouldn't rely on
* getting back more than 256 results */
}
}
ctx->count += it->count;
for (i = 0; i < it->count; i ++) {
if (i + ctx->count < 256) {
ctx->e[i + ctx->count] = it->entities[i];
} else {
/* can't store more than that, tests shouldn't rely on
* getting back more than 256 results */
}
}
ctx->count += it->count;

ctx->invoked ++;
}
Expand Down
23 changes: 7 additions & 16 deletions test/api/src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,15 @@ void probe_system_w_ctx(
test_assert(e != 0);
}

if (it->entities) {
ecs_entity_t *e = ecs_field(it, ecs_entity_t, 0);
if (e) {
test_assert(e != NULL);
test_assert(it->entities != NULL);
test_assert(it->entities == e);

for (i = 0; i < it->count; i ++) {
if (i + ctx->count < 256) {
ctx->e[i + ctx->count] = e[i];
} else {
/* can't store more than that, tests shouldn't rely on
* getting back more than 256 results */
}
}
ctx->count += it->count;
for (i = 0; i < it->count; i ++) {
if (i + ctx->count < 256) {
ctx->e[i + ctx->count] = it->entities[i];
} else {
/* can't store more than that, tests shouldn't rely on
* getting back more than 256 results */
}
}
ctx->count += it->count;

ctx->invoked ++;
}
Expand Down

0 comments on commit d24a9e1

Please sign in to comment.