summaryrefslogtreecommitdiff
path: root/src/Witness_complex/test
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-14 07:17:44 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-14 07:17:44 +0000
commit4e784aca4df90d3fca9146bfd9e3feda98ce5f4c (patch)
tree89182d71a1cfe45b70410af70500e3e90f7aca52 /src/Witness_complex/test
parentc829c36217c003b2068750aa8f23b6082636e6e1 (diff)
parentbaf1b5b39be90694b512fff9c79438bf362916f3 (diff)
Merge last trunk modifications (version 1.3.0)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1113 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 608c3cb733a7723c865f82a4de9408c984227f1a
Diffstat (limited to 'src/Witness_complex/test')
-rw-r--r--src/Witness_complex/test/CMakeLists.txt30
-rw-r--r--src/Witness_complex/test/simple_witness_complex.cpp59
-rw-r--r--src/Witness_complex/test/witness_complex_points.cpp64
3 files changed, 153 insertions, 0 deletions
diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt
new file mode 100644
index 00000000..37bef2d0
--- /dev/null
+++ b/src/Witness_complex/test/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 2.6)
+project(GUDHIWitnessComplexUT)
+
+if (GCOVR_PATH)
+ # for gcovr to make coverage reports - Corbera Jenkins plugin
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
+endif()
+if (GPROF_PATH)
+ # for gprof to make coverage reports - Jenkins
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
+endif()
+
+add_executable ( simple_witness_complexUT simple_witness_complex.cpp )
+target_link_libraries(simple_witness_complexUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
+# Unitary tests definition and xml result file generation
+add_test(NAME simple_witness_complexUT
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/simple_witness_complexUT
+ # XML format for Jenkins xUnit plugin
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/simple_witness_complexUT.xml --log_level=test_suite --report_level=no)
+
+add_executable ( witness_complex_pointsUT witness_complex_points.cpp )
+target_link_libraries(witness_complex_pointsUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
+# Unitary tests definition and xml result file generation
+add_test(NAME witness_complex_pointsUT
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/witness_complex_pointsUT
+ # XML format for Jenkins xUnit plugin
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/witness_complex_pointsUT.xml --log_level=test_suite --report_level=no)
+
diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp
new file mode 100644
index 00000000..03df78ee
--- /dev/null
+++ b/src/Witness_complex/test/simple_witness_complex.cpp
@@ -0,0 +1,59 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "simple_witness_complex"
+#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/Witness_complex.h>
+
+#include <iostream>
+#include <ctime>
+#include <vector>
+
+typedef Gudhi::Simplex_tree<> Simplex_tree;
+typedef std::vector< Vertex_handle > typeVectorVertex;
+typedef Gudhi::witness_complex::Witness_complex<Simplex_tree> WitnessComplex;
+
+BOOST_AUTO_TEST_CASE(simple_witness_complex) {
+ Simplex_tree complex;
+ std::vector< typeVectorVertex > knn;
+
+ knn.push_back({1, 0, 5, 2, 6, 3, 4});
+ knn.push_back({2, 6, 4, 5, 0, 1, 3});
+ knn.push_back({3, 4, 2, 1, 5, 6, 0});
+ knn.push_back({4, 2, 1, 3, 5, 6, 0});
+ knn.push_back({5, 1, 6, 0, 2, 3, 4});
+ knn.push_back({6, 0, 5, 2, 1, 3, 4});
+ knn.push_back({0, 5, 6, 1, 2, 3, 4});
+ knn.push_back({2, 6, 4, 5, 3, 1, 0});
+ knn.push_back({1, 2, 5, 4, 3, 6, 0});
+ knn.push_back({3, 4, 0, 6, 5, 1, 2});
+ knn.push_back({5, 0, 1, 3, 6, 2, 4});
+ knn.push_back({5, 6, 1, 0, 2, 3, 4});
+ knn.push_back({1, 6, 0, 5, 2, 3, 4});
+ WitnessComplex witnessComplex(knn, 7, 7, complex);
+
+ BOOST_CHECK(witnessComplex.is_witness_complex(knn, false));
+}
diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp
new file mode 100644
index 00000000..bd3df604
--- /dev/null
+++ b/src/Witness_complex/test/witness_complex_points.cpp
@@ -0,0 +1,64 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "witness_complex_points"
+#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/Witness_complex.h>
+#include <gudhi/Landmark_choice_by_random_point.h>
+#include <gudhi/Landmark_choice_by_furthest_point.h>
+
+#include <iostream>
+#include <vector>
+
+typedef std::vector<double> Point;
+typedef std::vector< Vertex_handle > typeVectorVertex;
+typedef Gudhi::Simplex_tree<> Simplex_tree;
+typedef Gudhi::witness_complex::Witness_complex<Simplex_tree> WitnessComplex;
+
+BOOST_AUTO_TEST_CASE(witness_complex_points) {
+ std::vector< typeVectorVertex > knn;
+ std::vector< Point > points;
+ // Add grid points as witnesses
+ for (double i = 0; i < 10; i += 1.0)
+ for (double j = 0; j < 10; j += 1.0)
+ for (double k = 0; k < 10; k += 1.0)
+ points.push_back(Point({i, j, k}));
+
+ bool b_print_output = false;
+ // First test: random choice
+ Simplex_tree complex1;
+ Gudhi::witness_complex::landmark_choice_by_random_point(points, 100, knn);
+ assert(!knn.empty());
+ WitnessComplex witnessComplex1(knn, 100, 3, complex1);
+ BOOST_CHECK(witnessComplex1.is_witness_complex(knn, b_print_output));
+
+ // Second test: furthest choice
+ knn.clear();
+ Simplex_tree complex2;
+ Gudhi::witness_complex::landmark_choice_by_furthest_point(points, 100, knn);
+ WitnessComplex witnessComplex2(knn, 100, 3, complex2);
+ BOOST_CHECK(witnessComplex2.is_witness_complex(knn, b_print_output));
+}