[libsigcplusplus] Tests: Add comments by uses after move.



commit 4986e90562311e91b23a451bcc2cb9edd50fdaca
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jul 21 08:40:04 2017 +0200

    Tests: Add comments by uses after move.
    
    Because we really do want to test this.
    We do not explicitly promise that it's safe to use moved-from libsigc++
    objects, but we choose to make it safe.

 tests/test_signal_move.cc    |    4 ++--
 tests/test_slot_move.cc      |    4 ++--
 tests/test_trackable_move.cc |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/tests/test_signal_move.cc b/tests/test_signal_move.cc
index 82080c1..83a6316 100644
--- a/tests/test_signal_move.cc
+++ b/tests/test_signal_move.cc
@@ -35,14 +35,14 @@ main(int argc, char* argv[])
 
   // Test the move constructor:
   sigc::signal<int(int)> sig2(std::move(sig));
-  sig(-2);
+  sig(-2); // Test that the moved-from slot does nothing.
   sig2(2);
   util->check_result(result_stream, "foo(int 2)");
 
   // Test the move assignment operator:
   sigc::signal<int(int)> sig3;
   sig3 = std::move(sig2);
-  sig2(-3);
+  sig2(-3); // Test that the moved-from slot does nothing.
   sig3(3);
   util->check_result(result_stream, "foo(int 3)");
 
diff --git a/tests/test_slot_move.cc b/tests/test_slot_move.cc
index f1bec22..d207172 100644
--- a/tests/test_slot_move.cc
+++ b/tests/test_slot_move.cc
@@ -43,14 +43,14 @@ main(int argc, char* argv[])
 
   // test move constructor:
   sigc::slot<void(int)> s2(std::move(s1));
-  s1(-2);
+  s1(-2); // Test that the moved-from slot does nothing.
   s2(2);
   util->check_result(result_stream, "foo(int 2)");
 
   // test move assignment:
   sigc::slot<void(int)> s3;
   s3 = std::move(s2);
-  s2(-3);
+  s2(-3); // Test that the moved-from slot does nothing.
   s3(3);
   util->check_result(result_stream, "foo(int 3)");
 
diff --git a/tests/test_trackable_move.cc b/tests/test_trackable_move.cc
index 90e3aa2..daf80ce 100644
--- a/tests/test_trackable_move.cc
+++ b/tests/test_trackable_move.cc
@@ -23,11 +23,11 @@ public:
     src.i = 0;
   }
 
-  my_class& operator=(my_class&& src)
+  my_class& operator=(my_class&& src) noexcept
   {
     sigc::trackable::operator=(std::move(src));
     i = std::move(src.i);
-    src.i = 0;
+    src.i = 0; // Make the moved-from object zeroed. Undefined behaviour would be acceptable too.
     return *this;
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]