From 616d80c1208f3a14b871b0105f56ee9abd98a82c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 21 Aug 2018 08:06:31 +0000 Subject: Copy assignment for Simplex_tree and its tests (rules of 5) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/simplex_tree_fix_vincent@3814 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4ac0e87aaef3bf29369f25b8eb0c766a6f1b395b --- src/Simplex_tree/test/CMakeLists.txt | 8 +++ .../test/simplex_tree_ctor_and_move_unit_test.cpp | 63 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp (limited to 'src/Simplex_tree/test') diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index c63d8532..5bea3938 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -28,3 +28,11 @@ if (TBB_FOUND) endif() gudhi_add_coverage_test(Simplex_tree_iostream_operator_test_unit) + +add_executable ( Simplex_tree_ctor_and_move_test_unit simplex_tree_ctor_and_move_unit_test.cpp ) +target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_ctor_and_move_test_unit ${TBB_LIBRARIES}) +endif() + +gudhi_add_coverage_test(Simplex_tree_ctor_and_move_test_unit) 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 new file mode 100644 index 00000000..c9439e65 --- /dev/null +++ b/src/Simplex_tree/test/simplex_tree_ctor_and_move_unit_test.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include // std::pair, std::make_pair +#include // float comparison +#include +#include // greater + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree_constructor_and_move" +#include +#include + +// ^ +// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. +#include "gudhi/Simplex_tree.h" + +using namespace Gudhi; + +typedef boost::mpl::list, Simplex_tree> list_of_tested_variants; + + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_copy_constructor, Simplex_tree, list_of_tested_variants) { + std::cout << "********************************************************************" << std::endl; + std::cout << "TEST OF COPY CONSTRUCTOR" << std::endl; + Simplex_tree st; + + st.insert_simplex_and_subfaces({2, 1, 0}, 3.0); + st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.0); + st.insert_simplex_and_subfaces({3, 0}, 2.0); + st.insert_simplex_and_subfaces({3, 4, 5}, 3.0); + /* Inserted simplex: */ + /* 1 6 */ + /* o---o */ + /* /X\7/ */ + /* o---o---o---o */ + /* 2 0 3\X/4 */ + /* o */ + /* 5 */ + /* */ + /* In other words: */ + /* A facet [2,1,0] */ + /* An edge [0,3] */ + /* A facet [3,4,5] */ + /* A cell [0,1,6,7] */ + + Simplex_tree st1(st); + Simplex_tree st2(st); + // Cross check + BOOST_CHECK(st1 == st2); + BOOST_CHECK(st == st2); + BOOST_CHECK(st1 == st); + + std::cout << "********************************************************************" << std::endl; + std::cout << "TEST OF COPY ASSIGNMENT" << std::endl; + Simplex_tree st3 = st; + Simplex_tree st4 = st; + // Cross check + BOOST_CHECK(st3 == st4); + BOOST_CHECK(st == st4); + BOOST_CHECK(st3 == st); +} -- cgit v1.2.3