From c76d58d9d709b9db14727efc9d8d5e03eb0bd215 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 20 Jan 2015 10:17:56 +0100 Subject: [PATCH] use CGAL_assertion's --- .../orient_polyhedron_3_test.cpp | 6 ++-- .../point_inside_polyhedron_boundary_test.cpp | 2 +- .../test_polyhedron_stitching.cpp | 7 +++-- ...ate_hole_Polyhedron_3_no_delaunay_test.cpp | 28 +++++++++---------- .../triangulate_hole_Polyhedron_3_test.cpp | 28 +++++++++---------- .../triangulate_hole_polyline_test.cpp | 22 +++++++-------- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polyhedron_3_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polyhedron_3_test.cpp index 69e6450d124..285c76b6f38 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polyhedron_3_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polyhedron_3_test.cpp @@ -18,12 +18,12 @@ void test(const char* file_name) { Polyhedron oriented_poly; // file should contain oriented poly if ( !input || !(input >> oriented_poly) || oriented_poly.empty() ){ std::cerr << "Error: can not read file: " << file_name; - assert(false); + CGAL_assertion(false); } - assert(CGAL::Polygon_mesh_processing::is_oriented(oriented_poly)); + CGAL_assertion(CGAL::Polygon_mesh_processing::is_oriented(oriented_poly)); oriented_poly.inside_out(); - assert(!CGAL::Polygon_mesh_processing::is_oriented(oriented_poly)); + CGAL_assertion(!CGAL::Polygon_mesh_processing::is_oriented(oriented_poly)); std::cerr << file_name << " passed the test." << std::endl; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp index 4481fbef034..486c7d507ed 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp @@ -106,7 +106,7 @@ void test( CGAL::Bounded_side res = inside(points[i]); if(!on_boundary.empty()) { - assert(on_boundary[i] == (res == CGAL::ON_BOUNDARY)); + CGAL_assertion(on_boundary[i] == (res == CGAL::ON_BOUNDARY)); } if(res == CGAL::ON_BOUNDED_SIDE) { ++nb_inside; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_polyhedron_stitching.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_polyhedron_stitching.cpp index 0059b5de2a9..62e91c9d5f1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_polyhedron_stitching.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_polyhedron_stitching.cpp @@ -14,11 +14,12 @@ void test(const char* fname) { std::cout << "Testing " << fname << "..." << std::flush; std::ifstream input(fname); - assert(input); + if (!input) + CGAL_assertion(false); Polyhedron P; input >> P; - assert(P.size_of_vertices()!=0); + CGAL_assertion(P.size_of_vertices()!=0); CGAL::Polygon_mesh_processing::stitch_borders(P); @@ -27,7 +28,7 @@ void test(const char* fname) output.close(); P.normalize_border(); - assert(P.is_valid(false, 5)); + CGAL_assertion(P.is_valid(false, 5)); std::cout << "OK\n"; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp index 0710707a4b5..34b461a51c9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp @@ -43,7 +43,7 @@ void read_poly_with_borders(const char* file_name, Polyhedron& poly, std::vector std::ifstream input(file_name); if ( !input || !(input >> poly) || (num_vertices(poly) == 0)){ std::cerr << " Error: can not read file." << std::endl; - assert(false); + CGAL_assertion(false); } std::set border_map; @@ -113,10 +113,10 @@ void test_triangulate_hole_weight(const char* file_name, bool use_DT) { const double epsilon = 1e-10; if(std::abs(w_algo.w.first - w_test.w.first) > epsilon) { - assert(false); + CGAL_assertion(false); } if(std::abs(w_algo.w.second - w_test.w.second) > epsilon) { - assert(false); + CGAL_assertion(false); } } @@ -136,13 +136,13 @@ void test_triangulate_hole(const char* file_name) { CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); if(patch.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -160,13 +160,13 @@ void test_triangulate_hole_should_be_no_output(const char* file_name) { CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), false); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; - assert(false); + CGAL_assertion(false); } CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), true); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; - assert(false); + CGAL_assertion(false); } } @@ -188,13 +188,13 @@ void test_triangulate_and_refine_hole(const char* file_name) { if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -215,13 +215,13 @@ void test_triangulate_refine_and_fair_hole(const char* file_name) { if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -249,7 +249,7 @@ void test_ouput_iterators_triangulate_hole(const char* file_name) { if(patch.size() != (output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; std::cerr << " " << patch.size() << " vs " << (output_it - &*patch_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } } std::cerr << " Done!" << std::endl; @@ -283,13 +283,13 @@ void test_ouput_iterators_triangulate_and_refine_hole(const char* file_name) { if(patch_facets.size() != (output_its.first - &*patch_facets_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; std::cerr << " " << patch_facets.size() << " vs " << (output_its.first - &*patch_facets_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } if(patch_vertices.size() != (output_its.second - &*patch_vertices_2.begin())) { std::cerr << " Error: returned vertex output iterator is not valid!" << std::endl; std::cerr << " " << patch_vertices.size() << " vs " << (output_its.second - &*patch_vertices_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } } std::cerr << " Done!" << std::endl; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp index bb57717b771..30fd26488b9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp @@ -42,7 +42,7 @@ void read_poly_with_borders(const char* file_name, Polyhedron& poly, std::vector std::ifstream input(file_name); if ( !input || !(input >> poly) || (num_vertices(poly) == 0)){ std::cerr << " Error: can not read file." << std::endl; - assert(false); + CGAL_assertion(false); } std::set border_map; @@ -112,10 +112,10 @@ void test_triangulate_hole_weight(const char* file_name, bool use_DT) { const double epsilon = 1e-10; if(std::abs(w_algo.w.first - w_test.w.first) > epsilon) { - assert(false); + CGAL_assertion(false); } if(std::abs(w_algo.w.second - w_test.w.second) > epsilon) { - assert(false); + CGAL_assertion(false); } } @@ -135,13 +135,13 @@ void test_triangulate_hole(const char* file_name) { CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); if(patch.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -159,13 +159,13 @@ void test_triangulate_hole_should_be_no_output(const char* file_name) { CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), false); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; - assert(false); + CGAL_assertion(false); } CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), true); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; - assert(false); + CGAL_assertion(false); } } @@ -187,13 +187,13 @@ void test_triangulate_and_refine_hole(const char* file_name) { if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -214,13 +214,13 @@ void test_triangulate_refine_and_fair_hole(const char* file_name) { if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; - assert(false); + CGAL_assertion(false); } } if(!poly.is_valid() || ! is_closed(poly)) { std::cerr << " Error: patched polyhedron is not valid or closed." << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; @@ -248,7 +248,7 @@ void test_ouput_iterators_triangulate_hole(const char* file_name) { if(patch.size() != (output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; std::cerr << " " << patch.size() << " vs " << (output_it - &*patch_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } } std::cerr << " Done!" << std::endl; @@ -282,13 +282,13 @@ void test_ouput_iterators_triangulate_and_refine_hole(const char* file_name) { if(patch_facets.size() != (output_its.first - &*patch_facets_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; std::cerr << " " << patch_facets.size() << " vs " << (output_its.first - &*patch_facets_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } if(patch_vertices.size() != (output_its.second - &*patch_vertices_2.begin())) { std::cerr << " Error: returned vertex output iterator is not valid!" << std::endl; std::cerr << " " << patch_vertices.size() << " vs " << (output_its.second - &*patch_vertices_2.begin()) << std::endl; - assert(false); + CGAL_assertion(false); } } std::cerr << " Done!" << std::endl; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp index 954a3526b92..150ef07efdd 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp @@ -57,13 +57,13 @@ private: // it reads .polylines.txt (there should be one polyline with last point repeated) void read_polyline_one_line(const char* file_name, std::vector& points) { std::ifstream stream(file_name); - if(!stream) { assert(false); } + if(!stream) { CGAL_assertion(false); } int count; - if(!(stream >> count)) { assert(false); } + if(!(stream >> count)) { CGAL_assertion(false); } while(count-- > 0) { Point_3 p; - if(!(stream >> p)) { assert(false); } + if(!(stream >> p)) { CGAL_assertion(false); } points.push_back(p); } } @@ -75,14 +75,14 @@ void read_polyline_with_extra_points( std::vector& extras) { std::ifstream stream(file_name); - if(!stream) { assert(false); } + if(!stream) { CGAL_assertion(false); } for(int i =0; i < 2; ++i) { int count; - if(!(stream >> count)) { assert(false); } + if(!(stream >> count)) { CGAL_assertion(false); } while(count-- > 0) { Point_3 p; - if(!(stream >> p)) { assert(false); } + if(!(stream >> p)) { CGAL_assertion(false); } i == 0 ? points.push_back(p) : extras.push_back(p); } } @@ -91,7 +91,7 @@ void read_polyline_with_extra_points( void check_triangles(std::vector& points, std::vector >& tris) { if(points.size() - 3 != tris.size()) { std::cerr << " Error: there should be n-2 triangles in generated patch." << std::endl; - assert(false); + CGAL_assertion(false); } const int max_index = static_cast(points.size())-1; @@ -101,7 +101,7 @@ void check_triangles(std::vector& points, std::vectorget<1>() == it->get<2>() ) { std::cerr << "Error: indices of triangles should be all different." << std::endl; - assert(false); + CGAL_assertion(false); } if(it->get<0>() >= max_index || @@ -109,7 +109,7 @@ void check_triangles(std::vector& points, std::vectorget<2>() >= max_index ) { std::cerr << " Error: max possible index check failed." << std::endl; - assert(false); + CGAL_assertion(false); } } } @@ -124,7 +124,7 @@ void check_constructed_polyhedron(const char* file_name, if(!poly.is_valid()) { std::cerr << " Error: constructed patch does not constitute a valid polyhedron." << std::endl; - assert(false); + CGAL_assertion(false); } std::string out_file_name; out_file_name.append(file_name).append(".off"); @@ -177,7 +177,7 @@ void test_should_be_no_output(const char* file_name, bool use_DT) { if(!tris.empty()) { std::cerr << " Error: patch should be empty" << std::endl; - assert(false); + CGAL_assertion(false); } std::cerr << " Done!" << std::endl; }