diff options
Diffstat (limited to 'src/Persistent_cohomology/test')
4 files changed, 33 insertions, 43 deletions
diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt index a21f39c4..11e9a951 100644 --- a/src/Persistent_cohomology/test/CMakeLists.txt +++ b/src/Persistent_cohomology/test/CMakeLists.txt @@ -1,49 +1,37 @@ cmake_minimum_required(VERSION 2.6) project(Persistent_cohomology_tests) -if (GCOVR_PATH) - # for gcovr to make coverage reports - Corbera Jenkins plugin - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") -endif(GCOVR_PATH) -if (GPROF_PATH) - # for gprof to make coverage reports - Jenkins - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") -endif(GPROF_PATH) - -add_executable ( PersistentCohomologyUT persistent_cohomology_unit_test.cpp ) -target_link_libraries(PersistentCohomologyUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -add_executable ( BettiNumbersUT betti_numbers_unit_test.cpp ) -target_link_libraries(BettiNumbersUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +include(GUDHI_test_coverage) + +add_executable ( Persistent_cohomology_test_unit persistent_cohomology_unit_test.cpp ) +target_link_libraries(Persistent_cohomology_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +add_executable ( Persistent_cohomology_test_betti_numbers betti_numbers_unit_test.cpp ) +target_link_libraries(Persistent_cohomology_test_betti_numbers ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) - target_link_libraries(PersistentCohomologyUT ${TBB_LIBRARIES}) - target_link_libraries(BettiNumbersUT ${TBB_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_unit ${TBB_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_betti_numbers ${TBB_LIBRARIES}) endif(TBB_FOUND) -# Unitary tests -add_test(NAME PersistentCohomologyUT - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/PersistentCohomologyUT - ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_unit_test.txt - # XML format for Jenkins xUnit plugin - --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/PersistentCohomologyUT.xml --log_level=test_suite --report_level=no) +# Do not forget to copy test results files in current binary dir +file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_unit_test.txt" + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -add_test(NAME BettiNumbersUT - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/BettiNumbersUT - # XML format for Jenkins xUnit plugin - --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/BettiNumbersUT.xml --log_level=test_suite --report_level=no) +# Unitary tests +gudhi_add_coverage_test(Persistent_cohomology_test_unit) +gudhi_add_coverage_test(Persistent_cohomology_test_betti_numbers) if(GMPXX_FOUND AND GMP_FOUND) - add_executable ( PersistentCohomologyMultiFieldUT persistent_cohomology_unit_test_multi_field.cpp ) - target_link_libraries(PersistentCohomologyMultiFieldUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + add_executable ( Persistent_cohomology_test_unit_multi_field persistent_cohomology_unit_test_multi_field.cpp ) + target_link_libraries(Persistent_cohomology_test_unit_multi_field ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) - target_link_libraries(PersistentCohomologyMultiFieldUT ${TBB_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_unit_multi_field ${TBB_LIBRARIES}) endif(TBB_FOUND) + # Do not forget to copy test results files in current binary dir + file(COPY "${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt" + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) # Unitary tests - add_test(NAME PersistentCohomologyMultiFieldUT - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/PersistentCohomologyMultiFieldUT - ${CMAKE_SOURCE_DIR}/src/Persistent_cohomology/test/simplex_tree_file_for_multi_field_unit_test.txt - # XML format for Jenkins xUnit plugin - --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/PersistentCohomologyMultiFieldUT.xml --log_level=test_suite --report_level=no) + gudhi_add_coverage_test(Persistent_cohomology_test_unit_multi_field) endif(GMPXX_FOUND AND GMP_FOUND) diff --git a/src/Persistent_cohomology/test/README b/src/Persistent_cohomology/test/README index 6c64b5fe..0c41feed 100644 --- a/src/Persistent_cohomology/test/README +++ b/src/Persistent_cohomology/test/README @@ -11,13 +11,19 @@ To launch with details: SINGLE FIELD ------------ -./PersistentCohomologyUT simplex_tree_file_for_unit_test.txt --report_level=detailed --log_level=all +./Persistent_cohomology_test_unit --report_level=detailed --log_level=all ==> echo $? returns 0 in case of success (non-zero otherwise) MULTI FIELD ----------- -./PersistentCohomologyMultiFieldUT simplex_tree_file_for_multi_field_unit_test.txt --report_level=detailed --log_level=all +./Persistent_cohomology_test_unit_multi_field --report_level=detailed --log_level=all + + ==> echo $? returns 0 in case of success (non-zero otherwise) + +BETTI NUMBERS +------------- +./Persistent_cohomology_test_betti_numbers --report_level=detailed --log_level=all ==> echo $? returns 0 in case of success (non-zero otherwise) diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp index e2e0bc71..f8174020 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp @@ -22,11 +22,9 @@ using namespace boost::unit_test; typedef Simplex_tree<> typeST; std::string test_rips_persistence(int coefficient, int min_persistence) { - // file name is given as parameter from CMakeLists.txt - const std::string inputFile(framework::master_test_suite().argv[1]); - + // file is copied in CMakeLists.txt std::ifstream simplex_tree_stream; - simplex_tree_stream.open(inputFile.c_str()); + simplex_tree_stream.open("simplex_tree_file_for_unit_test.txt"); typeST st; simplex_tree_stream >> st; simplex_tree_stream.close(); diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp index 6a7ecbec..3537cfa4 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp @@ -22,11 +22,9 @@ using namespace boost::unit_test; typedef Simplex_tree<> typeST; std::string test_rips_persistence(int min_coefficient, int max_coefficient, double min_persistence) { - // file name is given as parameter from CMakeLists.txt - const std::string inputFile(framework::master_test_suite().argv[1]); - + // file is copied in CMakeLists.txt std::ifstream simplex_tree_stream; - simplex_tree_stream.open(inputFile.c_str()); + simplex_tree_stream.open("simplex_tree_file_for_multi_field_unit_test.txt"); typeST st; simplex_tree_stream >> st; simplex_tree_stream.close(); |