Browse Source

sigh:
* fixed doc
* test review/cleanup

Michele Caini 4 years ago
parent
commit
52f77d61ba
2 changed files with 33 additions and 39 deletions
  1. 4 4
      src/entt/signal/sigh.hpp
  2. 29 35
      test/entt/signal/sigh.cpp

+ 4 - 4
src/entt/signal/sigh.hpp

@@ -81,7 +81,7 @@ public:
         : calls{allocator} {}
 
     /**
-     * @brief Default copy constructor.
+     * @brief Copy constructor.
      * @param other The instance to copy from.
      */
     sigh(const sigh &other)
@@ -96,7 +96,7 @@ public:
         : calls{other.calls, allocator} {}
 
     /**
-     * @brief Default move constructor.
+     * @brief Move constructor.
      * @param other The instance to move from.
      */
     sigh(sigh &&other) ENTT_NOEXCEPT
@@ -111,7 +111,7 @@ public:
         : calls{std::move(other.calls), allocator} {}
 
     /**
-     * @brief Default copy assignment operator.
+     * @brief Copy assignment operator.
      * @param other The instance to copy from.
      * @return This signal handler.
      */
@@ -121,7 +121,7 @@ public:
     }
 
     /**
-     * @brief Default move assignment operator.
+     * @brief Move assignment operator.
      * @param other The instance to move from.
      * @return This signal handler.
      */

+ 29 - 35
test/entt/signal/sigh.cpp

@@ -531,53 +531,47 @@ TEST_F(SigH, UnboundMemberFunction) {
 
 TEST_F(SigH, CustomAllocator) {
     std::allocator<void (*)(int)> allocator;
+    entt::sigh<void(int), decltype(allocator)> sigh{allocator};
 
-    auto test = [&](auto curr) {
-        ASSERT_EQ(curr.get_allocator(), allocator);
-        ASSERT_FALSE(curr.get_allocator() != allocator);
-        ASSERT_TRUE(curr.empty());
-
-        entt::sink sink{curr};
-        sigh_listener listener;
-        sink.template connect<&sigh_listener::g>(listener);
-
-        decltype(curr) copy{curr, allocator};
-        sink.disconnect(listener);
+    ASSERT_EQ(sigh.get_allocator(), allocator);
+    ASSERT_FALSE(sigh.get_allocator() != allocator);
+    ASSERT_TRUE(sigh.empty());
 
-        ASSERT_TRUE(curr.empty());
-        ASSERT_FALSE(copy.empty());
+    entt::sink sink{sigh};
+    sigh_listener listener;
+    sink.template connect<&sigh_listener::g>(listener);
 
-        curr = copy;
+    decltype(sigh) copy{sigh, allocator};
+    sink.disconnect(listener);
 
-        ASSERT_FALSE(curr.empty());
-        ASSERT_FALSE(copy.empty());
+    ASSERT_TRUE(sigh.empty());
+    ASSERT_FALSE(copy.empty());
 
-        decltype(curr) move{std::move(copy), allocator};
+    sigh = copy;
 
-        ASSERT_TRUE(copy.empty());
-        ASSERT_FALSE(move.empty());
+    ASSERT_FALSE(sigh.empty());
+    ASSERT_FALSE(copy.empty());
 
-        sink = entt::sink{move};
-        sink.disconnect(&listener);
+    decltype(sigh) move{std::move(copy), allocator};
 
-        ASSERT_TRUE(copy.empty());
-        ASSERT_TRUE(move.empty());
+    ASSERT_TRUE(copy.empty());
+    ASSERT_FALSE(move.empty());
 
-        sink.template connect<&sigh_listener::g>(listener);
-        copy.swap(move);
+    sink = entt::sink{move};
+    sink.disconnect(&listener);
 
-        ASSERT_FALSE(copy.empty());
-        ASSERT_TRUE(move.empty());
+    ASSERT_TRUE(copy.empty());
+    ASSERT_TRUE(move.empty());
 
-        sink = entt::sink{copy};
-        sink.disconnect();
+    sink.template connect<&sigh_listener::g>(listener);
+    copy.swap(move);
 
-        ASSERT_TRUE(copy.empty());
-        ASSERT_TRUE(move.empty());
-    };
+    ASSERT_FALSE(copy.empty());
+    ASSERT_TRUE(move.empty());
 
-    entt::sigh<void(int), decltype(allocator)> sigh{allocator};
+    sink = entt::sink{copy};
+    sink.disconnect();
 
-    test(sigh);
-    test(std::move(sigh));
+    ASSERT_TRUE(copy.empty());
+    ASSERT_TRUE(move.empty());
 }