diff options
author | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-12 05:43:06 +0000 |
---|---|---|
committer | glisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-12 05:43:06 +0000 |
commit | ad6a64ad5a4f4121410250021eda0904eb9c718c (patch) | |
tree | fdad2e783a79b388cde1826e3b344d8977d1183a /src/common/test | |
parent | f9a32a464156dd61b444f0e70c8342642363e8ea (diff) | |
parent | f0e5330a88f9e89a887769ab79f6db6dd4e1c35a (diff) |
Merge from trunk.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/qt5@1848 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: c8e1376894207c8c08896f750f71c115e07f6d95
Diffstat (limited to 'src/common/test')
-rw-r--r-- | src/common/test/CMakeLists.txt | 24 | ||||
-rw-r--r-- | src/common/test/README | 14 | ||||
-rw-r--r-- | src/common/test/dtoffrw_alphashapedoc_result.off | 7 | ||||
-rw-r--r-- | src/common/test/test_points_off_reader.cpp | 73 |
4 files changed, 118 insertions, 0 deletions
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt new file mode 100644 index 00000000..7ccdb752 --- /dev/null +++ b/src/common/test/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.6) +project(Common_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() +if (GPROF_PATH) + # for gprof to make coverage reports - Jenkins + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +endif() + +add_executable ( poffreader_UT test_points_off_reader.cpp ) +target_link_libraries(poffreader_UT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + +# Do not forget to copy test files in current binary dir +file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + +# Unitary tests +add_test(poffreader_UT ${CMAKE_CURRENT_BINARY_DIR}/poffreader_UT + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/poffreader_UT.xml --log_level=test_suite --report_level=no) + + diff --git a/src/common/test/README b/src/common/test/README new file mode 100644 index 00000000..f2a7eb5a --- /dev/null +++ b/src/common/test/README @@ -0,0 +1,14 @@ +To compile: +*********** + +cmake . +make + +To launch with details: +*********************** + +./dtoffrw_UT --report_level=detailed --log_level=all + + ==> echo $? returns 0 in case of success (non-zero otherwise) + + diff --git a/src/common/test/dtoffrw_alphashapedoc_result.off b/src/common/test/dtoffrw_alphashapedoc_result.off new file mode 100644 index 00000000..1deb8dbd --- /dev/null +++ b/src/common/test/dtoffrw_alphashapedoc_result.off @@ -0,0 +1,7 @@ +Point[0] = 1 1 +Point[1] = 7 0 +Point[2] = 4 6 +Point[3] = 9 6 +Point[4] = 0 14 +Point[5] = 2 19 +Point[6] = 9 17 diff --git a/src/common/test/test_points_off_reader.cpp b/src/common/test/test_points_off_reader.cpp new file mode 100644 index 00000000..b4f71182 --- /dev/null +++ b/src/common/test/test_points_off_reader.cpp @@ -0,0 +1,73 @@ +/* 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): Vincent Rouvreau + * + * Copyright (C) 2015 INRIA Saclay (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/>. + */ + +#include <gudhi/Points_off_io.h> + +#include <iostream> +#include <string> +#include <vector> + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "points_off_read_write" +#include <boost/test/unit_test.hpp> + +using Point_d = std::vector<double>; + +BOOST_AUTO_TEST_CASE( points_doc_test ) +{ + // Read the OFF file (input file name given as parameter) and triangulates points + Gudhi::Points_off_reader<Point_d> off_reader("alphacomplexdoc.off"); + // Check the read operation was correct + BOOST_CHECK(off_reader.is_valid()); + + // Retrieve the triangulation + std::vector<Point_d> point_cloud = off_reader.get_point_cloud(); + BOOST_CHECK(point_cloud.size() == 7); + + std::vector<Point_d> expected_points; + std::vector<double> point = {1.0, 1.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {7.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {4.0, 6.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {9.0, 6.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {0.0, 14.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {2.0, 19.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {9.0, 17.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + + BOOST_CHECK(point_cloud == expected_points); +} + +BOOST_AUTO_TEST_CASE( Delaunay_triangulation_unexisting_file_read_test ) +{ + Gudhi::Points_off_reader<Point_d> off_reader("some_impossible_weird_file_name.off"); + // Check the read operation was correct + BOOST_CHECK(!off_reader.is_valid()); + + std::vector<Point_d> point_cloud = off_reader.get_point_cloud(); + BOOST_CHECK(point_cloud.size() == 0); +} |