diff --git a/test/entt/resource/resource_cache.cpp b/test/entt/resource/resource_cache.cpp index 5da128fd9..559010352 100644 --- a/test/entt/resource/resource_cache.cpp +++ b/test/entt/resource/resource_cache.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "../common/linter.hpp" #include "../common/throwing_allocator.hpp" struct broken_tag {}; @@ -124,7 +125,9 @@ TEST(ResourceCache, Move) { entt::resource_cache other{std::move(cache)}; - ASSERT_EQ(cache.size(), 0u); // NOLINT + test::is_initialized(cache); + + ASSERT_TRUE(cache.empty()); ASSERT_TRUE(other.contains("resource"_hs)); cache = other; @@ -132,8 +135,9 @@ TEST(ResourceCache, Move) { cache.load("bar"_hs, 1u); other.load("quux"_hs, 0u); other = std::move(cache); + test::is_initialized(cache); - ASSERT_EQ(cache.size(), 0u); // NOLINT + ASSERT_TRUE(cache.empty()); ASSERT_TRUE(other.contains("resource"_hs)); ASSERT_TRUE(other.contains("foo"_hs)); ASSERT_TRUE(other.contains("bar"_hs)); @@ -321,34 +325,34 @@ TEST(ResourceCache, Load) { } TEST(ResourceCache, Erase) { - constexpr std::size_t resource_count = 8u; + constexpr std::size_t resource_count = 5u; entt::resource_cache cache; - for(std::size_t next{}, last = resource_count + 1u; next < last; ++next) { + for(std::size_t next{}; next < resource_count; ++next) { cache.load(static_cast(next), next); } - ASSERT_EQ(cache.size(), resource_count + 1u); + ASSERT_EQ(cache.size(), resource_count); - for(std::size_t next{}, last = resource_count + 1u; next < last; ++next) { + for(std::size_t next{}; next < resource_count; ++next) { ASSERT_TRUE(cache.contains(static_cast(next))); } auto it = cache.erase(++cache.begin()); it = cache.erase(it, it + 1); - ASSERT_EQ((--cache.end())->first, 6u); - ASSERT_EQ(cache.erase(6u), 1u); - ASSERT_EQ(cache.erase(6u), 0u); + ASSERT_EQ((--cache.end())->first, 2u); + ASSERT_EQ(cache.erase(2u), 1u); + ASSERT_EQ(cache.erase(2u), 0u); - ASSERT_EQ(cache.size(), resource_count + 1u - 3u); + ASSERT_EQ(cache.size(), 2u); ASSERT_EQ(it, ++cache.begin()); - ASSERT_EQ(it->first, 7u); - ASSERT_EQ((--cache.end())->first, 5u); + ASSERT_EQ(cache.begin()->first, 0u); + ASSERT_EQ((--cache.end())->first, 3u); - for(std::size_t next{}, last = resource_count + 1u; next < last; ++next) { - if(next == 1u || next == 8u || next == 6u) { // NOLINT + for(std::size_t next{}; next < resource_count; ++next) { + if(next == 1u || next == 2u || next == 4u) { ASSERT_FALSE(cache.contains(static_cast(next))); } else { ASSERT_TRUE(cache.contains(static_cast(next))); @@ -357,7 +361,7 @@ TEST(ResourceCache, Erase) { cache.erase(cache.begin(), cache.end()); - for(std::size_t next{}, last = resource_count + 1u; next < last; ++next) { + for(std::size_t next{}; next < resource_count; ++next) { ASSERT_FALSE(cache.contains(static_cast(next))); }