entity/*: minor changes to doc and tests
This commit is contained in:
@@ -160,11 +160,11 @@ template<typename Entity>
|
||||
}
|
||||
|
||||
|
||||
/*! @brief Null object for all entity identifiers. */
|
||||
/*! @brief Null object for all identifiers. */
|
||||
struct null_t {
|
||||
/**
|
||||
* @brief Converts the null object to identifiers of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @return The null representation for the given type.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -192,9 +192,9 @@ struct null_t {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compares a null object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a null object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @return False if the two elements differ, true otherwise.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -204,9 +204,9 @@ struct null_t {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compares a null object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a null object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @return True if the two elements differ, false otherwise.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -217,9 +217,9 @@ struct null_t {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compares a null object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a null object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @param other A null object yet to be converted.
|
||||
* @return False if the two elements differ, true otherwise.
|
||||
*/
|
||||
@@ -230,9 +230,9 @@ template<typename Entity>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compares a null object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a null object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @param other A null object yet to be converted.
|
||||
* @return True if the two elements differ, false otherwise.
|
||||
*/
|
||||
@@ -242,11 +242,11 @@ template<typename Entity>
|
||||
}
|
||||
|
||||
|
||||
/*! @brief Tombstone object for all entity identifiers. */
|
||||
/*! @brief Tombstone object for all identifiers. */
|
||||
struct tombstone_t {
|
||||
/**
|
||||
* @brief Converts the tombstone object to identifiers of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @return The tombstone representation for the given type.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -274,9 +274,9 @@ struct tombstone_t {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compares a tombstone object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a tombstone object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @return False if the two elements differ, true otherwise.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -286,9 +286,9 @@ struct tombstone_t {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compares a tombstone object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a tombstone object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @return True if the two elements differ, false otherwise.
|
||||
*/
|
||||
template<typename Entity>
|
||||
@@ -299,9 +299,9 @@ struct tombstone_t {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compares a tombstone object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a tombstone object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @param other A tombstone object yet to be converted.
|
||||
* @return False if the two elements differ, true otherwise.
|
||||
*/
|
||||
@@ -312,9 +312,9 @@ template<typename Entity>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compares a tombstone object and an entity identifier of any type.
|
||||
* @tparam Entity Type of entity identifier.
|
||||
* @param entity Entity identifier with which to compare.
|
||||
* @brief Compares a tombstone object and an identifier of any type.
|
||||
* @tparam Entity Type of identifier.
|
||||
* @param entity Identifier with which to compare.
|
||||
* @param other A tombstone object yet to be converted.
|
||||
* @return True if the two elements differ, false otherwise.
|
||||
*/
|
||||
@@ -327,9 +327,9 @@ template<typename Entity>
|
||||
/**
|
||||
* @brief Compile-time constant for null entities.
|
||||
*
|
||||
* There exist implicit conversions from this variable to entity identifiers of
|
||||
* any allowed type. Similarly, there exist comparision operators between the
|
||||
* null entity and any other entity identifier.
|
||||
* There exist implicit conversions from this variable to identifiers of any
|
||||
* allowed type. Similarly, there exist comparision operators between the null
|
||||
* entity and any other identifier.
|
||||
*/
|
||||
inline constexpr null_t null{};
|
||||
|
||||
@@ -337,9 +337,9 @@ inline constexpr null_t null{};
|
||||
/**
|
||||
* @brief Compile-time constant for tombstone entities.
|
||||
*
|
||||
* There exist implicit conversions from this variable to entity identifiers of
|
||||
* any allowed type. Similarly, there exist comparision operators between the
|
||||
* tombstone entity and any other entity identifier.
|
||||
* There exist implicit conversions from this variable to identifiers of any
|
||||
* allowed type. Similarly, there exist comparision operators between the
|
||||
* tombstone entity and any other identifier.
|
||||
*/
|
||||
inline constexpr tombstone_t tombstone{};
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Finds an entity.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return An iterator to the given entity if it's found, past the end
|
||||
* iterator otherwise.
|
||||
*/
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Checks if a group contains an entity.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return True if the group contains the given entity, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool contains(const entity_type entt) const {
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
* results in undefined behavior.
|
||||
*
|
||||
* @tparam Component Types of components to get.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return The components assigned to the entity.
|
||||
*/
|
||||
template<typename... Component>
|
||||
@@ -781,7 +781,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Finds an entity.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return An iterator to the given entity if it's found, past the end
|
||||
* iterator otherwise.
|
||||
*/
|
||||
@@ -809,7 +809,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Checks if a group contains an entity.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return True if the group contains the given entity, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool contains(const entity_type entt) const {
|
||||
@@ -828,7 +828,7 @@ public:
|
||||
* results in undefined behavior.
|
||||
*
|
||||
* @tparam Component Types of components to get.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return The components assigned to the entity.
|
||||
*/
|
||||
template<typename... Component>
|
||||
|
||||
@@ -41,7 +41,7 @@ struct basic_handle {
|
||||
/**
|
||||
* @brief Constructs a handle from a given registry and entity.
|
||||
* @param ref An instance of the registry class.
|
||||
* @param value An entity identifier.
|
||||
* @param value A valid identifier.
|
||||
*/
|
||||
basic_handle(registry_type &ref, entity_type value) ENTT_NOEXCEPT
|
||||
: reg{&ref}, entt{value}
|
||||
@@ -79,7 +79,7 @@ struct basic_handle {
|
||||
|
||||
/**
|
||||
* @brief Converts a handle to its underlying entity.
|
||||
* @return An entity identifier.
|
||||
* @return The contained identifier.
|
||||
*/
|
||||
[[nodiscard]] operator entity_type() const ENTT_NOEXCEPT {
|
||||
return entity();
|
||||
|
||||
@@ -61,11 +61,9 @@ class basic_runtime_view final {
|
||||
|
||||
class view_iterator final {
|
||||
[[nodiscard]] bool valid() const {
|
||||
const auto entt = *it;
|
||||
|
||||
return (!stable_storage || (entt != tombstone))
|
||||
&& std::all_of(pools->begin()++, pools->end(), [entt](const auto *curr) { return curr->contains(entt); })
|
||||
&& std::none_of(filter->cbegin(), filter->cend(), [entt](const auto *curr) { return curr && curr->contains(entt); });
|
||||
return (no_tombstone_check || (*it != tombstone))
|
||||
&& std::all_of(pools->begin()++, pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); })
|
||||
&& std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); });
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -81,7 +79,7 @@ class basic_runtime_view final {
|
||||
: pools{&cpools},
|
||||
filter{&ignore},
|
||||
it{curr},
|
||||
stable_storage{std::any_of(pools->cbegin(), pools->cend(), [](const basic_common_type *cpool) { return (cpool->policy() == deletion_policy::in_place); })}
|
||||
no_tombstone_check{!((cpools.size() + ignore.size()) == 1u) || std::all_of(pools->cbegin(), pools->cend(), [](const basic_common_type *cpool) { return (cpool->policy() == deletion_policy::swap_and_pop); })}
|
||||
{
|
||||
if(it != (*pools)[0]->end() && !valid()) {
|
||||
++(*this);
|
||||
@@ -128,7 +126,7 @@ class basic_runtime_view final {
|
||||
const std::vector<const basic_common_type *> *pools;
|
||||
const std::vector<const basic_common_type *> *filter;
|
||||
underlying_iterator it;
|
||||
bool stable_storage;
|
||||
bool no_tombstone_check;
|
||||
};
|
||||
|
||||
[[nodiscard]] bool valid() const {
|
||||
@@ -203,7 +201,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Checks if a view contains an entity.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return True if the view contains the given entity, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool contains(const entity_type entt) const {
|
||||
|
||||
@@ -532,7 +532,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Tests if a loader knows about a given entity.
|
||||
* @param entt An entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return True if `entity` is managed by the loader, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool contains(entity_type entt) const ENTT_NOEXCEPT {
|
||||
@@ -541,7 +541,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Returns the identifier to which an entity refers.
|
||||
* @param entt An entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return The local identifier if any, the null entity otherwise.
|
||||
*/
|
||||
[[nodiscard]] entity_type map(entity_type entt) const ENTT_NOEXCEPT {
|
||||
|
||||
@@ -289,7 +289,7 @@ protected:
|
||||
|
||||
/**
|
||||
* @brief Attempts to erase an entity from the internal packed array.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param ud Optional user data that are forwarded as-is to derived classes.
|
||||
*/
|
||||
void swap_and_pop(const Entity entt, void *ud) override {
|
||||
@@ -307,7 +307,7 @@ protected:
|
||||
|
||||
/**
|
||||
* @brief Attempts to erase an entity from the internal packed array.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param ud Optional user data that are forwarded as-is to derived classes.
|
||||
*/
|
||||
void in_place_pop(const Entity entt, void *ud) override {
|
||||
@@ -541,7 +541,7 @@ public:
|
||||
* Attempting to use an entity that doesn't belong to the storage results in
|
||||
* undefined behavior.
|
||||
*
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return The object assigned to the entity.
|
||||
*/
|
||||
[[nodiscard]] const value_type & get(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
@@ -559,7 +559,7 @@ public:
|
||||
*
|
||||
* @sa get
|
||||
*
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return The object assigned to the entity as a tuple.
|
||||
*/
|
||||
[[nodiscard]] std::tuple<const value_type &> get_as_tuple(const entity_type entt) const ENTT_NOEXCEPT {
|
||||
@@ -583,7 +583,7 @@ public:
|
||||
* in undefined behavior.
|
||||
*
|
||||
* @tparam Args Types of arguments to use to construct the object.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param args Parameters to use to construct an object for the entity.
|
||||
* @return A reference to the newly created object.
|
||||
*/
|
||||
@@ -608,7 +608,7 @@ public:
|
||||
/**
|
||||
* @brief Updates the instance assigned to a given entity in-place.
|
||||
* @tparam Func Types of the function objects to invoke.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param func Valid function objects.
|
||||
* @return A reference to the updated instance.
|
||||
*/
|
||||
@@ -726,7 +726,7 @@ public:
|
||||
* Attempting to use an entity that doesn't belong to the storage results in
|
||||
* undefined behavior.
|
||||
*
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @return Returns an empty tuple.
|
||||
*/
|
||||
[[nodiscard]] std::tuple<> get_as_tuple([[maybe_unused]] const entity_type entt) const ENTT_NOEXCEPT {
|
||||
@@ -742,7 +742,7 @@ public:
|
||||
* in undefined behavior.
|
||||
*
|
||||
* @tparam Args Types of arguments to use to construct the object.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param args Parameters to use to construct an object for the entity.
|
||||
*/
|
||||
template<typename... Args>
|
||||
@@ -754,7 +754,7 @@ public:
|
||||
/**
|
||||
* @brief Updates the instance assigned to a given entity in-place.
|
||||
* @tparam Func Types of the function objects to invoke.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param func Valid function objects.
|
||||
*/
|
||||
template<typename... Func>
|
||||
@@ -800,7 +800,7 @@ struct storage_adapter_mixin: Type {
|
||||
/**
|
||||
* @brief Assigns entities to a storage.
|
||||
* @tparam Args Types of arguments to use to construct the object.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param args Parameters to use to initialize the object.
|
||||
* @return A reference to the newly created object.
|
||||
*/
|
||||
@@ -827,7 +827,7 @@ struct storage_adapter_mixin: Type {
|
||||
/**
|
||||
* @brief Patches the given instance for an entity.
|
||||
* @tparam Func Types of the function objects to invoke.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param func Valid function objects.
|
||||
* @return A reference to the patched instance.
|
||||
*/
|
||||
@@ -936,7 +936,7 @@ public:
|
||||
* @brief Assigns entities to a storage.
|
||||
* @tparam Args Types of arguments to use to construct the object.
|
||||
* @param owner The registry that issued the request.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param args Parameters to use to initialize the object.
|
||||
* @return A reference to the newly created object.
|
||||
*/
|
||||
@@ -976,7 +976,7 @@ public:
|
||||
* @brief Patches the given instance for an entity.
|
||||
* @tparam Func Types of the function objects to invoke.
|
||||
* @param owner The registry that issued the request.
|
||||
* @param entt A valid entity identifier.
|
||||
* @param entt A valid identifier.
|
||||
* @param func Valid function objects.
|
||||
* @return A reference to the patched instance.
|
||||
*/
|
||||
|
||||
@@ -162,10 +162,7 @@ TEST(Storage, EmptyType) {
|
||||
|
||||
TEST(Storage, Insert) {
|
||||
entt::storage<stable_type> pool;
|
||||
entt::entity entities[2u];
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
|
||||
pool.insert(std::begin(entities), std::end(entities), stable_type{99});
|
||||
|
||||
ASSERT_TRUE(pool.contains(entities[0u]));
|
||||
@@ -193,10 +190,7 @@ TEST(Storage, Insert) {
|
||||
|
||||
TEST(Storage, InsertEmptyType) {
|
||||
entt::storage<empty_type> pool;
|
||||
entt::entity entities[2u];
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
|
||||
|
||||
pool.insert(std::begin(entities), std::end(entities));
|
||||
|
||||
@@ -209,11 +203,7 @@ TEST(Storage, InsertEmptyType) {
|
||||
|
||||
TEST(Storage, Erase) {
|
||||
entt::storage<int> pool;
|
||||
entt::entity entities[3u];
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entities[2u] = entt::entity{9};
|
||||
entt::entity entities[3u]{entt::entity{3}, entt::entity{42}, entt::entity{9}};
|
||||
|
||||
pool.emplace(entities[0u]);
|
||||
pool.emplace(entities[1u]);
|
||||
@@ -248,15 +238,11 @@ TEST(Storage, Erase) {
|
||||
|
||||
TEST(Storage, StableErase) {
|
||||
entt::storage<stable_type> pool;
|
||||
entt::entity entities[3u];
|
||||
entt::entity entities[3u]{entt::entity{3}, entt::entity{42}, entt::entity{9}};
|
||||
|
||||
ASSERT_DEATH([[maybe_unused]] auto &&value = pool.get(entt::tombstone), "");
|
||||
ASSERT_DEATH([[maybe_unused]] auto &&value = pool.get(entt::null), "");
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entities[2u] = entt::entity{9};
|
||||
|
||||
pool.emplace(entities[0u], stable_type{0});
|
||||
pool.emplace(entities[1u], stable_type{1});
|
||||
pool.emplace(entities[2u], stable_type{2});
|
||||
@@ -357,11 +343,7 @@ TEST(Storage, StableErase) {
|
||||
|
||||
TEST(Storage, Remove) {
|
||||
entt::storage<int> pool;
|
||||
entt::entity entities[3u];
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entities[2u] = entt::entity{9};
|
||||
entt::entity entities[3u]{entt::entity{3}, entt::entity{42}, entt::entity{9}};
|
||||
|
||||
pool.emplace(entities[0u]);
|
||||
pool.emplace(entities[1u]);
|
||||
@@ -395,11 +377,7 @@ TEST(Storage, Remove) {
|
||||
|
||||
TEST(Storage, StableRemove) {
|
||||
entt::storage<stable_type> pool;
|
||||
entt::entity entities[3u];
|
||||
|
||||
entities[0u] = entt::entity{3};
|
||||
entities[1u] = entt::entity{42};
|
||||
entities[2u] = entt::entity{9};
|
||||
entt::entity entities[3u]{entt::entity{3}, entt::entity{42}, entt::entity{9}};
|
||||
|
||||
pool.emplace(entities[0u], stable_type{0});
|
||||
pool.emplace(entities[1u], stable_type{1});
|
||||
@@ -804,18 +782,18 @@ TEST(Storage, SortUnordered) {
|
||||
auto begin = pool.begin();
|
||||
auto end = pool.end();
|
||||
|
||||
ASSERT_EQ(*(begin++), boxed_int{1});
|
||||
ASSERT_EQ(*(begin++), boxed_int{3});
|
||||
ASSERT_EQ(*(begin++), boxed_int{6});
|
||||
ASSERT_EQ(*(begin++), boxed_int{9});
|
||||
ASSERT_EQ(*(begin++), boxed_int{12});
|
||||
ASSERT_EQ(*(begin++), values[2u]);
|
||||
ASSERT_EQ(*(begin++), values[1u]);
|
||||
ASSERT_EQ(*(begin++), values[0u]);
|
||||
ASSERT_EQ(*(begin++), values[3u]);
|
||||
ASSERT_EQ(*(begin++), values[4u]);
|
||||
ASSERT_EQ(begin, end);
|
||||
|
||||
ASSERT_EQ(pool.data()[0u], entt::entity{9});
|
||||
ASSERT_EQ(pool.data()[1u], entt::entity{3});
|
||||
ASSERT_EQ(pool.data()[2u], entt::entity{12});
|
||||
ASSERT_EQ(pool.data()[3u], entt::entity{42});
|
||||
ASSERT_EQ(pool.data()[4u], entt::entity{7});
|
||||
ASSERT_EQ(pool.data()[0u], entities[4u]);
|
||||
ASSERT_EQ(pool.data()[1u], entities[3u]);
|
||||
ASSERT_EQ(pool.data()[2u], entities[0u]);
|
||||
ASSERT_EQ(pool.data()[3u], entities[1u]);
|
||||
ASSERT_EQ(pool.data()[4u], entities[2u]);
|
||||
}
|
||||
|
||||
TEST(Storage, SortRange) {
|
||||
@@ -831,31 +809,31 @@ TEST(Storage, SortRange) {
|
||||
|
||||
pool.sort_n(2u, [&pool](auto lhs, auto rhs) { return pool.get(lhs).value < pool.get(rhs).value; });
|
||||
|
||||
ASSERT_EQ(pool.raw()[0u][0u], boxed_int{6});
|
||||
ASSERT_EQ(pool.raw()[0u][1u], boxed_int{3});
|
||||
ASSERT_EQ(pool.raw()[0u][2u], boxed_int{1});
|
||||
ASSERT_EQ(pool.raw()[0u][0u], values[1u]);
|
||||
ASSERT_EQ(pool.raw()[0u][1u], values[0u]);
|
||||
ASSERT_EQ(pool.raw()[0u][2u], values[2u]);
|
||||
|
||||
ASSERT_EQ(pool.data()[0u], entt::entity{42});
|
||||
ASSERT_EQ(pool.data()[1u], entt::entity{12});
|
||||
ASSERT_EQ(pool.data()[2u], entt::entity{7});
|
||||
ASSERT_EQ(pool.data()[0u], entities[1u]);
|
||||
ASSERT_EQ(pool.data()[1u], entities[0u]);
|
||||
ASSERT_EQ(pool.data()[2u], entities[2u]);
|
||||
|
||||
pool.sort_n(5u, [&pool](auto lhs, auto rhs) { return pool.get(lhs).value < pool.get(rhs).value; });
|
||||
|
||||
auto begin = pool.begin();
|
||||
auto end = pool.end();
|
||||
|
||||
ASSERT_EQ(*(begin++), boxed_int{1});
|
||||
ASSERT_EQ(*(begin++), boxed_int{3});
|
||||
ASSERT_EQ(*(begin++), boxed_int{6});
|
||||
ASSERT_EQ(*(begin++), boxed_int{9});
|
||||
ASSERT_EQ(*(begin++), boxed_int{12});
|
||||
ASSERT_EQ(*(begin++), values[2u]);
|
||||
ASSERT_EQ(*(begin++), values[0u]);
|
||||
ASSERT_EQ(*(begin++), values[1u]);
|
||||
ASSERT_EQ(*(begin++), values[3u]);
|
||||
ASSERT_EQ(*(begin++), values[4u]);
|
||||
ASSERT_EQ(begin, end);
|
||||
|
||||
ASSERT_EQ(pool.data()[0u], entt::entity{9});
|
||||
ASSERT_EQ(pool.data()[1u], entt::entity{3});
|
||||
ASSERT_EQ(pool.data()[2u], entt::entity{42});
|
||||
ASSERT_EQ(pool.data()[3u], entt::entity{12});
|
||||
ASSERT_EQ(pool.data()[4u], entt::entity{7});
|
||||
ASSERT_EQ(pool.data()[0u], entities[4u]);
|
||||
ASSERT_EQ(pool.data()[1u], entities[3u]);
|
||||
ASSERT_EQ(pool.data()[2u], entities[1u]);
|
||||
ASSERT_EQ(pool.data()[3u], entities[0u]);
|
||||
ASSERT_EQ(pool.data()[4u], entities[2u]);
|
||||
}
|
||||
|
||||
TEST(Storage, RespectDisjoint) {
|
||||
@@ -898,14 +876,14 @@ TEST(Storage, RespectOverlap) {
|
||||
auto begin = lhs.begin();
|
||||
auto end = lhs.end();
|
||||
|
||||
ASSERT_EQ(*(begin++), 6);
|
||||
ASSERT_EQ(*(begin++), 9);
|
||||
ASSERT_EQ(*(begin++), 3);
|
||||
ASSERT_EQ(*(begin++), lhs_values[1u]);
|
||||
ASSERT_EQ(*(begin++), lhs_values[2u]);
|
||||
ASSERT_EQ(*(begin++), lhs_values[0u]);
|
||||
ASSERT_EQ(begin, end);
|
||||
|
||||
ASSERT_EQ(lhs.data()[0u], entt::entity{3});
|
||||
ASSERT_EQ(lhs.data()[1u], entt::entity{42});
|
||||
ASSERT_EQ(lhs.data()[2u], entt::entity{12});
|
||||
ASSERT_EQ(lhs.data()[0u], lhs_entities[0u]);
|
||||
ASSERT_EQ(lhs.data()[1u], lhs_entities[2u]);
|
||||
ASSERT_EQ(lhs.data()[2u], lhs_entities[1u]);
|
||||
}
|
||||
|
||||
TEST(Storage, RespectOrdered) {
|
||||
@@ -955,20 +933,20 @@ TEST(Storage, RespectReverse) {
|
||||
auto begin = rhs.begin();
|
||||
auto end = rhs.end();
|
||||
|
||||
ASSERT_EQ(*(begin++), 5);
|
||||
ASSERT_EQ(*(begin++), 4);
|
||||
ASSERT_EQ(*(begin++), 3);
|
||||
ASSERT_EQ(*(begin++), 2);
|
||||
ASSERT_EQ(*(begin++), 1);
|
||||
ASSERT_EQ(*(begin++), 6);
|
||||
ASSERT_EQ(*(begin++), rhs_values[0u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[1u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[2u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[3u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[4u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[5u]);
|
||||
ASSERT_EQ(begin, end);
|
||||
|
||||
ASSERT_EQ(rhs.data()[0u], entt::entity{6});
|
||||
ASSERT_EQ(rhs.data()[1u], entt::entity{1});
|
||||
ASSERT_EQ(rhs.data()[2u], entt::entity{2});
|
||||
ASSERT_EQ(rhs.data()[3u], entt::entity{3});
|
||||
ASSERT_EQ(rhs.data()[4u], entt::entity{4});
|
||||
ASSERT_EQ(rhs.data()[5u], entt::entity{5});
|
||||
ASSERT_EQ(rhs.data()[0u], rhs_entities[5u]);
|
||||
ASSERT_EQ(rhs.data()[1u], rhs_entities[4u]);
|
||||
ASSERT_EQ(rhs.data()[2u], rhs_entities[3u]);
|
||||
ASSERT_EQ(rhs.data()[3u], rhs_entities[2u]);
|
||||
ASSERT_EQ(rhs.data()[4u], rhs_entities[1u]);
|
||||
ASSERT_EQ(rhs.data()[5u], rhs_entities[0u]);
|
||||
}
|
||||
|
||||
TEST(Storage, RespectUnordered) {
|
||||
@@ -994,20 +972,20 @@ TEST(Storage, RespectUnordered) {
|
||||
auto begin = rhs.begin();
|
||||
auto end = rhs.end();
|
||||
|
||||
ASSERT_EQ(*(begin++), 5);
|
||||
ASSERT_EQ(*(begin++), 4);
|
||||
ASSERT_EQ(*(begin++), 3);
|
||||
ASSERT_EQ(*(begin++), 2);
|
||||
ASSERT_EQ(*(begin++), 1);
|
||||
ASSERT_EQ(*(begin++), 6);
|
||||
ASSERT_EQ(*(begin++), rhs_values[5u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[4u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[0u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[1u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[3u]);
|
||||
ASSERT_EQ(*(begin++), rhs_values[2u]);
|
||||
ASSERT_EQ(begin, end);
|
||||
|
||||
ASSERT_EQ(rhs.data()[0u], entt::entity{6});
|
||||
ASSERT_EQ(rhs.data()[1u], entt::entity{1});
|
||||
ASSERT_EQ(rhs.data()[2u], entt::entity{2});
|
||||
ASSERT_EQ(rhs.data()[3u], entt::entity{3});
|
||||
ASSERT_EQ(rhs.data()[4u], entt::entity{4});
|
||||
ASSERT_EQ(rhs.data()[5u], entt::entity{5});
|
||||
ASSERT_EQ(rhs.data()[0u], rhs_entities[2u]);
|
||||
ASSERT_EQ(rhs.data()[1u], rhs_entities[3u]);
|
||||
ASSERT_EQ(rhs.data()[2u], rhs_entities[1u]);
|
||||
ASSERT_EQ(rhs.data()[3u], rhs_entities[0u]);
|
||||
ASSERT_EQ(rhs.data()[4u], rhs_entities[4u]);
|
||||
ASSERT_EQ(rhs.data()[5u], rhs_entities[5u]);
|
||||
}
|
||||
|
||||
TEST(Storage, CanModifyDuringIteration) {
|
||||
|
||||
Reference in New Issue
Block a user