diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-02-02 14:26:29 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-02-02 14:26:29 +0000 |
commit | db2c9248e50cd4eb91ec39802a2b2bce9565030d (patch) | |
tree | 6dbaf64a5f146ec91afc9f7729350855761376b7 /src/Witness_complex/test | |
parent | d13a8867ca368b1f56be3ba151d2042728fb4754 (diff) | |
parent | 945a98537205d4f3e3f7c3c652f373af89723731 (diff) |
merged Vincent's changes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@993 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 359347a7fa9e1f30c7e8af323fb753e946c78948
Diffstat (limited to 'src/Witness_complex/test')
-rw-r--r-- | src/Witness_complex/test/CMakeLists.txt | 40 | ||||
-rw-r--r-- | src/Witness_complex/test/simple_witness_complex.cpp | 50 | ||||
-rw-r--r-- | src/Witness_complex/test/witness_complex_points.cpp | 34 |
3 files changed, 75 insertions, 49 deletions
diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index a13fd94a..9422c152 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -1,16 +1,34 @@ cmake_minimum_required(VERSION 2.6) -project(GUDHITestWitnessComplex) +project(GUDHIWitnessComplexUT) -#if(NOT MSVC) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") -# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") -# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --coverage") -#endif() +if (GCOVR_PATH) + # for gcovr to make coverage reports - Corbera Jenkins plugin + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage") +endif() +if (GPROF_PATH) + # for gprof to make coverage reports - Jenkins + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg") +endif() -add_executable ( simple_witness_complex simple_witness_complex.cpp ) -add_test(test ${CMAKE_CURRENT_BINARY_DIR}/simple_witness_complex) +add_executable ( simple_witness_complexUT simple_witness_complex.cpp ) +target_link_libraries(simple_witness_complexUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -add_executable ( witness_complex_points witness_complex_points.cpp ) -add_test(test ${CMAKE_CURRENT_BINARY_DIR}/witness_complex_points) +# 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) -#cpplint_add_tests("${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi") diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index 7735ca6f..7d44b90c 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -20,34 +20,40 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <iostream> -#include <ctime> +#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> -using namespace Gudhi; -using namespace Gudhi::witness_complex; +#include <iostream> +#include <ctime> +#include <vector> +typedef Gudhi::Simplex_tree<> Simplex_tree; typedef std::vector< Vertex_handle > typeVectorVertex; -typedef Witness_complex<Simplex_tree<>> WitnessComplex; +typedef Gudhi::witness_complex::Witness_complex<Simplex_tree> WitnessComplex; -int main (int argc, char * const argv[]) -{ - Simplex_tree<> complex; +BOOST_AUTO_TEST_CASE(simple_witness_complex) { + Simplex_tree complex; std::vector< typeVectorVertex > knn; - typeVectorVertex witness0 = {1,0,5,2,6,3,4}; knn.push_back(witness0 ); - typeVectorVertex witness1 = {2,6,4,5,0,1,3}; knn.push_back(witness1 ); - typeVectorVertex witness2 = {3,4,2,1,5,6,0}; knn.push_back(witness2 ); - typeVectorVertex witness3 = {4,2,1,3,5,6,0}; knn.push_back(witness3 ); - typeVectorVertex witness4 = {5,1,6,0,2,3,4}; knn.push_back(witness4 ); - typeVectorVertex witness5 = {6,0,5,2,1,3,4}; knn.push_back(witness5 ); - typeVectorVertex witness6 = {0,5,6,1,2,3,4}; knn.push_back(witness6 ); - typeVectorVertex witness7 = {2,6,4,5,3,1,0}; knn.push_back(witness7 ); - typeVectorVertex witness8 = {1,2,5,4,3,6,0}; knn.push_back(witness8 ); - typeVectorVertex witness9 = {3,4,0,6,5,1,2}; knn.push_back(witness9 ); - typeVectorVertex witness10 = {5,0,1,3,6,2,4}; knn.push_back(witness10); - typeVectorVertex witness11 = {5,6,1,0,2,3,4}; knn.push_back(witness11); - typeVectorVertex witness12 = {1,6,0,5,2,3,4}; knn.push_back(witness12); + + 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, complex, 7, 7); - assert(witnessComplex.is_witness_complex(knn, false)); + + 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 index 3850bd82..300b2ac5 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -20,45 +20,47 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <iostream> -#include <ctime> +#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> -using namespace Gudhi; -using namespace Gudhi::witness_complex; - -typedef std::vector< Vertex_handle > typeVectorVertex; -typedef Witness_complex<Simplex_tree<>> WitnessComplex; typedef std::vector<double> Point; -//typedef std::pair<typeVectorVertex, Filtration_value> typeSimplex; -//typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; +typedef std::vector< Vertex_handle > typeVectorVertex; +typedef Gudhi::Simplex_tree<> Simplex_tree; +typedef Gudhi::witness_complex::Witness_complex<Simplex_tree> WitnessComplex; +typedef Gudhi::witness_complex::Landmark_choice_by_random_point Landmark_choice_by_random_point; +typedef Gudhi::witness_complex::Landmark_choice_by_furthest_point Landmark_choice_by_furthest_point; -int main (int argc, char * const argv[]) -{ +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})); + points.push_back(Point({i, j, k})); bool b_print_output = false; // First test: random choice - Simplex_tree<> complex1; + Simplex_tree complex1; Landmark_choice_by_random_point lcrp(points, 100, knn); assert(!knn.empty()); WitnessComplex witnessComplex1(knn, complex1, 100, 3); - assert(witnessComplex1.is_witness_complex(knn, b_print_output)); + BOOST_CHECK(witnessComplex1.is_witness_complex(knn, b_print_output)); // Second test: furthest choice knn.clear(); - Simplex_tree<> complex2; + Simplex_tree complex2; Landmark_choice_by_furthest_point lcfp(points, 100, knn); WitnessComplex witnessComplex2(knn, complex2, 100, 3); - assert(witnessComplex2.is_witness_complex(knn, b_print_output)); + BOOST_CHECK(witnessComplex2.is_witness_complex(knn, b_print_output)); } |