diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-27 07:44:40 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-27 07:44:40 +0000 |
commit | 2f0d4a7a06f8fde904b75b27c3836e362f549707 (patch) | |
tree | e1522803404837c461756715629cf9647eef9317 /src/common/test/test_points_off_reader.cpp | |
parent | 9ffc108705ace9910cabc79225d984fe1d15b794 (diff) | |
parent | a138c9ed4fb9770a3612ff4ee0f914942bbe9724 (diff) |
Merge last trunk modifications
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1568 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 14c192615a0b9b79121a8395e721978b72272536
Diffstat (limited to 'src/common/test/test_points_off_reader.cpp')
-rw-r--r-- | src/common/test/test_points_off_reader.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
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); +} |