From c71dce7fe646cd4ca4da5f385cb0d97535e4d941 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 16 Oct 2018 13:57:50 +0000 Subject: Add lazy_toplex_map_unit_test Class documentation rewrite Fix conventions in code git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3956 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 65f79ee3c0f22157b2cedfc498e5d9c97dd055f6 --- src/Toplex_map/test/lazy_toplex_map_unit_test.cpp | 78 +++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/Toplex_map/test/lazy_toplex_map_unit_test.cpp (limited to 'src/Toplex_map/test/lazy_toplex_map_unit_test.cpp') diff --git a/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp b/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp new file mode 100644 index 00000000..77d464ae --- /dev/null +++ b/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp @@ -0,0 +1,78 @@ +#include +#include +#include + + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "lazy toplex map" +#include + +BOOST_AUTO_TEST_CASE(toplex_map) { + using Vertex = Gudhi::Lazy_Toplex_map::Vertex; + + Gudhi::Lazy_Toplex_map tm; + std::cout << "insert_simplex {1, 2, 3, 4}" << std::endl; + std::vector sigma1 = {1, 2, 3, 4}; + tm.insert_simplex(sigma1); + std::cout << "insert_simplex {5, 2, 3, 6}" << std::endl; + std::vector sigma2 = {5, 2, 3, 6}; + tm.insert_simplex(sigma2); + std::cout << "insert_simplex {5}" << std::endl; + std::vector sigma3 = {5}; + tm.insert_simplex(sigma3); + std::cout << "insert_simplex {4, 5, 3}" << std::endl; + std::vector sigma6 = {4, 5, 3}; + tm.insert_simplex(sigma6); + std::cout << "insert_simplex {4, 5, 9}" << std::endl; + std::vector sigma7 = {4, 5, 9}; + tm.insert_simplex(sigma7); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 5); + + std::vector sigma4 = {5, 2, 3}; + std::vector sigma5 = {5, 2, 7}; + BOOST_CHECK(tm.membership(sigma4)); + BOOST_CHECK(!tm.membership(sigma5)); + std::cout << "insert_simplex {5, 2, 7}" << std::endl; + tm.insert_simplex(sigma5); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 6); + + BOOST_CHECK(tm.membership(sigma5)); + + std::cout << "contraction(4,5)" << std::endl; + auto r = tm.contraction(4,5); + std::cout << "r=" << r << std::endl; + BOOST_CHECK(r == 5); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 6); + + std::vector sigma8 = {1, 2, 3}; + std::vector sigma9 = {2, 7}; + + sigma8.emplace_back(r); + sigma9.emplace_back(r); + BOOST_CHECK(!tm.membership(sigma6)); + BOOST_CHECK(tm.membership(sigma8)); + BOOST_CHECK(tm.membership(sigma9)); + + std::cout << "remove_simplex({2, 7, r = 5})" << std::endl; + tm.remove_simplex(sigma9); + BOOST_CHECK(!tm.membership(sigma9)); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 8); + + // {2, 7, 5} is removed, but verify its edges are still there + std::vector edge = {2, 7}; + BOOST_CHECK(tm.membership(edge)); + edge = {2, 5}; + BOOST_CHECK(tm.membership(edge)); + edge = {7, 5}; + BOOST_CHECK(tm.membership(edge)); + +} + -- cgit v1.2.3