diff --git a/src/entt/entity/organizer.hpp b/src/entt/entity/organizer.hpp index 8f7cababb..6ec145ad4 100644 --- a/src/entt/entity/organizer.hpp +++ b/src/entt/entity/organizer.hpp @@ -109,13 +109,13 @@ resource, type_list> to_resource(); /** * @brief Utility class for creating a static task graph. - * + * * This class offers minimal support (but sufficient in many cases) for creating * an execution graph from functions and their requirements on resources.
* Note that the resulting tasks aren't executed in any case. This isn't the * goal of the tool. Instead, they are returned to the user in the form of a * graph that allows for safe execution. - * + * * @tparam Entity A valid entity type (see entt_traits for more details). */ template diff --git a/src/entt/signal/dispatcher.hpp b/src/entt/signal/dispatcher.hpp index 1c656ce8a..cc5db24a4 100644 --- a/src/entt/signal/dispatcher.hpp +++ b/src/entt/signal/dispatcher.hpp @@ -88,15 +88,15 @@ class dispatcher { template [[nodiscard]] pool_handler & assure() { const auto index = type_seq::value(); - + if(!(index < pools.size())) { pools.resize(std::size_t(index)+1u); } - + if(!pools[index]) { pools[index].reset(new pool_handler{}); } - + return static_cast &>(*pools[index]); } diff --git a/src/entt/signal/emitter.hpp b/src/entt/signal/emitter.hpp index 43606e49c..2dfbf2a98 100644 --- a/src/entt/signal/emitter.hpp +++ b/src/entt/signal/emitter.hpp @@ -34,7 +34,7 @@ namespace entt { * required to specify in advance the full list of accepted types.
* Moreover, whenever an event is published, an emitter provides the listeners * with a reference to itself along with a reference to the event. Therefore - * listeners have an handy way to work with it without incurring in the need of + * listeners have an handy way to work with it without incurring in the need of * capturing a reference to the emitter. * * @tparam Derived Actual type of emitter that extends the class template. @@ -124,15 +124,15 @@ class emitter { template [[nodiscard]] const pool_handler & assure() const { const auto index = type_seq::value(); - + if(!(index < pools.size())) { pools.resize(std::size_t(index)+1u); } - + if(!pools[index]) { pools[index].reset(new pool_handler{}); } - + return static_cast &>(*pools[index]); } diff --git a/src/entt/signal/sigh.hpp b/src/entt/signal/sigh.hpp index dbb15ccc9..53a1e668e 100644 --- a/src/entt/signal/sigh.hpp +++ b/src/entt/signal/sigh.hpp @@ -257,7 +257,7 @@ private: * The clear separation between a signal and a sink permits to store the former * as private data member without exposing the publish functionality to the * users of the class. - * + * * @warning * Lifetime of a sink must not overcome that of the signal to which it refers. * In any other case, attempting to use a sink results in undefined behavior. diff --git a/test/entt/core/type_info.cpp b/test/entt/core/type_info.cpp index b7a9c459f..07a2d3c82 100644 --- a/test/entt/core/type_info.cpp +++ b/test/entt/core/type_info.cpp @@ -75,4 +75,4 @@ TEST(TypeInfo, Functionalities) { ASSERT_TRUE(empty); ASSERT_EQ(empty.hash(), other.hash()); -} \ No newline at end of file +} diff --git a/test/entt/entity/observer.cpp b/test/entt/entity/observer.cpp index d952f6f33..125111d6f 100644 --- a/test/entt/entity/observer.cpp +++ b/test/entt/entity/observer.cpp @@ -366,4 +366,4 @@ TEST(Observer, GroupCornerCase) { ASSERT_FALSE(add_observer.empty()); ASSERT_TRUE(remove_observer.empty()); -} \ No newline at end of file +} diff --git a/test/entt/entity/organizer.cpp b/test/entt/entity/organizer.cpp index 00d9e1edf..4b222e3ff 100644 --- a/test/entt/entity/organizer.cpp +++ b/test/entt/entity/organizer.cpp @@ -9,340 +9,340 @@ void ro_int_double(entt::view, const int>, const double &) {} void sync_point(entt::registry &) {} struct clazz { - void ro_int_char_double(entt::view, const int, const char>, const double &) {} - void rw_int(entt::view, int>) {} - void rw_int_char(entt::view, int, char>) {} - void rw_int_char_double(entt::view, int, char>, double &) {} + void ro_int_char_double(entt::view, const int, const char>, const double &) {} + void rw_int(entt::view, int>) {} + void rw_int_char(entt::view, int, char>) {} + void rw_int_char_double(entt::view, int, char>, double &) {} }; void to_args_integrity(entt::view, int> view, std::size_t &value, entt::registry ®istry) { - value = view.size(); + value = view.size(); } TEST(Organizer, EmplaceFreeFunction) { - entt::organizer organizer; - entt::registry registry; + entt::organizer organizer; + entt::registry registry; - organizer.emplace<&ro_int_rw_char_double>("t1"); - organizer.emplace<&ro_char_rw_int>("t2"); - organizer.emplace<&ro_char_rw_double>("t3"); - organizer.emplace<&ro_int_double>("t4"); + organizer.emplace<&ro_int_rw_char_double>("t1"); + organizer.emplace<&ro_char_rw_int>("t2"); + organizer.emplace<&ro_char_rw_double>("t3"); + organizer.emplace<&ro_int_double>("t4"); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(graph.size(), 4u); + ASSERT_EQ(graph.size(), 4u); - ASSERT_STREQ(graph[0u].name(), "t1"); - ASSERT_STREQ(graph[1u].name(), "t2"); - ASSERT_STREQ(graph[2u].name(), "t3"); - ASSERT_STREQ(graph[3u].name(), "t4"); + ASSERT_STREQ(graph[0u].name(), "t1"); + ASSERT_STREQ(graph[1u].name(), "t2"); + ASSERT_STREQ(graph[2u].name(), "t3"); + ASSERT_STREQ(graph[3u].name(), "t4"); - ASSERT_EQ(graph[0u].ro_count(), 1u); - ASSERT_EQ(graph[1u].ro_count(), 1u); - ASSERT_EQ(graph[2u].ro_count(), 1u); - ASSERT_EQ(graph[3u].ro_count(), 2u); + ASSERT_EQ(graph[0u].ro_count(), 1u); + ASSERT_EQ(graph[1u].ro_count(), 1u); + ASSERT_EQ(graph[2u].ro_count(), 1u); + ASSERT_EQ(graph[3u].ro_count(), 2u); - ASSERT_EQ(graph[0u].rw_count(), 2u); - ASSERT_EQ(graph[1u].rw_count(), 1u); - ASSERT_EQ(graph[2u].rw_count(), 1u); - ASSERT_EQ(graph[3u].rw_count(), 0u); + ASSERT_EQ(graph[0u].rw_count(), 2u); + ASSERT_EQ(graph[1u].rw_count(), 1u); + ASSERT_EQ(graph[2u].rw_count(), 1u); + ASSERT_EQ(graph[3u].rw_count(), 0u); - ASSERT_NE(graph[0u].info(), graph[1u].info()); - ASSERT_NE(graph[1u].info(), graph[2u].info()); - ASSERT_NE(graph[2u].info(), graph[3u].info()); + ASSERT_NE(graph[0u].info(), graph[1u].info()); + ASSERT_NE(graph[1u].info(), graph[2u].info()); + ASSERT_NE(graph[2u].info(), graph[3u].info()); - ASSERT_TRUE(graph[0u].top_level()); - ASSERT_FALSE(graph[1u].top_level()); - ASSERT_FALSE(graph[2u].top_level()); - ASSERT_FALSE(graph[3u].top_level()); + ASSERT_TRUE(graph[0u].top_level()); + ASSERT_FALSE(graph[1u].top_level()); + ASSERT_FALSE(graph[2u].top_level()); + ASSERT_FALSE(graph[3u].top_level()); - ASSERT_EQ(graph[0u].children().size(), 2u); - ASSERT_EQ(graph[1u].children().size(), 1u); - ASSERT_EQ(graph[2u].children().size(), 1u); - ASSERT_EQ(graph[3u].children().size(), 0u); + ASSERT_EQ(graph[0u].children().size(), 2u); + ASSERT_EQ(graph[1u].children().size(), 1u); + ASSERT_EQ(graph[2u].children().size(), 1u); + ASSERT_EQ(graph[3u].children().size(), 0u); - ASSERT_EQ(graph[0u].children()[0u], 1u); - ASSERT_EQ(graph[0u].children()[1u], 2u); - ASSERT_EQ(graph[1u].children()[0u], 3u); - ASSERT_EQ(graph[2u].children()[0u], 3u); + ASSERT_EQ(graph[0u].children()[0u], 1u); + ASSERT_EQ(graph[0u].children()[1u], 2u); + ASSERT_EQ(graph[1u].children()[0u], 3u); + ASSERT_EQ(graph[2u].children()[0u], 3u); - for(auto &&vertex: graph) { - ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); - } + for(auto &&vertex: graph) { + ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); + } - organizer.clear(); + organizer.clear(); - ASSERT_EQ(organizer.graph().size(), 0u); + ASSERT_EQ(organizer.graph().size(), 0u); } TEST(Organizer, EmplaceMemberFunction) { - entt::organizer organizer; - entt::registry registry; - clazz instance; + entt::organizer organizer; + entt::registry registry; + clazz instance; - organizer.emplace<&clazz::ro_int_char_double>(instance, "t1"); - organizer.emplace<&clazz::rw_int>(instance, "t2"); - organizer.emplace<&clazz::rw_int_char>(instance, "t3"); - organizer.emplace<&clazz::rw_int_char_double>(instance, "t4"); + organizer.emplace<&clazz::ro_int_char_double>(instance, "t1"); + organizer.emplace<&clazz::rw_int>(instance, "t2"); + organizer.emplace<&clazz::rw_int_char>(instance, "t3"); + organizer.emplace<&clazz::rw_int_char_double>(instance, "t4"); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(graph.size(), 4u); + ASSERT_EQ(graph.size(), 4u); - ASSERT_STREQ(graph[0u].name(), "t1"); - ASSERT_STREQ(graph[1u].name(), "t2"); - ASSERT_STREQ(graph[2u].name(), "t3"); - ASSERT_STREQ(graph[3u].name(), "t4"); + ASSERT_STREQ(graph[0u].name(), "t1"); + ASSERT_STREQ(graph[1u].name(), "t2"); + ASSERT_STREQ(graph[2u].name(), "t3"); + ASSERT_STREQ(graph[3u].name(), "t4"); - ASSERT_EQ(graph[0u].ro_count(), 3u); - ASSERT_EQ(graph[1u].ro_count(), 0u); - ASSERT_EQ(graph[2u].ro_count(), 0u); - ASSERT_EQ(graph[3u].ro_count(), 0u); + ASSERT_EQ(graph[0u].ro_count(), 3u); + ASSERT_EQ(graph[1u].ro_count(), 0u); + ASSERT_EQ(graph[2u].ro_count(), 0u); + ASSERT_EQ(graph[3u].ro_count(), 0u); - ASSERT_EQ(graph[0u].rw_count(), 0u); - ASSERT_EQ(graph[1u].rw_count(), 1u); - ASSERT_EQ(graph[2u].rw_count(), 2u); - ASSERT_EQ(graph[3u].rw_count(), 3u); + ASSERT_EQ(graph[0u].rw_count(), 0u); + ASSERT_EQ(graph[1u].rw_count(), 1u); + ASSERT_EQ(graph[2u].rw_count(), 2u); + ASSERT_EQ(graph[3u].rw_count(), 3u); - ASSERT_NE(graph[0u].info(), graph[1u].info()); - ASSERT_NE(graph[1u].info(), graph[2u].info()); - ASSERT_NE(graph[2u].info(), graph[3u].info()); + ASSERT_NE(graph[0u].info(), graph[1u].info()); + ASSERT_NE(graph[1u].info(), graph[2u].info()); + ASSERT_NE(graph[2u].info(), graph[3u].info()); - ASSERT_TRUE(graph[0u].top_level()); - ASSERT_FALSE(graph[1u].top_level()); - ASSERT_FALSE(graph[2u].top_level()); - ASSERT_FALSE(graph[3u].top_level()); + ASSERT_TRUE(graph[0u].top_level()); + ASSERT_FALSE(graph[1u].top_level()); + ASSERT_FALSE(graph[2u].top_level()); + ASSERT_FALSE(graph[3u].top_level()); - ASSERT_EQ(graph[0u].children().size(), 1u); - ASSERT_EQ(graph[1u].children().size(), 1u); - ASSERT_EQ(graph[2u].children().size(), 1u); - ASSERT_EQ(graph[3u].children().size(), 0u); + ASSERT_EQ(graph[0u].children().size(), 1u); + ASSERT_EQ(graph[1u].children().size(), 1u); + ASSERT_EQ(graph[2u].children().size(), 1u); + ASSERT_EQ(graph[3u].children().size(), 0u); - ASSERT_EQ(graph[0u].children()[0u], 1u); - ASSERT_EQ(graph[1u].children()[0u], 2u); - ASSERT_EQ(graph[2u].children()[0u], 3u); + ASSERT_EQ(graph[0u].children()[0u], 1u); + ASSERT_EQ(graph[1u].children()[0u], 2u); + ASSERT_EQ(graph[2u].children()[0u], 3u); - for(auto &&vertex: graph) { - ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); - } + for(auto &&vertex: graph) { + ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); + } - organizer.clear(); + organizer.clear(); - ASSERT_EQ(organizer.graph().size(), 0u); + ASSERT_EQ(organizer.graph().size(), 0u); } TEST(Organizer, EmplaceDirectFunction) { - entt::organizer organizer; - entt::registry registry; - clazz instance; + entt::organizer organizer; + entt::registry registry; + clazz instance; - // no aggressive comdat - auto t1 = +[](const void *, entt::registry ®) { reg.clear(); }; - auto t2 = +[](const void *, entt::registry ®) { reg.clear(); }; - auto t3 = +[](const void *, entt::registry ®) { reg.clear(); }; - auto t4 = +[](const void *, entt::registry ®) { reg.clear(); }; + // no aggressive comdat + auto t1 = +[](const void *, entt::registry ®) { reg.clear(); }; + auto t2 = +[](const void *, entt::registry ®) { reg.clear(); }; + auto t3 = +[](const void *, entt::registry ®) { reg.clear(); }; + auto t4 = +[](const void *, entt::registry ®) { reg.clear(); }; - organizer.emplace(t1, nullptr, "t1"); - organizer.emplace(t2, &instance, "t2"); - organizer.emplace(t3, nullptr, "t3"); - organizer.emplace(t4, &instance, "t4"); + organizer.emplace(t1, nullptr, "t1"); + organizer.emplace(t2, &instance, "t2"); + organizer.emplace(t3, nullptr, "t3"); + organizer.emplace(t4, &instance, "t4"); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(graph.size(), 4u); + ASSERT_EQ(graph.size(), 4u); - ASSERT_STREQ(graph[0u].name(), "t1"); - ASSERT_STREQ(graph[1u].name(), "t2"); - ASSERT_STREQ(graph[2u].name(), "t3"); - ASSERT_STREQ(graph[3u].name(), "t4"); + ASSERT_STREQ(graph[0u].name(), "t1"); + ASSERT_STREQ(graph[1u].name(), "t2"); + ASSERT_STREQ(graph[2u].name(), "t3"); + ASSERT_STREQ(graph[3u].name(), "t4"); - ASSERT_EQ(graph[0u].ro_count(), 0u); - ASSERT_EQ(graph[1u].ro_count(), 1u); - ASSERT_EQ(graph[2u].ro_count(), 1u); - ASSERT_EQ(graph[3u].ro_count(), 0u); + ASSERT_EQ(graph[0u].ro_count(), 0u); + ASSERT_EQ(graph[1u].ro_count(), 1u); + ASSERT_EQ(graph[2u].ro_count(), 1u); + ASSERT_EQ(graph[3u].ro_count(), 0u); - ASSERT_EQ(graph[0u].rw_count(), 1u); - ASSERT_EQ(graph[1u].rw_count(), 0u); - ASSERT_EQ(graph[2u].rw_count(), 1u); - ASSERT_EQ(graph[3u].rw_count(), 3u); + ASSERT_EQ(graph[0u].rw_count(), 1u); + ASSERT_EQ(graph[1u].rw_count(), 0u); + ASSERT_EQ(graph[2u].rw_count(), 1u); + ASSERT_EQ(graph[3u].rw_count(), 3u); - ASSERT_TRUE(graph[0u].callback() == t1); - ASSERT_TRUE(graph[1u].callback() == t2); - ASSERT_TRUE(graph[2u].callback() == t3); - ASSERT_TRUE(graph[3u].callback() == t4); + ASSERT_TRUE(graph[0u].callback() == t1); + ASSERT_TRUE(graph[1u].callback() == t2); + ASSERT_TRUE(graph[2u].callback() == t3); + ASSERT_TRUE(graph[3u].callback() == t4); - ASSERT_EQ(graph[0u].data(), nullptr); - ASSERT_EQ(graph[1u].data(), &instance); - ASSERT_EQ(graph[2u].data(), nullptr); - ASSERT_EQ(graph[3u].data(), &instance); + ASSERT_EQ(graph[0u].data(), nullptr); + ASSERT_EQ(graph[1u].data(), &instance); + ASSERT_EQ(graph[2u].data(), nullptr); + ASSERT_EQ(graph[3u].data(), &instance); - ASSERT_EQ(graph[0u].info(), entt::type_info{}); - ASSERT_EQ(graph[1u].info(), entt::type_info{}); - ASSERT_EQ(graph[2u].info(), entt::type_info{}); - ASSERT_EQ(graph[3u].info(), entt::type_info{}); + ASSERT_EQ(graph[0u].info(), entt::type_info{}); + ASSERT_EQ(graph[1u].info(), entt::type_info{}); + ASSERT_EQ(graph[2u].info(), entt::type_info{}); + ASSERT_EQ(graph[3u].info(), entt::type_info{}); - ASSERT_TRUE(graph[0u].top_level()); - ASSERT_FALSE(graph[1u].top_level()); - ASSERT_FALSE(graph[2u].top_level()); - ASSERT_FALSE(graph[3u].top_level()); + ASSERT_TRUE(graph[0u].top_level()); + ASSERT_FALSE(graph[1u].top_level()); + ASSERT_FALSE(graph[2u].top_level()); + ASSERT_FALSE(graph[3u].top_level()); - ASSERT_EQ(graph[0u].children().size(), 2u); - ASSERT_EQ(graph[1u].children().size(), 1u); - ASSERT_EQ(graph[2u].children().size(), 1u); - ASSERT_EQ(graph[3u].children().size(), 0u); + ASSERT_EQ(graph[0u].children().size(), 2u); + ASSERT_EQ(graph[1u].children().size(), 1u); + ASSERT_EQ(graph[2u].children().size(), 1u); + ASSERT_EQ(graph[3u].children().size(), 0u); - ASSERT_EQ(graph[0u].children()[0u], 1u); - ASSERT_EQ(graph[0u].children()[1u], 2u); - ASSERT_EQ(graph[1u].children()[0u], 3u); - ASSERT_EQ(graph[2u].children()[0u], 3u); + ASSERT_EQ(graph[0u].children()[0u], 1u); + ASSERT_EQ(graph[0u].children()[1u], 2u); + ASSERT_EQ(graph[1u].children()[0u], 3u); + ASSERT_EQ(graph[2u].children()[0u], 3u); - for(auto &&vertex: graph) { - ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); - } + for(auto &&vertex: graph) { + ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); + } - organizer.clear(); + organizer.clear(); - ASSERT_EQ(organizer.graph().size(), 0u); + ASSERT_EQ(organizer.graph().size(), 0u); } TEST(Organizer, SyncPoint) { - entt::organizer organizer; - entt::registry registry; - clazz instance; + entt::organizer organizer; + entt::registry registry; + clazz instance; - organizer.emplace<&ro_int_double>("before"); - organizer.emplace<&sync_point>("sync"); - organizer.emplace<&clazz::ro_int_char_double>(instance, "after"); + organizer.emplace<&ro_int_double>("before"); + organizer.emplace<&sync_point>("sync"); + organizer.emplace<&clazz::ro_int_char_double>(instance, "after"); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(graph.size(), 3u); + ASSERT_EQ(graph.size(), 3u); - ASSERT_STREQ(graph[0u].name(), "before"); - ASSERT_STREQ(graph[1u].name(), "sync"); - ASSERT_STREQ(graph[2u].name(), "after"); + ASSERT_STREQ(graph[0u].name(), "before"); + ASSERT_STREQ(graph[1u].name(), "sync"); + ASSERT_STREQ(graph[2u].name(), "after"); - ASSERT_TRUE(graph[0u].top_level()); - ASSERT_FALSE(graph[1u].top_level()); - ASSERT_FALSE(graph[2u].top_level()); + ASSERT_TRUE(graph[0u].top_level()); + ASSERT_FALSE(graph[1u].top_level()); + ASSERT_FALSE(graph[2u].top_level()); - ASSERT_EQ(graph[0u].children().size(), 1u); - ASSERT_EQ(graph[1u].children().size(), 1u); - ASSERT_EQ(graph[2u].children().size(), 0u); + ASSERT_EQ(graph[0u].children().size(), 1u); + ASSERT_EQ(graph[1u].children().size(), 1u); + ASSERT_EQ(graph[2u].children().size(), 0u); - ASSERT_EQ(graph[0u].children()[0u], 1u); - ASSERT_EQ(graph[1u].children()[0u], 2u); + ASSERT_EQ(graph[0u].children()[0u], 1u); + ASSERT_EQ(graph[1u].children()[0u], 2u); - for(auto &&vertex: graph) { - ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); - } + for(auto &&vertex: graph) { + ASSERT_NO_THROW(vertex.callback()(vertex.data(), registry)); + } } TEST(Organizer, Override) { - entt::organizer organizer; + entt::organizer organizer; - organizer.emplace<&ro_int_rw_char_double, const char, const double>("t1"); - organizer.emplace<&ro_char_rw_double, const double>("t2"); - organizer.emplace<&ro_int_double, double>("t3"); + organizer.emplace<&ro_int_rw_char_double, const char, const double>("t1"); + organizer.emplace<&ro_char_rw_double, const double>("t2"); + organizer.emplace<&ro_int_double, double>("t3"); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(graph.size(), 3u); + ASSERT_EQ(graph.size(), 3u); - ASSERT_STREQ(graph[0u].name(), "t1"); - ASSERT_STREQ(graph[1u].name(), "t2"); - ASSERT_STREQ(graph[2u].name(), "t3"); + ASSERT_STREQ(graph[0u].name(), "t1"); + ASSERT_STREQ(graph[1u].name(), "t2"); + ASSERT_STREQ(graph[2u].name(), "t3"); - ASSERT_TRUE(graph[0u].top_level()); - ASSERT_TRUE(graph[1u].top_level()); - ASSERT_FALSE(graph[2u].top_level()); + ASSERT_TRUE(graph[0u].top_level()); + ASSERT_TRUE(graph[1u].top_level()); + ASSERT_FALSE(graph[2u].top_level()); - ASSERT_EQ(graph[0u].children().size(), 1u); - ASSERT_EQ(graph[1u].children().size(), 1u); - ASSERT_EQ(graph[2u].children().size(), 0u); + ASSERT_EQ(graph[0u].children().size(), 1u); + ASSERT_EQ(graph[1u].children().size(), 1u); + ASSERT_EQ(graph[2u].children().size(), 0u); - ASSERT_EQ(graph[0u].children()[0u], 2u); - ASSERT_EQ(graph[1u].children()[0u], 2u); + ASSERT_EQ(graph[0u].children()[0u], 2u); + ASSERT_EQ(graph[1u].children()[0u], 2u); } TEST(Organizer, Prepare) { - entt::organizer organizer; - entt::registry registry; - clazz instance; + entt::organizer organizer; + entt::registry registry; + clazz instance; - organizer.emplace<&ro_int_double>(); - organizer.emplace<&clazz::rw_int_char>(instance); + organizer.emplace<&ro_int_double>(); + organizer.emplace<&clazz::rw_int_char>(instance); - const auto graph = organizer.graph(); + const auto graph = organizer.graph(); - ASSERT_EQ(registry.try_ctx(), nullptr); - ASSERT_EQ(registry.try_ctx(), nullptr); - ASSERT_EQ(registry.try_ctx(), nullptr); + ASSERT_EQ(registry.try_ctx(), nullptr); + ASSERT_EQ(registry.try_ctx(), nullptr); + ASSERT_EQ(registry.try_ctx(), nullptr); - for(auto &&vertex: graph) { - vertex.prepare(registry); - } + for(auto &&vertex: graph) { + vertex.prepare(registry); + } - ASSERT_EQ(registry.try_ctx(), nullptr); - ASSERT_EQ(registry.try_ctx(), nullptr); - ASSERT_NE(registry.try_ctx(), nullptr); + ASSERT_EQ(registry.try_ctx(), nullptr); + ASSERT_EQ(registry.try_ctx(), nullptr); + ASSERT_NE(registry.try_ctx(), nullptr); } TEST(Organizer, Dependencies) { - entt::organizer organizer; - clazz instance; + entt::organizer organizer; + clazz instance; - organizer.emplace<&ro_int_double>(); - organizer.emplace<&clazz::rw_int_char>(instance); - organizer.emplace(+[](const void *, entt::registry &) {}); + organizer.emplace<&ro_int_double>(); + organizer.emplace<&clazz::rw_int_char>(instance); + organizer.emplace(+[](const void *, entt::registry &) {}); - const auto graph = organizer.graph(); - entt::type_info buffer[5u]{}; + const auto graph = organizer.graph(); + entt::type_info buffer[5u]{}; - ASSERT_EQ(graph.size(), 3u); + ASSERT_EQ(graph.size(), 3u); - ASSERT_EQ(graph[0u].ro_count(), 2u); - ASSERT_EQ(graph[0u].rw_count(), 0u); + ASSERT_EQ(graph[0u].ro_count(), 2u); + ASSERT_EQ(graph[0u].rw_count(), 0u); - ASSERT_EQ(graph[0u].ro_dependency(buffer, 0u), 0u); - ASSERT_EQ(graph[0u].rw_dependency(buffer, 2u), 0u); + ASSERT_EQ(graph[0u].ro_dependency(buffer, 0u), 0u); + ASSERT_EQ(graph[0u].rw_dependency(buffer, 2u), 0u); - ASSERT_EQ(graph[0u].ro_dependency(buffer, 5u), 2u); - ASSERT_EQ(buffer[0u], entt::type_id()); - ASSERT_EQ(buffer[1u], entt::type_id()); + ASSERT_EQ(graph[0u].ro_dependency(buffer, 5u), 2u); + ASSERT_EQ(buffer[0u], entt::type_id()); + ASSERT_EQ(buffer[1u], entt::type_id()); - ASSERT_EQ(graph[1u].ro_count(), 0u); - ASSERT_EQ(graph[1u].rw_count(), 2u); + ASSERT_EQ(graph[1u].ro_count(), 0u); + ASSERT_EQ(graph[1u].rw_count(), 2u); - ASSERT_EQ(graph[1u].ro_dependency(buffer, 2u), 0u); - ASSERT_EQ(graph[1u].rw_dependency(buffer, 0u), 0u); + ASSERT_EQ(graph[1u].ro_dependency(buffer, 2u), 0u); + ASSERT_EQ(graph[1u].rw_dependency(buffer, 0u), 0u); - ASSERT_EQ(graph[1u].rw_dependency(buffer, 5u), 2u); - ASSERT_EQ(buffer[0u], entt::type_id()); - ASSERT_EQ(buffer[1u], entt::type_id()); + ASSERT_EQ(graph[1u].rw_dependency(buffer, 5u), 2u); + ASSERT_EQ(buffer[0u], entt::type_id()); + ASSERT_EQ(buffer[1u], entt::type_id()); - ASSERT_EQ(graph[2u].ro_count(), 1u); - ASSERT_EQ(graph[2u].rw_count(), 1u); + ASSERT_EQ(graph[2u].ro_count(), 1u); + ASSERT_EQ(graph[2u].rw_count(), 1u); - ASSERT_EQ(graph[2u].ro_dependency(buffer, 2u), 1u); - ASSERT_EQ(graph[2u].rw_dependency(buffer, 0u), 0u); + ASSERT_EQ(graph[2u].ro_dependency(buffer, 2u), 1u); + ASSERT_EQ(graph[2u].rw_dependency(buffer, 0u), 0u); - ASSERT_EQ(graph[2u].ro_dependency(buffer, 5u), 1u); - ASSERT_EQ(buffer[0u], entt::type_id()); + ASSERT_EQ(graph[2u].ro_dependency(buffer, 5u), 1u); + ASSERT_EQ(buffer[0u], entt::type_id()); - ASSERT_EQ(graph[2u].rw_dependency(buffer, 5u), 1u); - ASSERT_EQ(buffer[0u], entt::type_id()); + ASSERT_EQ(graph[2u].rw_dependency(buffer, 5u), 1u); + ASSERT_EQ(buffer[0u], entt::type_id()); } TEST(Organizer, ToArgsIntegrity) { - entt::organizer organizer; - entt::registry registry; + entt::organizer organizer; + entt::registry registry; - organizer.emplace<&to_args_integrity>(); - registry.set(42u); + organizer.emplace<&to_args_integrity>(); + registry.set(42u); - auto graph = organizer.graph(); - graph[0u].callback()(graph[0u].data(), registry); + auto graph = organizer.graph(); + graph[0u].callback()(graph[0u].data(), registry); - ASSERT_EQ(registry.ctx(), 0u); + ASSERT_EQ(registry.ctx(), 0u); } diff --git a/test/entt/entity/view_pack.cpp b/test/entt/entity/view_pack.cpp index e3f1987da..b5db15c1b 100644 --- a/test/entt/entity/view_pack.cpp +++ b/test/entt/entity/view_pack.cpp @@ -73,7 +73,6 @@ TEST(ViewPack, Iterator) { registry.emplace(entity); const auto pack = registry.view() | registry.view(); - using iterator = typename decltype(pack)::iterator; ASSERT_NE(pack.begin(), pack.end()); ASSERT_EQ(pack.begin()++, pack.begin()); @@ -88,7 +87,6 @@ TEST(ViewPack, ReverseIterator) { registry.emplace(entity); const auto pack = registry.view() | registry.view(); - using iterator = typename decltype(pack)::reverse_iterator; ASSERT_NE(pack.rbegin(), pack.rend()); ASSERT_EQ(pack.rbegin()++, pack.rbegin()); @@ -327,16 +325,16 @@ TEST(ViewPack, ShortestPool) { ASSERT_FALSE(eit != pack.each().end()); { - std::size_t next{}; - - for(const auto [entt, cv, iv]: pack.each()) { - static_assert(std::is_same_v); - static_assert(std::is_same_v); - static_assert(std::is_same_v); - ASSERT_EQ(entt::to_integral(entt), ++next); - ASSERT_EQ(&cv, registry.try_get(entt)); - ASSERT_EQ(&iv, registry.try_get(entt)); - } + std::size_t next{}; + + for(const auto [entt, cv, iv]: pack.each()) { + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + ASSERT_EQ(entt::to_integral(entt), ++next); + ASSERT_EQ(&cv, registry.try_get(entt)); + ASSERT_EQ(&iv, registry.try_get(entt)); + } } } @@ -354,7 +352,7 @@ TEST(ViewPack, LongestPool) { { std::size_t next{2u}; - + for(const auto entt: pack) { ASSERT_EQ(entt::to_integral(entt), next--); ASSERT_TRUE((registry.has(entt))); @@ -393,7 +391,7 @@ TEST(ViewPack, LongestPool) { { std::size_t next{2u}; - + for(const auto [entt, iv, cv]: pack.each()) { static_assert(std::is_same_v); static_assert(std::is_same_v); diff --git a/test/entt/meta/meta_any.cpp b/test/entt/meta/meta_any.cpp index fe3b7cb0c..f6f9c1125 100644 --- a/test/entt/meta/meta_any.cpp +++ b/test/entt/meta/meta_any.cpp @@ -9,7 +9,7 @@ struct clazz_t { void member(int i) { value = i; } static void func() { c = 'd'; } - static inline char c = 'c'; + static inline char c = 'c'; int value = 0; }; @@ -641,27 +641,27 @@ TEST_F(MetaAny, Invoke) { clazz_t instance; entt::meta_any any{std::ref(instance)}; - ASSERT_TRUE(any.invoke("func"_hs)); - ASSERT_TRUE(any.invoke("member"_hs, 42)); - ASSERT_FALSE(any.invoke("non_existent"_hs, 42)); + ASSERT_TRUE(any.invoke("func"_hs)); + ASSERT_TRUE(any.invoke("member"_hs, 42)); + ASSERT_FALSE(any.invoke("non_existent"_hs, 42)); - ASSERT_EQ(clazz_t::c, 'd'); - ASSERT_EQ(instance.value, 42); + ASSERT_EQ(clazz_t::c, 'd'); + ASSERT_EQ(instance.value, 42); } TEST_F(MetaAny, SetGet) { clazz_t instance; entt::meta_any any{std::ref(instance)}; - ASSERT_TRUE(any.set("value"_hs, 42)); + ASSERT_TRUE(any.set("value"_hs, 42)); const auto value = any.get("value"_hs); - ASSERT_TRUE(value); - ASSERT_NE(value.try_cast(), nullptr); - ASSERT_EQ(value.cast(), 42); + ASSERT_TRUE(value); + ASSERT_NE(value.try_cast(), nullptr); + ASSERT_EQ(value.cast(), 42); ASSERT_EQ(instance.value, 42); - ASSERT_FALSE(any.set("non_existent"_hs, 42)); - ASSERT_FALSE(any.get("non_existent"_hs)); + ASSERT_FALSE(any.set("non_existent"_hs, 42)); + ASSERT_FALSE(any.get("non_existent"_hs)); } diff --git a/test/entt/meta/meta_func.cpp b/test/entt/meta/meta_func.cpp index ba8340b9c..017b81e51 100644 --- a/test/entt/meta/meta_func.cpp +++ b/test/entt/meta/meta_func.cpp @@ -347,10 +347,10 @@ TEST_F(MetaFunc, ExternalMemberFunction) { entt::registry registry; const auto entity = registry.create(); - + ASSERT_FALSE(registry.has(entity)); - + func.invoke({}, std::ref(registry), entity); - + ASSERT_TRUE(registry.has(entity)); } diff --git a/test/entt/meta/meta_pointer.cpp b/test/entt/meta/meta_pointer.cpp index 1c5052f39..46eaf0899 100644 --- a/test/entt/meta/meta_pointer.cpp +++ b/test/entt/meta/meta_pointer.cpp @@ -94,4 +94,4 @@ TEST(MetaPointerLike, PointerToMoveOnlyType) { ASSERT_TRUE(any); ASSERT_FALSE(*any); -} \ No newline at end of file +}