diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-03-19 12:19:22 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-03-19 12:19:22 +0000 |
commit | 8c820ca8f9da625084f94dc9b80bb936f2c7aa8a (patch) | |
tree | ceeb3cefb54bf30a4819534bffb4a791ef1be2d3 /src/Bottleneck/test | |
parent | a52663bd7c94c402200605062b7e70dc4575d781 (diff) |
Add of bottleneck functionnality
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneckDistance@492 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 68ecf70a07641fea7106a17bbbf45404747834cc
Diffstat (limited to 'src/Bottleneck/test')
-rw-r--r-- | src/Bottleneck/test/CMakeLists.txt | 21 | ||||
-rw-r--r-- | src/Bottleneck/test/README | 12 | ||||
-rw-r--r-- | src/Bottleneck/test/bottleneck_unit_test.cpp | 26 |
3 files changed, 59 insertions, 0 deletions
diff --git a/src/Bottleneck/test/CMakeLists.txt b/src/Bottleneck/test/CMakeLists.txt new file mode 100644 index 00000000..7044372e --- /dev/null +++ b/src/Bottleneck/test/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.6) +project(GUDHIBottleneckUnitTest) + +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() + +add_executable ( BottleneckUnitTest bottleneck_unit_test.cpp ) +target_link_libraries(BottleneckUnitTest ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + +# Unitary tests +add_test(BottleneckUnitTest ${CMAKE_CURRENT_BINARY_DIR}/BottleneckUnitTest) + +if (LCOV_PATH) + # Lcov code coverage of unitary test + add_test(src/Bottleneck/lcov/coverage.log ${CMAKE_SOURCE_DIR}/scripts/check_code_coverage.sh ${CMAKE_SOURCE_DIR}/src/Bottleneck) +endif() + +cpplint_add_tests("${CMAKE_SOURCE_DIR}/src/Bottleneck/include/gudhi") diff --git a/src/Bottleneck/test/README b/src/Bottleneck/test/README new file mode 100644 index 00000000..0e7b8673 --- /dev/null +++ b/src/Bottleneck/test/README @@ -0,0 +1,12 @@ +To compile: +*********** + +cmake . +make + +To launch with details: +*********************** + +./BottleneckUnitTest --report_level=detailed --log_level=all + + ==> echo $? returns 0 in case of success (non-zero otherwise) diff --git a/src/Bottleneck/test/bottleneck_unit_test.cpp b/src/Bottleneck/test/bottleneck_unit_test.cpp new file mode 100644 index 00000000..068b8690 --- /dev/null +++ b/src/Bottleneck/test/bottleneck_unit_test.cpp @@ -0,0 +1,26 @@ +#define BOOST_TEST_MODULE bottleneck test + +#include <boost/test/included/unit_test.hpp> + +#include "gudhi/Graph_matching.h" +#include <iostream> + +using namespace Gudhi::bottleneck; + +BOOST_AUTO_TEST_CASE(random_diagrams) { + int n = 100; + // Random construction + std::vector< std::pair<double, double> > v1, v2; + for (int i = 0; i < n; i++) { + int a = rand() % n; + v1.emplace_back(a, a + rand() % (n - a)); + int b = rand() % n; + v2.emplace_back(b, b + rand() % (n - b)); + } + // v1 and v2 are persistence diagrams containing each 100 randoms points. + double b = bottleneck_distance(v1, v2, 0); + // + std::cout << b << std::endl; + const double EXPECTED_DISTANCE = 98.5; + BOOST_CHECK(b == EXPECTED_DISTANCE); +} |