[glibmm] tests/glibmm_refptr: Add simpler tests for move constructor/operator=.



commit 2c76615b0dcf5f56ec4d231a13c7fd4836bf792f
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Jul 28 09:41:17 2015 +0200

    tests/glibmm_refptr: Add simpler tests for move constructor/operator=.
    
    The *with_parent* tests test much the same thing, but these ones
    are simpler, based on Marcin Kolny's simpler tests for the
    universal reference versions.

 tests/glibmm_refptr/main.cc |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/tests/glibmm_refptr/main.cc b/tests/glibmm_refptr/main.cc
index d55cb57..d03b224 100644
--- a/tests/glibmm_refptr/main.cc
+++ b/tests/glibmm_refptr/main.cc
@@ -197,6 +197,27 @@ void test_refptr_with_parent_move_constructor()
 }
 
 static
+void test_refptr_move_constructor()
+{
+  Glib::RefPtr<Something> refSomething(new Something());
+  Glib::RefPtr<Something> refSomething2(std::move(refSomething));
+  g_assert_cmpint(refSomething2->ref_count(), ==, 1);
+  g_assert(!refSomething);
+  g_assert_cmpint(refSomething2->max_ref_count(), ==, 1);
+}
+
+static
+void test_refptr_move_assignment_operator()
+{
+  Glib::RefPtr<Something> refSomething(new Something());
+  Glib::RefPtr<Something> refSomething2;
+  refSomething2 = std::move(refSomething);
+  g_assert_cmpint(refSomething2->ref_count(), ==, 1);
+  g_assert(!refSomething);
+  g_assert_cmpint(refSomething2->max_ref_count(), ==, 1);
+}
+
+static
 void test_refptr_universal_reference_move_constructor()
 {
   Glib::RefPtr<SomethingDerived> refSomethingDerived(new SomethingDerived());
@@ -228,11 +249,17 @@ int main(int, char**)
   //Test refcount when using the RefPtr assignment operator (operator=):
   test_refptr_assignment_operator();
 
+  //Test the refcount when using the RefPtr move constuctor:
+  test_refptr_move_constructor();
+
+  //Test the refcount when using the RefPtr move asignment operator (operator=):
+  test_refptr_move_assignment_operator();
+
   //Test the refcount when another class makes a copy via its constructor:
   test_refptr_with_parent_copy_constructor();
 
   //Test the refcount when another class makes a copy via its
-  //(perfect-forwarding)move constructor, which should not involve a temporary
+  //(perfect-forwarding) move constructor, which should not involve a temporary
   //instance:
   test_refptr_with_parent_move_constructor();  
 


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