Browse Source

storage: minor changes/tests

Michele Caini 3 years ago
parent
commit
631c55ba92
2 changed files with 5 additions and 1 deletions
  1. 1 1
      src/entt/entity/storage.hpp
  2. 4 0
      test/entt/entity/storage.cpp

+ 1 - 1
src/entt/entity/storage.hpp

@@ -711,7 +711,7 @@ public:
      * @param first An iterator to the first element of the range of entities.
      * @param first An iterator to the first element of the range of entities.
      * @param last An iterator past the last element of the range of entities.
      * @param last An iterator past the last element of the range of entities.
      * @param value An instance of the object to construct.
      * @param value An instance of the object to construct.
-     * @return Iterator pointing to the first element inserted, if any.
+     * @return Iterator pointing to the last element inserted, if any.
      */
      */
     template<typename It>
     template<typename It>
     iterator insert(It first, It last, const value_type &value = {}) {
     iterator insert(It first, It last, const value_type &value = {}) {

+ 4 - 0
test/entt/entity/storage.cpp

@@ -328,6 +328,8 @@ TEST_F(Storage, Insert) {
     ASSERT_EQ(pool.size(), 2u);
     ASSERT_EQ(pool.size(), 2u);
     ASSERT_EQ(pool.get(entities[0u]).value, 99);
     ASSERT_EQ(pool.get(entities[0u]).value, 99);
     ASSERT_EQ(pool.get(entities[1u]).value, 99);
     ASSERT_EQ(pool.get(entities[1u]).value, 99);
+    ASSERT_EQ(it++->value, 99);
+    ASSERT_EQ(it->value, 99);
 
 
     pool.erase(std::begin(entities), std::end(entities));
     pool.erase(std::begin(entities), std::end(entities));
     const stable_type values[2u] = {stable_type{42}, stable_type{3}};
     const stable_type values[2u] = {stable_type{42}, stable_type{3}};
@@ -342,6 +344,8 @@ TEST_F(Storage, Insert) {
     ASSERT_EQ(pool.index(entities[1u]), 2u);
     ASSERT_EQ(pool.index(entities[1u]), 2u);
     ASSERT_EQ(pool.get(entities[0u]).value, 3);
     ASSERT_EQ(pool.get(entities[0u]).value, 3);
     ASSERT_EQ(pool.get(entities[1u]).value, 42);
     ASSERT_EQ(pool.get(entities[1u]).value, 42);
+    ASSERT_EQ(it++->value, 3);
+    ASSERT_EQ(it->value, 42);
 }
 }
 
 
 TEST_F(Storage, InsertEmptyType) {
 TEST_F(Storage, InsertEmptyType) {