#include void Refs_get_ref_by_ptr(void) { flecs::world world; auto e = flecs::entity(world) .set({10, 20}); auto ref = e.get_ref(); test_assert(ref->x == 10); test_assert(ref->y == 20); } void Refs_get_ref_by_method(void) { flecs::world world; auto e = flecs::entity(world) .set({10, 20}); auto ref = e.get_ref(); test_assert(ref.get()->x == 10); test_assert(ref.get()->y == 20); } void Refs_ref_after_add(void) { flecs::world world; auto e = flecs::entity(world) .set({10, 20}); auto ref = e.get_ref(); e.add(); test_assert(ref->x == 10); test_assert(ref->y == 20); } void Refs_ref_after_remove(void) { flecs::world world; auto e = flecs::entity(world) .set({10, 20}) .set({1, 1}); auto ref = e.get_ref(); e.remove(); test_assert(ref->x == 10); test_assert(ref->y == 20); } void Refs_ref_after_set(void) { flecs::world world; auto e = flecs::entity(world) .set({10, 20}); auto ref = e.get_ref(); e.set({1, 1}); test_assert(ref->x == 10); test_assert(ref->y == 20); } void Refs_ref_before_set(void) { flecs::world world; auto e = flecs::entity(world); auto ref = e.get_ref(); e.set({10, 20}); test_assert(ref->x == 10); test_assert(ref->y == 20); } void Refs_non_const_ref(void) { flecs::world world; auto e = world.entity().set({10, 20}); auto ref = e.get_ref(); ref->x ++; test_int(e.get()->x, 11); } void Refs_pair_ref(void) { flecs::world world; auto e = world.entity().set({10, 20}); auto ref = e.get_ref(); ref->x ++; test_int((e.get()->x), 11); } void Refs_pair_ref_w_entity(void) { flecs::world world; auto tag = world.entity(); auto e = world.entity().set(tag, {10, 20}); auto ref = e.get_ref(tag); ref->x ++; test_int(e.get(tag)->x, 11); } void Refs_pair_ref_second(void) { flecs::world world; auto tag = world.entity(); auto e = world.entity().set_second(tag, {10, 20}); auto ref = e.get_ref_second(tag); ref->x ++; test_int(e.get_second(tag)->x, 11); } void Refs_from_stage(void) { flecs::world world; flecs::world stage = world.get_stage(0); // get default stage flecs::entity e = stage.entity().set({10, 20}); auto ref = e.get_ref(); test_int(ref->x, 10); test_int(ref->y, 20); } void Refs_default_ctor(void) { flecs::world world; // Make sure default ctor works flecs::ref p; flecs::entity e = world.entity().set({10, 20}); p = e.get_ref(); test_int(p->x, 10); test_int(p->y, 20); } void Refs_try_get(void) { flecs::world world; flecs::ref p; test_assert(p.try_get() == nullptr); }