From 7d1e88a2995e23d882cc3bfe69ec09357d6c2618 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Tue, 17 May 2022 10:33:51 +0200 Subject: code review: test also the list of all oppposite vertices is the simplex given as an input --- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 2b2be89d..b18e2ec4 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -1015,14 +1015,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_boundaries_and_opposite_vertex_iterat // simplices must be kept sorted by vertex number for std::vector to use operator== - cf. last BOOST_CHECK std::vector simplices = {{0, 1, 2}, {0, 3}, {0, 1, 6, 7}, {3, 4, 5}, {3, 5}, {2}}; for (auto simplex : simplices) { - std::size_t range_size = std::distance(st.boundary_opposite_vertex_simplex_range(st.find(simplex)).begin(), - st.boundary_opposite_vertex_simplex_range(st.find(simplex)).end()); - std::cout << "Range size = " << range_size << " - " << simplex.size() << std::endl; - if (simplex.size() > 1) { - BOOST_CHECK(range_size == simplex.size()); - } else { - BOOST_CHECK(range_size == 0); - } + Simplex opposite_vertices; for(auto boundary_and_opposite_vertex : st.boundary_opposite_vertex_simplex_range(st.find(simplex))) { Simplex output; for (auto vertex : st.simplex_vertex_range(boundary_and_opposite_vertex.first)) { @@ -1030,9 +1023,18 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_boundaries_and_opposite_vertex_iterat output.emplace_back(vertex); } std::clog << " - opposite vertex = " << boundary_and_opposite_vertex.second << std::endl; + // Check that boundary simplex + opposite vertex = simplex given as input output.emplace_back(boundary_and_opposite_vertex.second); std::sort(output.begin(), output.end()); BOOST_CHECK(simplex == output); + opposite_vertices.emplace_back(boundary_and_opposite_vertex.second); } + // Check that the list of all opposite vertices = simplex given as input + // no opposite vertices if simplex given as input is of dimension 1 + std::sort(opposite_vertices.begin(), opposite_vertices.end()); + if (simplex.size() > 1) + BOOST_CHECK(simplex == opposite_vertices); + else + BOOST_CHECK(opposite_vertices.size() == 0); } } -- cgit v1.2.3