snapshot: code coverage

This commit is contained in:
Michele Caini
2023-07-10 14:02:53 +02:00
parent acae0533bc
commit 77b5907a9f
2 changed files with 9 additions and 3 deletions

View File

@@ -172,9 +172,7 @@ public:
basic_snapshot_loader(registry_type &source) noexcept
: reg{&source} {
// restoring a snapshot as a whole requires a clean registry
for([[maybe_unused]] auto elem: source.storage()) {
ENTT_ASSERT(elem.second.empty(), "Registry must be empty");
}
ENTT_ASSERT(reg->template storage<entity_type>().empty() && (reg->storage().begin() == reg->storage().end()), "Registry must be empty");
}
/*! @brief Default move constructor. */

View File

@@ -12,6 +12,7 @@
#include <entt/entity/registry.hpp>
#include <entt/entity/snapshot.hpp>
#include <entt/signal/sigh.hpp>
#include "../common/config.h"
struct empty {};
@@ -231,6 +232,13 @@ TEST(BasicSnapshotLoader, Constructors) {
ASSERT_NO_FATAL_FAILURE(loader = std::move(other));
}
ENTT_DEBUG_TEST(BasicSnapshotLoaderDeathTest, Constructors) {
entt::registry registry;
registry.emplace<int>(registry.create());
ASSERT_DEATH([[maybe_unused]] entt::basic_snapshot_loader loader{registry}, "");
}
TEST(BasicSnapshotLoader, GetEntityType) {
using namespace entt::literals;
using traits_type = entt::entt_traits<entt::entity>;