summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/test
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-09-03 15:00:41 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-09-03 15:00:41 +0000
commit527d4871c7826d5a07686c5e3f1f6edb18fbdc3d (patch)
treebeba4bac3d540907b0fe1bc2a90fa5ba83cac341 /src/Simplex_tree/test
parent7f94efd0e40f9fe15d9131643c19e285fbf75d6e (diff)
Code review : Fix remarks for move and copy assignment
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/simplex_tree_fix_vincent@3868 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 069e920ab3ca9504b5e1c49ab23afe1693f4e6f8
Diffstat (limited to 'src/Simplex_tree/test')
-rw-r--r--src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp
index 95e99afe..6c27a458 100644
--- a/src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp
+++ b/src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp
@@ -75,6 +75,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_copy_constructor, Simplex_tree, list_of_te
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF COPY ASSIGNMENT" << std::endl;
Simplex_tree st3;
+ // To check there is no memory leak
+ st3.insert_simplex_and_subfaces({9, 10, 11}, 200.0);
st3 = st;
print_simplex_filtration(st3, "First copy assignment from the default Simplex_tree");
Simplex_tree st4;
@@ -108,12 +110,18 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_copy_constructor, Simplex_tree, list_of_te
std::cout << "********************************************************************" << std::endl;
std::cout << "TEST OF MOVE ASSIGNMENT" << std::endl;
- // A swap is a copy ctor of a tmp value, then it uses move assignment
- std::swap(st3, st4);
- print_simplex_filtration(st3, "First move assignment from the default Simplex_tree");
- print_simplex_filtration(st4, "Second move assignment from the default Simplex_tree");
- BOOST_CHECK(st3 == st4);
- BOOST_CHECK(st == st4);
- BOOST_CHECK(st3 == st);
+ Simplex_tree st7;
+ // To check there is no memory leak
+ st7.insert_simplex_and_subfaces({9, 10, 11}, 200.0);
+ st7 = std::move(st3);
+ print_simplex_filtration(st7, "First move assignment from the default Simplex_tree");
+ Simplex_tree st8;
+ st8 = std::move(st4);
+ print_simplex_filtration(st8, "Second move assignment from the default Simplex_tree");
+
+ // Cross check
+ BOOST_CHECK(st7 == st8);
+ BOOST_CHECK(st == st8);
+ BOOST_CHECK(st7 == st);
}