Skip to content

Commit

Permalink
test: added test case for 0 radius entity check
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Jul 30, 2022
1 parent ef6cd5b commit 75e6160
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions code/tests/cases/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,29 @@ MODULE(query, {

librg_world_destroy(world);
});

IT("should query entities with 0 radius", {
librg_world *world = librg_world_create();
r = librg_config_chunkamount_set(world, 3, 3, 1); EQUALS(r, LIBRG_OK);
r = librg_config_chunkoffset_set(world, LIBRG_OFFSET_BEG, LIBRG_OFFSET_BEG, LIBRG_OFFSET_BEG);

r = librg_entity_track(world, 1); EQUALS(r, LIBRG_OK);
r = librg_entity_track(world, 2); EQUALS(r, LIBRG_OK);
r = librg_entity_track(world, 3); EQUALS(r, LIBRG_OK);

r = librg_entity_chunk_set(world, 1, 1); EQUALS(r, LIBRG_OK);
r = librg_entity_chunk_set(world, 2, 1); EQUALS(r, LIBRG_OK);
r = librg_entity_chunk_set(world, 3, 2); EQUALS(r, LIBRG_OK);

r = librg_entity_owner_set(world, 2, 1); EQUALS(r, LIBRG_OK);

int64_t results[16] = {0};
size_t amt = 16;
librg_world_query(world, 1, 0, results, &amt);
EQUALS(amt, 2);
EQUALS(results[0], 2); // own entity first
EQUALS(results[1], 1);

librg_world_destroy(world);
});
});

0 comments on commit 75e6160

Please sign in to comment.