From 2530c5352fec28cc6c27af6b8f645a8b85d86676 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Nov 2018 11:07:35 +0000 Subject: Add some tests for empty toplex management git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3989 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 37ae2287e7905210bc2e699eacbc656ba873e40d --- src/Toplex_map/test/lazy_toplex_map_unit_test.cpp | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'src/Toplex_map') diff --git a/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp b/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp index eb1aa0b5..a050cc92 100644 --- a/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp +++ b/src/Toplex_map/test/lazy_toplex_map_unit_test.cpp @@ -95,3 +95,76 @@ BOOST_AUTO_TEST_CASE(toplex_map) { edge = {7, 5}; BOOST_CHECK(tm.membership(edge)); } + +BOOST_AUTO_TEST_CASE(toplex_map_empty_toplex) { + using Vertex = Gudhi::Lazy_toplex_map::Vertex; + + Gudhi::Lazy_toplex_map tm; + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 0); + std::cout << "num_vertices = " << tm.num_vertices() << std::endl; + BOOST_CHECK(tm.num_vertices() == 0); + + std::cout << "Check an empty simplex is a member." << std::endl; + std::vector empty_sigma = {}; + BOOST_CHECK(tm.membership(empty_sigma)); + + std::cout << "Check the edge 2,7 is not a member." << std::endl; + std::vector edge = {2, 7}; + BOOST_CHECK(!tm.membership(edge)); + + std::cout << "Insert an empty simplex." << std::endl; + tm.insert_simplex(empty_sigma); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 0); + std::cout << "num_vertices = " << tm.num_vertices() << std::endl; + BOOST_CHECK(tm.num_vertices() == 0); + + std::cout << "Check an empty simplex is a member." << std::endl; + BOOST_CHECK(tm.membership(empty_sigma)); + std::cout << "Check the edge 2,7 is not a member." << std::endl; + BOOST_CHECK(!tm.membership(edge)); + + std::cout << "Insert edge 2,7." << std::endl; + tm.insert_simplex(edge); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 1); + std::cout << "num_vertices = " << tm.num_vertices() << std::endl; + BOOST_CHECK(tm.num_vertices() == 2); + + std::cout << "Check an empty simplex is a member." << std::endl; + BOOST_CHECK(tm.membership(empty_sigma)); + std::cout << "Check the edge 2,7 is a member." << std::endl; + BOOST_CHECK(tm.membership(edge)); + + std::cout << "contraction(2,7)" << std::endl; + auto r = tm.contraction(2, 7); + std::cout << "r=" << r << std::endl; + BOOST_CHECK(r == 7); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 1); + std::cout << "num_vertices = " << tm.num_vertices() << std::endl; + BOOST_CHECK(tm.num_vertices() == 1); + + std::cout << "Check an empty simplex is a member." << std::endl; + BOOST_CHECK(tm.membership(empty_sigma)); + std::cout << "Check the edge 2,7 is not a member." << std::endl; + BOOST_CHECK(!tm.membership(edge)); + + std::cout << "Remove the vertex 7." << std::endl; + std::vector vertex = {7}; + tm.remove_simplex(vertex); + + std::cout << "num_maximal_simplices = " << tm.num_maximal_simplices() << std::endl; + BOOST_CHECK(tm.num_maximal_simplices() == 0); + std::cout << "num_vertices = " << tm.num_vertices() << std::endl; + BOOST_CHECK(tm.num_vertices() == 0); + + std::cout << "Check an empty simplex is a member." << std::endl; + BOOST_CHECK(tm.membership(empty_sigma)); + std::cout << "Check the edge 2,7 is not a member." << std::endl; + BOOST_CHECK(!tm.membership(edge)); +} -- cgit v1.2.3