diff options
author | Gard Spreemann <gspr@nonempty.org> | 2019-09-25 14:53:36 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2019-09-25 14:53:36 +0200 |
commit | 70ad5fc411b0e0a3d590ad281fc97d488994062b (patch) | |
tree | b0ddd84d7ee935936787eee2b75f78f2e21c41f0 /src/common/test/test_points_off_reader.cpp | |
parent | b50046e487ab42cdef19b02128a9f498d6a36482 (diff) | |
parent | 5ccee32ec2ba38743c6b96867db3e1b5151e45e4 (diff) |
Merge branch 'dfsg/latest' into debian/sid
Diffstat (limited to 'src/common/test/test_points_off_reader.cpp')
-rw-r--r-- | src/common/test/test_points_off_reader.cpp | 61 |
1 files changed, 61 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..f190a13e --- /dev/null +++ b/src/common/test/test_points_off_reader.cpp @@ -0,0 +1,61 @@ +/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2015 Inria + * + * Modification(s): + * - YYYY/MM Author: Description of the modification + */ + +#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, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {7.0, 0.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {4.0, 6.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {9.0, 6.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {0.0, 14.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {2.0, 19.0, 0.0}; + expected_points.push_back(Point_d(point.begin(), point.end())); + point = {9.0, 17.0, 0.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); +} |