summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-12-19 09:52:37 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-12-19 09:52:37 +0000
commitaa5760623c2d769c01567f5c7f07d52fabc3e2d9 (patch)
tree16d2ec9e910917699c74e7605f648622a6798e2a /src/Alpha_complex/test/Alpha_complex_unit_test.cpp
parent80aa35b3ad53c95607221167b72d9aa00e1f71b5 (diff)
Add a function for unitary tests to test floating point values equality w/wo epsilon values
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3083 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 835037fd6efea4fbfc9a494df3015186232388bf
Diffstat (limited to 'src/Alpha_complex/test/Alpha_complex_unit_test.cpp')
-rw-r--r--src/Alpha_complex/test/Alpha_complex_unit_test.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
index 166373fe..c3ad1a9c 100644
--- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
+++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp
@@ -23,6 +23,7 @@
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex"
#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
#include <CGAL/Delaunay_triangulation.h>
#include <CGAL/Epick_d.h>
@@ -36,7 +37,7 @@
// to construct a simplex_tree from Delaunay_triangulation
#include <gudhi/graph_simplicial_complex.h>
#include <gudhi/Simplex_tree.h>
-#include <boost/mpl/list.hpp>
+#include <gudhi/Unitary_tests_utils.h>
// Use dynamic_dimension_tag for the user to be able to set dimension
typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel_d;
@@ -96,10 +97,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of
BOOST_CHECK(simplex_tree_59.num_simplices() == 23);
}
-bool are_almost_the_same(float a, float b) {
- return std::fabs(a - b) < std::numeric_limits<float>::epsilon();
-}
-
// Use static dimension_tag for the user not to be able to set dimension
typedef CGAL::Epick_d< CGAL::Dimension_tag<4> > Kernel_4;
typedef Kernel_4::Point_d Point_4;
@@ -166,16 +163,16 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) {
for (auto f_simplex : simplex_tree.filtration_simplex_range()) {
switch (simplex_tree.dimension(f_simplex)) {
case 0:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 0.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 0.0);
break;
case 1:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 1.0/2.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 1.0/2.0);
break;
case 2:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 2.0/3.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 2.0/3.0);
break;
case 3:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 3.0/4.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 3.0/4.0);
break;
default:
BOOST_CHECK(false); // Shall not happen
@@ -239,10 +236,10 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) {
for (auto f_simplex : simplex_tree.filtration_simplex_range()) {
switch (simplex_tree.dimension(f_simplex)) {
case 0:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 0.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 0.0);
break;
case 1:
- BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 1.0/2.0));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 1.0/2.0);
break;
default:
BOOST_CHECK(false); // Shall not happen