diff --git a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp index 841aeb1fcd3..19d96c02f2b 100644 --- a/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp +++ b/Kernel_23/test/Kernel_23/Filtered_cartesian.cpp @@ -27,6 +27,7 @@ #include #include +#include #include @@ -52,9 +53,12 @@ #include "CGAL/_test_mf_plane_3_to_2d.h" +template +void test(); int main() { + CGAL::force_ieee_double_precision(); typedef CGAL::Cartesian Clsdb; typedef CGAL::Filtered_kernel Clsd; @@ -71,6 +75,13 @@ main() std::cout << "Testing IO with F_k>:" << std::endl; _test_io( Clsd() ); + std::cout << "Testing with Epick:\n"; + test(); + return 0; +} + +template +void test() { std::cout << "Testing 2d :"; std::cout << std::endl; _test_2( Cls() ); @@ -101,6 +112,4 @@ main() std::cout << "Testing 3d-2d :"; std::cout << std::endl; _test_mf_plane_3_to_2d( Cls() ); - - return 0; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h new file mode 100644 index 00000000000..361d0800554 --- /dev/null +++ b/Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h @@ -0,0 +1,44 @@ +#ifndef CGAL_TESTSUITE_APPROX_EQUAL_H +#define CGAL_TESTSUITE_APPROX_EQUAL_H +#include + +namespace CGAL { +namespace testsuite { + +template +bool approx_equal(FT a, FT b) { return a == b; } + +bool approx_equal(double a, double b) { + return std::abs(boost::math::float_distance(a, b)) <= 1; +} + +struct Xyz_tag {}; +struct Xy_tag {}; + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xyz_tag) +{ + return approx_equal(a.x(), b.x()) && + approx_equal(a.y(), b.y()) && + approx_equal(a.z(), b.z()); +} + +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Xy_tag) +{ + return approx_equal(a.x(), b.x()) && approx_equal(a.y(), b.y()); +} + +struct Direction_2_tag {}; +template +bool approx_equal(Object a, Object b, CGAL::testsuite::Direction_2_tag) +{ + return CGAL_NTS sign(a.dx()) == CGAL_NTS sign(a.dx()) + && CGAL_NTS sign(a.dy()) == CGAL_NTS sign(b.dy()) + && approx_equal(a.dx() * b.dy(), a.dy() * b.dx()); +} + +} // end namespace testsuite +} // end namespace CGAL + +#endif // CGAL_TESTSUITE_APPROX_EQUAL_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h index dbe58ed1121..a0ffb40e8be 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_weighted_point_2.h @@ -31,6 +31,8 @@ #include #include +#include "_approx_equal.h" + template bool _test_fct_weighted_point_2(const R& ) @@ -158,8 +160,9 @@ _test_fct_weighted_point_2(const R& ) std::cout << CGAL::weighted_circumcenter(wp_00, wp_10, wp_01) << std::endl; - assert( CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5) - == CGAL::squared_radius(p1, p3, p5)); + using CGAL::testsuite::approx_equal; + assert( approx_equal(CGAL::squared_radius_smallest_orthogonal_circle(wp1, wp3, wp5), + CGAL::squared_radius(p1, p3, p5)) ); assert( CGAL::squared_radius_smallest_orthogonal_circle(wp_00, wp_10, wp_01) == RT(0)); std::cout << "done" << std::endl; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h index f17c9028deb..cf498947577 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_further_fct_point_2.h @@ -24,6 +24,8 @@ #ifndef CGAL__TEST_FURTHER_FCT_POINT_2_H #define CGAL__TEST_FURTHER_FCT_POINT_2_H +#include "_approx_equal.h" + template bool _test_further_fct_point_2(const R& ) @@ -95,8 +97,10 @@ _test_further_fct_point_2(const R& ) p4 = p0.transform(rotate4); p5 = p0.transform(rotate5); + using CGAL::testsuite::approx_equal; + using CGAL::testsuite::Direction_2_tag; - assert( (p5 - CGAL::ORIGIN).direction() == dir5 ); + assert( approx_equal((p5 - CGAL::ORIGIN).direction(), dir5, Direction_2_tag()) ); assert( CGAL::side_of_bounded_circle(p1, p2, p3, CGAL::Point_2(CGAL::ORIGIN))\ == CGAL::ON_BOUNDED_SIDE );