summaryrefslogtreecommitdiff
path: root/src/Toplex_map/test
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-10-13 09:33:33 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-10-13 09:33:33 +0000
commitd8e1da2f6465e3d6baa0c6e921a3cc0b9ce3f2c7 (patch)
treefd981c4bc3ed4ee9c9d6987e5fc08b224bd08d6c /src/Toplex_map/test
parent9b586188bb7c32b6469c34f3e7eb697d28805ff3 (diff)
module toplex_map added
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@2784 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 61f8f8a2d3920dbc30b86dd808a0e316383af137
Diffstat (limited to 'src/Toplex_map/test')
-rw-r--r--src/Toplex_map/test/CMakeLists.txt14
-rw-r--r--src/Toplex_map/test/test.cpp71
2 files changed, 85 insertions, 0 deletions
diff --git a/src/Toplex_map/test/CMakeLists.txt b/src/Toplex_map/test/CMakeLists.txt
new file mode 100644
index 00000000..223ebccb
--- /dev/null
+++ b/src/Toplex_map/test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.6)
+project(Toplex_map_tests)
+
+add_executable ( ToplexMapUT test.cpp )
+target_link_libraries(ToplexMapUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
+
+# Unitary tests
+add_test(NAME SalUT
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/ToplexMapUT
+ ${CMAKE_SOURCE_DIR}/src/Toplex_map/test/test.txt
+ # XML format for Jenkins xUnit plugin
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/ToplexMapUT.xml --log_level=test_suite --report_level=no)
+
diff --git a/src/Toplex_map/test/test.cpp b/src/Toplex_map/test/test.cpp
new file mode 100644
index 00000000..3f4d96c2
--- /dev/null
+++ b/src/Toplex_map/test/test.cpp
@@ -0,0 +1,71 @@
+#include <iostream>
+#include <gudhi/Lazy_toplex_map.h>
+#include <gudhi/Filtered_toplex_map.h>
+#include <gudhi/Fake_simplex_tree.h>
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "toplex map"
+#include <boost/test/unit_test.hpp>
+
+using namespace Gudhi;
+
+std::vector<Vertex> sigma1 = {1, 2, 3, 4};
+std::vector<Vertex> sigma2 = {5, 2, 3, 6};
+std::vector<Vertex> sigma3 = {5};
+std::vector<Vertex> sigma4 = {5, 2, 3};
+std::vector<Vertex> sigma5 = {5, 2, 7};
+std::vector<Vertex> sigma6 = {4, 5, 3};
+std::vector<Vertex> sigma7 = {4, 5, 9};
+std::vector<Vertex> sigma8 = {1, 2, 3, 6};
+
+
+BOOST_AUTO_TEST_CASE(toplexmap) {
+ Toplex_map K;
+ K.insert_simplex(sigma1);
+ K.insert_simplex(sigma2);
+ K.insert_simplex(sigma3);
+ K.insert_simplex(sigma6);
+ K.insert_simplex(sigma7);
+ BOOST_CHECK(K.membership(sigma4));
+ BOOST_CHECK(!K.maximality(sigma5));
+ BOOST_CHECK(!K.membership(sigma5));
+ K.contraction(4,5);
+ BOOST_CHECK(!K.membership(sigma6));
+}
+
+BOOST_AUTO_TEST_CASE(ltoplexmap) {
+ Lazy_Toplex_map K;
+ K.insert_simplex(sigma1);
+ K.insert_simplex(sigma2);
+ K.insert_simplex(sigma3);
+ K.insert_simplex(sigma6);
+ K.insert_simplex(sigma7);
+ BOOST_CHECK(K.membership(sigma4));
+ BOOST_CHECK(!K.membership(sigma5));
+ K.contraction(4,5);
+ BOOST_CHECK(!K.membership(sigma6));
+}
+
+BOOST_AUTO_TEST_CASE(ftoplexmap) {
+ Filtered_toplex_map K;
+ K.insert_simplex_and_subfaces(sigma1, 2.);
+ K.insert_simplex_and_subfaces(sigma2, 2.);
+ K.insert_simplex_and_subfaces(sigma6, 1.);
+ K.insert_simplex_and_subfaces(sigma7, 1.);
+ BOOST_CHECK(K.filtration(sigma4)==2.);
+ BOOST_CHECK(K.filtration(sigma3)==1.);
+}
+
+/*
+BOOST_AUTO_TEST_CASE(toplexmap_candidates) {
+ Toplex_map K;
+ K.insert_simplex(sigma1);
+ K.insert_simplex(sigma2);
+ K.remove_simplex(sigma1);
+ K.remove_simplex(sigma2);
+ auto c = K.candidates();
+ BOOST_CHECK(c.count(get_key(sigma1)));
+ BOOST_CHECK(c.count(get_key(sigma2)));
+ BOOST_CHECK(c.size()==2);
+}
+*/