improved test

This commit is contained in:
Dmitry Anisimov 2020-07-16 12:19:15 +02:00
parent 0d0c5d211f
commit 28494fe9fe
1 changed files with 164 additions and 131 deletions

View File

@ -8,159 +8,192 @@ using Kernel = CGAL::Simple_cartesian<double>;
using HDS_list = CGAL::HalfedgeDS_list<Kernel, CGAL::Polyhedron_items_3>; using HDS_list = CGAL::HalfedgeDS_list<Kernel, CGAL::Polyhedron_items_3>;
using HDS_vector = CGAL::HalfedgeDS_vector<Kernel, CGAL::Polyhedron_items_3>; using HDS_vector = CGAL::HalfedgeDS_vector<Kernel, CGAL::Polyhedron_items_3>;
// void test_vertex_handles_and_points( using VL = typename HDS_list::Vertex;
// Polyhedron& polyhedron) { using HL = typename HDS_list::Halfedge;
using FL = typename HDS_list::Face;
// auto pit = polyhedron.points_begin(); using VV = typename HDS_vector::Vertex;
// auto vit = polyhedron.vertices_begin(); using HV = typename HDS_vector::Halfedge;
// for (auto vh : polyhedron.vertex_handles()) { using FV = typename HDS_vector::Face;
// assert(vh == vit);
// assert(vh->point() == vit->point());
// assert(vh->point() == *pit);
// ++vit; ++pit;
// }
// assert(pit == polyhedron.points_end());
// assert(vit == polyhedron.vertices_end());
// pit = polyhedron.points_begin(); void test_vertex_handles(
// vit = polyhedron.vertices_begin(); HDS_list& hds_list,
// for (auto& point : polyhedron.points()) { HDS_vector& hds_vector) {
// assert(*pit == point);
// assert(vit->point() == point);
// ++vit; ++pit;
// }
// assert(pit == polyhedron.points_end());
// assert(vit == polyhedron.vertices_end());
// }
// void test_const_vertex_handles_and_points( auto lit = hds_list.vertices_begin();
// const Polyhedron& polyhedron) { assert(hds_list.vertex_handles().size() == 1);
for (auto vh : hds_list.vertex_handles()) {
assert(vh == lit);
assert(vh->point() == lit->point());
assert(vh->halfedge() == lit->halfedge());
++lit;
}
assert(lit == hds_list.vertices_end());
// auto pit = polyhedron.points_begin(); auto vit = hds_vector.vertices_begin();
// auto vit = polyhedron.vertices_begin(); assert(hds_vector.vertex_handles().size() == 1);
// for (const auto vh : polyhedron.vertex_handles()) { for (auto vh : hds_vector.vertex_handles()) {
// assert(vh == vit); assert(vh == vit);
// assert(vh->point() == vit->point()); assert(vh->point() == vit->point());
// assert(vh->point() == *pit); assert(vh->halfedge() == vit->halfedge());
// ++vit; ++pit; ++vit;
// } }
// assert(pit == polyhedron.points_end()); assert(vit == hds_vector.vertices_end());
// assert(vit == polyhedron.vertices_end()); }
// pit = polyhedron.points_begin(); void test_const_vertex_handles(
// vit = polyhedron.vertices_begin(); const HDS_list& hds_list,
// for (const auto& point : polyhedron.points()) { const HDS_vector& hds_vector) {
// assert(*pit == point);
// assert(vit->point() == point);
// ++vit; ++pit;
// }
// assert(pit == polyhedron.points_end());
// assert(vit == polyhedron.vertices_end());
// }
// void test_facet_handles_and_planes( auto lit = hds_list.vertices_begin();
// Polyhedron& polyhedron) { assert(hds_list.vertex_handles().size() == 1);
for (const auto vh : hds_list.vertex_handles()) {
assert(vh == lit);
assert(vh->point() == lit->point());
assert(vh->halfedge() == lit->halfedge());
++lit;
}
assert(lit == hds_list.vertices_end());
// auto pit = polyhedron.planes_begin(); auto vit = hds_vector.vertices_begin();
// auto fit = polyhedron.facets_begin(); assert(hds_vector.vertex_handles().size() == 1);
// for (auto fh : polyhedron.facet_handles()) { for (const auto vh : hds_vector.vertex_handles()) {
// assert(fh == fit); assert(vh == vit);
// assert(fh->plane() == fit->plane()); assert(vh->point() == vit->point());
// assert(fh->plane() == *pit); assert(vh->halfedge() == vit->halfedge());
// ++fit; ++pit; ++vit;
// } }
// assert(pit == polyhedron.planes_end()); assert(vit == hds_vector.vertices_end());
// assert(fit == polyhedron.facets_end()); }
// pit = polyhedron.planes_begin(); void test_face_handles(
// fit = polyhedron.facets_begin(); HDS_list& hds_list,
// for (auto& plane : polyhedron.planes()) { HDS_vector& hds_vector) {
// assert(*pit == plane);
// assert(fit->plane() == plane);
// ++fit; ++pit;
// }
// assert(pit == polyhedron.planes_end());
// assert(fit == polyhedron.facets_end());
// }
// void test_const_facet_handles_and_planes( auto lit = hds_list.faces_begin();
// const Polyhedron& polyhedron) { assert(hds_list.face_handles().size() == 2);
for (auto fh : hds_list.face_handles()) {
assert(fh == lit);
assert(fh->plane() == lit->plane());
assert(fh->halfedge() == lit->halfedge());
++lit;
}
assert(lit == hds_list.faces_end());
// auto pit = polyhedron.planes_begin(); auto vit = hds_vector.faces_begin();
// auto fit = polyhedron.facets_begin(); assert(hds_vector.face_handles().size() == 2);
// for (const auto fh : polyhedron.facet_handles()) { for (auto fh : hds_vector.face_handles()) {
// assert(fh == fit); assert(fh == vit);
// assert(fh->plane() == fit->plane()); assert(fh->plane() == vit->plane());
// assert(fh->plane() == *pit); assert(fh->halfedge() == vit->halfedge());
// ++fit; ++pit; ++vit;
// } }
// assert(pit == polyhedron.planes_end()); assert(vit == hds_vector.faces_end());
// assert(fit == polyhedron.facets_end()); }
// pit = polyhedron.planes_begin(); void test_const_face_handles(
// fit = polyhedron.facets_begin(); const HDS_list& hds_list,
// for (const auto& plane : polyhedron.planes()) { const HDS_vector& hds_vector) {
// assert(*pit == plane);
// assert(fit->plane() == plane);
// ++fit; ++pit;
// }
// assert(pit == polyhedron.planes_end());
// assert(fit == polyhedron.facets_end());
// }
// void test_halfedge_handles_and_edges( auto lit = hds_list.faces_begin();
// Polyhedron& polyhedron) { assert(hds_list.face_handles().size() == 2);
for (const auto fh : hds_list.face_handles()) {
assert(fh == lit);
assert(fh->plane() == lit->plane());
assert(fh->halfedge() == lit->halfedge());
++lit;
}
assert(lit == hds_list.faces_end());
// auto hit = polyhedron.halfedges_begin(); auto vit = hds_vector.faces_begin();
// for (auto hh : polyhedron.halfedge_handles()) { assert(hds_vector.face_handles().size() == 2);
// assert(hh == hit); for (const auto fh : hds_vector.face_handles()) {
// assert(hh->facet() == hit->facet()); assert(fh == vit);
// assert(hh->vertex() == hit->vertex()); assert(fh->plane() == vit->plane());
// ++hit; assert(fh->halfedge() == vit->halfedge());
// } ++vit;
// assert(hit == polyhedron.halfedges_end()); }
assert(vit == hds_vector.faces_end());
}
// auto eit = polyhedron.edges_begin(); void test_halfedge_handles(
// for (auto& edge : polyhedron.edges()) { HDS_list& hds_list,
// assert((*eit).facet() == edge.facet()); HDS_vector& hds_vector) {
// assert((*eit).vertex() == edge.vertex());
// ++eit;
// }
// assert(eit == polyhedron.edges_end());
// }
// void test_const_halfedge_handles_and_edges( auto lit = hds_list.halfedges_begin();
// const Polyhedron& polyhedron) { assert(hds_list.halfedge_handles().size() == 2);
for (auto hh : hds_list.halfedge_handles()) {
assert(hh == lit);
assert(hh->face() == lit->face());
assert(hh->vertex() == lit->vertex());
++lit;
}
assert(lit == hds_list.halfedges_end());
// auto hit = polyhedron.halfedges_begin(); auto vit = hds_vector.halfedges_begin();
// for (const auto hh : polyhedron.halfedge_handles()) { assert(hds_vector.halfedge_handles().size() == 2);
// assert(hh == hit); for (auto hh : hds_vector.halfedge_handles()) {
// assert(hh->facet() == hit->facet()); assert(hh == vit);
// assert(hh->vertex() == hit->vertex()); assert(hh->face() == vit->face());
// ++hit; assert(hh->vertex() == vit->vertex());
// } ++vit;
// assert(hit == polyhedron.halfedges_end()); }
assert(vit == hds_vector.halfedges_end());
}
// auto eit = polyhedron.edges_begin(); void test_const_halfedge_handles(
// for (const auto& edge : polyhedron.edges()) { const HDS_list& hds_list,
// assert((*eit).facet() == edge.facet()); const HDS_vector& hds_vector) {
// assert((*eit).vertex() == edge.vertex());
// ++eit; auto lit = hds_list.halfedges_begin();
// } assert(hds_list.halfedge_handles().size() == 2);
// assert(eit == polyhedron.edges_end()); for (const auto hh : hds_list.halfedge_handles()) {
// } assert(hh == lit);
assert(hh->face() == lit->face());
assert(hh->vertex() == lit->vertex());
++lit;
}
assert(lit == hds_list.halfedges_end());
auto vit = hds_vector.halfedges_begin();
assert(hds_vector.halfedge_handles().size() == 2);
for (const auto hh : hds_vector.halfedge_handles()) {
assert(hh == vit);
assert(hh->face() == vit->face());
assert(hh->vertex() == vit->vertex());
++vit;
}
assert(vit == hds_vector.halfedges_end());
}
int main() { int main() {
HDS_list hds_list(1, 2, 2); HDS_list hds_list(1, 2, 2);
HDS_vector hds_vector(1, 2, 2); hds_list.vertices_push_back(VL());
hds_list.edges_push_back(HL(), HL());
hds_list.faces_push_back(FL());
hds_list.faces_push_back(FL());
// test_vertex_handles_and_points(polyhedron); HDS_vector hds_vector(1, 2, 2);
// test_const_vertex_handles_and_points(polyhedron); hds_vector.vertices_push_back(VV());
// test_facet_handles_and_planes(polyhedron); hds_vector.edges_push_back(HV(), HV());
// test_const_facet_handles_and_planes(polyhedron); hds_vector.faces_push_back(FV());
// test_halfedge_handles_and_edges(polyhedron); hds_vector.faces_push_back(FV());
// test_const_halfedge_handles_and_edges(polyhedron);
assert(hds_list.size_of_vertices() == 1);
assert(hds_list.size_of_halfedges() == 2);
assert(hds_list.size_of_faces() == 2);
assert(hds_vector.size_of_vertices() == 1);
assert(hds_vector.size_of_halfedges() == 2);
assert(hds_vector.size_of_faces() == 2);
test_vertex_handles(hds_list, hds_vector);
test_const_vertex_handles(hds_list, hds_vector);
test_face_handles(hds_list, hds_vector);
test_const_face_handles(hds_list, hds_vector);
test_halfedge_handles(hds_list, hds_vector);
test_const_halfedge_handles(hds_list, hds_vector);
std::cout << "test_hds_range_based_loops: SUCCESS" << std::endl; std::cout << "test_hds_range_based_loops: SUCCESS" << std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;