From aa40b908c9cc570d29901385f02a3190e2cadf22 Mon Sep 17 00:00:00 2001 From: Teseo Schneider Date: Fri, 19 Oct 2018 17:46:41 -0400 Subject: [PATCH 1/4] updated gtest to catch --- CMakeLists.txt | 1 + cmake/LibiglDownloadExternal.cmake | 8 +- tests/CMakeLists.txt | 85 ++++++--- tests/include/igl/CMakeLists.txt | 6 - tests/include/igl/avg_edge_length.cpp | 14 +- tests/include/igl/bbw.cpp | 5 +- tests/include/igl/boundary_loop.cpp | 14 +- .../igl/copyleft/boolean/CMakeLists.txt | 7 - tests/include/igl/copyleft/boolean/main.cpp | 6 - .../igl/copyleft/boolean/mesh_boolean.cpp | 14 +- .../include/igl/copyleft/cgal/CMakeLists.txt | 6 - tests/include/igl/copyleft/cgal/CSGTree.cpp | 6 +- tests/include/igl/copyleft/cgal/hausdorff.cpp | 4 +- tests/include/igl/copyleft/cgal/main.cpp | 6 - .../cgal/order_facets_around_edges.cpp | 18 +- .../include/igl/copyleft/cgal/outer_facet.cpp | 30 ++-- .../include/igl/copyleft/cgal/outer_hull.cpp | 2 +- .../copyleft/cgal/peel_outer_hull_layers.cpp | 14 +- .../copyleft/cgal/points_inside_component.cpp | 38 ++-- .../cgal/remesh_self_intersections.cpp | 2 +- .../igl/copyleft/comiso/CMakeLists.txt | 6 - tests/include/igl/copyleft/comiso/main.cpp | 6 - tests/include/igl/copyleft/comiso/miq.cpp | 7 +- .../igl/copyleft/tetgen/CMakeLists.txt | 6 - tests/include/igl/copyleft/tetgen/main.cpp | 6 - .../igl/copyleft/tetgen/tetrahedralize.cpp | 16 +- tests/include/igl/cotmatrix.cpp | 142 ++++++++------- tests/include/igl/cotmatrix_entries.cpp | 65 ++++--- tests/include/igl/cut_to_disk.cpp | 32 ++-- tests/include/igl/decimate.cpp | 76 ++++---- tests/include/igl/dirname.cpp | 4 +- tests/include/igl/doublearea.cpp | 66 +++---- tests/include/igl/edge_flaps.cpp | 80 ++++----- tests/include/igl/edge_lengths.cpp | 32 ++-- tests/include/igl/guess_extension.cpp | 44 ++--- tests/include/igl/is_edge_manifold.cpp | 34 ++-- tests/include/igl/is_symmetric.cpp | 12 +- tests/include/igl/ismember.cpp | 14 +- tests/include/igl/list_to_matrix.cpp | 94 +++++----- tests/include/igl/main.cpp | 6 - tests/include/igl/mosek/CMakeLists.txt | 6 - tests/include/igl/mosek/bbw.cpp | 4 +- tests/include/igl/mosek/main.cpp | 6 - tests/include/igl/pathinfo.cpp | 10 +- tests/include/igl/per_face_normals.cpp | 62 +++---- tests/include/igl/qslim.cpp | 8 +- tests/include/igl/readDMAT.cpp | 11 +- tests/include/igl/readOBJ.cpp | 7 +- tests/include/igl/readOFF.cpp | 11 +- tests/include/igl/seam_edges.cpp | 6 +- tests/include/igl/setdiff.cpp | 6 +- tests/include/igl/slice.cpp | 8 +- tests/include/igl/slice_into.cpp | 6 +- tests/include/igl/sort.cpp | 168 +++++++++--------- tests/include/igl/squared_edge_lengths.cpp | 50 +++--- tests/include/igl/tet_tet_adjacency.cpp | 66 +++---- .../igl/triangle_triangle_adjacency.cpp | 74 ++++---- tests/include/igl/unique.cpp | 36 ++-- tests/include/igl/upsample.cpp | 56 +++--- tests/test_common.h | 59 +++--- 60 files changed, 833 insertions(+), 861 deletions(-) delete mode 100644 tests/include/igl/CMakeLists.txt delete mode 100644 tests/include/igl/copyleft/boolean/CMakeLists.txt delete mode 100644 tests/include/igl/copyleft/boolean/main.cpp delete mode 100644 tests/include/igl/copyleft/cgal/CMakeLists.txt delete mode 100644 tests/include/igl/copyleft/cgal/main.cpp delete mode 100644 tests/include/igl/copyleft/comiso/CMakeLists.txt delete mode 100644 tests/include/igl/copyleft/comiso/main.cpp delete mode 100644 tests/include/igl/copyleft/tetgen/CMakeLists.txt delete mode 100644 tests/include/igl/copyleft/tetgen/main.cpp delete mode 100644 tests/include/igl/main.cpp delete mode 100644 tests/include/igl/mosek/CMakeLists.txt delete mode 100644 tests/include/igl/mosek/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a1dd8d959f..af6cb997a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ if(LIBIGL_BUILD_TUTORIALS) endif() if(LIBIGL_BUILD_TESTS) + include(CTest) enable_testing() add_subdirectory(tests) endif() diff --git a/cmake/LibiglDownloadExternal.cmake b/cmake/LibiglDownloadExternal.cmake index f7c69305cb..408b49a3e9 100644 --- a/cmake/LibiglDownloadExternal.cmake +++ b/cmake/LibiglDownloadExternal.cmake @@ -134,10 +134,10 @@ function(igl_download_triangle) endfunction() ## Google test -function(igl_download_googletest) - igl_download_project(googletest - GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG release-1.8.1 +function(igl_download_catch2) + igl_download_project(catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG 1faccd601d904a951142d8fba82914a8325b764e ) endfunction() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 50e1081464..a450d3e78f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.1) project(libigl_tests) -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) - -### Adding libIGL: choose the path to your local copy libIGL -if(NOT TARGET igl_common) - include(libigl) -else() - include(LibiglDownloadExternal) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) + +### Adding libIGL: choose the path to your local copy libIGL +if(NOT TARGET igl_common) + include(libigl) +else() + include(LibiglDownloadExternal) endif() ### Download data @@ -15,41 +15,76 @@ igl_download_test_data() set(IGL_TEST_DATA ${LIBIGL_EXTERNAL}/../tests/data) ### Download Google unit test framework. -igl_download_googletest() +igl_download_catch2() SET(TEST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) +list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/Catch2/contrib) INCLUDE_DIRECTORIES(${TEST_ROOT_DIR}) + + + +# Add catch2 +add_library(catch INTERFACE) +target_include_directories(catch SYSTEM INTERFACE ${LIBIGL_EXTERNAL}/catch2/single_include) + +# Create test executable +add_executable(libigl_tests main.cpp test_common.h) +target_link_libraries(libigl_tests PUBLIC igl::core catch) # Set TEST_DIR definition -ADD_DEFINITIONS(-DLIBIGL_DATA_DIR="${IGL_TEST_DATA}") - -# Add googletest googlemock support -ADD_SUBDIRECTORY( - ${LIBIGL_EXTERNAL}/googletest/googlemock - ${CMAKE_CURRENT_BINARY_DIR}/gtest) -SET(GTEST_BOTH_LIBRARIES gtest gmock) -INCLUDE_DIRECTORIES(${gmock_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${gmock_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${gtest_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${gtest_SOURCE_DIR}/include) +set(DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data/") +target_compile_definitions(libigl_tests PUBLIC -DLIBIGL_DATA_DIR="${IGL_TEST_DATA}") + # Process code in each subdirectories: add in decreasing order of complexity # (last added will run first and those should be the fastest tests) IF(LIBIGL_WITH_MOSEK) - ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/mosek) + file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/mosek/*.cpp) + file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/mosek/*.h ${TEST_ROOT_DIR}/include/igl/mosek/*.inl) + target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) + + target_link_libraries(libigl_tests PUBLIC igl::mosek) ENDIF() IF(LIBIGL_WITH_CGAL) - ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/boolean) - ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/cgal) + file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.cpp ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.cpp) + file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.inl ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.inl) + target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) + + target_link_libraries(libigl_tests PUBLIC igl::igl::cgal) ENDIF() IF(LIBIGL_WITH_TETGEN) - ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/tetgen) + file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.cpp) + file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.inl) + target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) + + target_link_libraries(libigl_tests PUBLIC igl::tetgen) ENDIF() IF(LIBIGL_WITH_COMISO) - ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/comiso) + file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.cpp) + file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.inl) + target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) + + target_link_libraries(libigl_tests PUBLIC igl::comiso) ENDIF() -ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl) + +file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/*.cpp) +file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/*.h ${TEST_ROOT_DIR}/include/igl/*.inl) +target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) + + + + +# Register tests +set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON) +include(Catch) +catch_discover_tests(libigl_tests) + + + + + + diff --git a/tests/include/igl/CMakeLists.txt b/tests/include/igl/CMakeLists.txt deleted file mode 100644 index acae0cba62..0000000000 --- a/tests/include/igl/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_tests igl::core gtest_main) -add_test(NAME run_igl_tests COMMAND igl_tests) diff --git a/tests/include/igl/avg_edge_length.cpp b/tests/include/igl/avg_edge_length.cpp index 9e3a500aa7..87c336e6fa 100644 --- a/tests/include/igl/avg_edge_length.cpp +++ b/tests/include/igl/avg_edge_length.cpp @@ -3,7 +3,7 @@ #include -TEST(avg_edge_length, cube) +TEST_CASE("avg_edge_length: cube", "[igl]") { //The allowed error for this test const double epsilon = 1e-15; @@ -31,32 +31,32 @@ TEST(avg_edge_length, cube) double avg; avg = igl::avg_edge_length(V,F); - ASSERT_NEAR((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.), avg, epsilon); + REQUIRE (avg == Approx ((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.)).margin( epsilon)); //Check the regular tetrahedron avg = igl::avg_edge_length(V,F_tet); - ASSERT_NEAR(sqrt(diag_sq), avg, epsilon); + REQUIRE (avg == Approx (sqrt(diag_sq)).margin( epsilon)); //Scale the cube to have huge sides side_sq = huge_scale * huge_scale; //squared lenght of a side diag_sq = 2.0 * side_sq; //squared lenght of a diagonal avg = igl::avg_edge_length(V_huge,F); - ASSERT_NEAR((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.), avg, epsilon*huge_scale); + REQUIRE (avg == Approx ((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.)).margin( epsilon*huge_scale)); //Check the equilateral triangles avg = igl::avg_edge_length(V_huge,F_tet); - ASSERT_NEAR(sqrt(diag_sq), avg, epsilon*huge_scale); + REQUIRE (avg == Approx (sqrt(diag_sq)).margin( epsilon*huge_scale)); //Scale the cube to have tiny sides side_sq = tiny_scale * tiny_scale; //squared lenght of a side diag_sq = 2.0 * side_sq; //squared lenght of a diagonal avg = igl::avg_edge_length(V_tiny,F); - ASSERT_NEAR((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.), avg, epsilon*tiny_scale); + REQUIRE (avg == Approx ((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.)).margin( epsilon*tiny_scale)); //Check the regular tetrahedron avg = igl::avg_edge_length(V_tiny,F_tet); - ASSERT_NEAR(sqrt(diag_sq), avg, epsilon*tiny_scale); + REQUIRE (avg == Approx (sqrt(diag_sq)).margin( epsilon*tiny_scale)); } diff --git a/tests/include/igl/bbw.cpp b/tests/include/igl/bbw.cpp index 31b9d83568..90f09aa2ef 100644 --- a/tests/include/igl/bbw.cpp +++ b/tests/include/igl/bbw.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,7 +5,7 @@ #include #include -TEST(bbw, decimated_knight) +TEST_CASE("bbw: decimated_knight", "[igl]") { Eigen::MatrixXd V,C; Eigen::MatrixXi T,F,E; @@ -22,6 +21,6 @@ TEST(bbw, decimated_knight) params.active_set_params.max_iter = 100; igl::bbw(V,T,b,bc,params,Was); // igl::writeDMAT("decimated-knight-as.dmat",Was); - ASSERT_LT( (Was-W_groundtruth).array().abs().maxCoeff() ,1e-4); + REQUIRE (1e-4 > (Was-W_groundtruth).array().abs().maxCoeff()); } diff --git a/tests/include/igl/boundary_loop.cpp b/tests/include/igl/boundary_loop.cpp index 84c3e24b2a..4e9c0a3aa4 100644 --- a/tests/include/igl/boundary_loop.cpp +++ b/tests/include/igl/boundary_loop.cpp @@ -4,7 +4,7 @@ #include #include -TEST(boundary_loop, cube) +TEST_CASE("boundary_loop: cube", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F; @@ -16,10 +16,10 @@ TEST(boundary_loop, cube) igl::boundary_loop(F, boundary); //The cube has no boundary - ASSERT_EQ(0, boundary.size()); + REQUIRE (boundary.size() == 0); } -TEST(boundary_loop, bunny) +TEST_CASE("boundary_loop: bunny", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F; @@ -31,7 +31,7 @@ TEST(boundary_loop, bunny) igl::boundary_loop(F, boundaries); //Compare our result with known results taken from meshlab - ASSERT_EQ(5, boundaries.size()); + REQUIRE (boundaries.size() == 5); //Compute min, max and sum of boundaries size_t boundaryMin=9999999; @@ -45,9 +45,9 @@ TEST(boundary_loop, bunny) } //Total boundary has 223 vertex - ASSERT_EQ(223, boundarySum); + REQUIRE (boundarySum == 223); //Largest loop has 80 vertex - ASSERT_EQ(80, boundaryMax); + REQUIRE (boundaryMax == 80); //Smallest loop has 22 vertex - ASSERT_EQ(22, boundaryMin); + REQUIRE (boundaryMin == 22); } diff --git a/tests/include/igl/copyleft/boolean/CMakeLists.txt b/tests/include/igl/copyleft/boolean/CMakeLists.txt deleted file mode 100644 index e1d79daf1c..0000000000 --- a/tests/include/igl/copyleft/boolean/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Check if CGAL is available -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_boolean_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_boolean_tests igl::core igl::cgal gtest_main) -add_test(NAME run_igl_boolean_tests COMMAND igl_boolean_tests) diff --git a/tests/include/igl/copyleft/boolean/main.cpp b/tests/include/igl/copyleft/boolean/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/copyleft/boolean/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/copyleft/boolean/mesh_boolean.cpp b/tests/include/igl/copyleft/boolean/mesh_boolean.cpp index 4dc2f84cf0..61ea590711 100644 --- a/tests/include/igl/copyleft/boolean/mesh_boolean.cpp +++ b/tests/include/igl/copyleft/boolean/mesh_boolean.cpp @@ -17,7 +17,7 @@ namespace mesh_boolean_test { Eigen::MatrixXi Eb; igl::exterior_edges(F, Eb); - ASSERT_EQ(0, Eb.rows()); + REQUIRE (Eb.rows() == 0); } template @@ -25,8 +25,8 @@ namespace mesh_boolean_test { const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F) { Eigen::MatrixXi B; - ASSERT_TRUE(igl::is_vertex_manifold(F, B)); - ASSERT_TRUE(igl::is_edge_manifold(F)); + REQUIRE (igl::is_vertex_manifold(F, B)); + REQUIRE (igl::is_edge_manifold(F)); } template @@ -47,10 +47,10 @@ namespace mesh_boolean_test { const int num_edges = uE.rows(); const int euler = num_vertices - num_edges + num_faces; - ASSERT_EQ(euler, 2 - 2 * genus); + REQUIRE (2 - 2 * genus == euler); } -TEST(MeshBoolean, TwoCubes) { +TEST_CASE("MeshBoolean: TwoCubes", "[igl/copyleft/boolean]") Eigen::MatrixXd V1; Eigen::MatrixXi F1; test_common::load_mesh("two-boxes-bad-self-union.ply", V1, F1); @@ -70,7 +70,7 @@ TEST(MeshBoolean, TwoCubes) { assert_genus_eq(Vo, Fo, 0); } -TEST(MeshBoolean, MinusTest) { +TEST_CASE("MeshBoolean: MinusTest", "[igl/copyleft/boolean]") // Many thanks to Eric Yao for submitting this test case. Eigen::MatrixXd V1, V2, Vo; Eigen::MatrixXi F1, F2, Fo; @@ -86,7 +86,7 @@ TEST(MeshBoolean, MinusTest) { assert_genus_eq(Vo, Fo, 1); } -TEST(MeshBoolean, IntersectWithSelf) { +TEST_CASE("MeshBoolean: IntersectWithSelf", "[igl/copyleft/boolean]") Eigen::MatrixXd V1, Vo; Eigen::MatrixXi F1, Fo; test_common::load_mesh("cube.obj", V1, F1); diff --git a/tests/include/igl/copyleft/cgal/CMakeLists.txt b/tests/include/igl/copyleft/cgal/CMakeLists.txt deleted file mode 100644 index 497a7db544..0000000000 --- a/tests/include/igl/copyleft/cgal/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_cgal_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_cgal_tests igl::core igl::cgal gtest_main) -add_test(NAME run_igl_cgal_tests COMMAND igl_cgal_tests) diff --git a/tests/include/igl/copyleft/cgal/CSGTree.cpp b/tests/include/igl/copyleft/cgal/CSGTree.cpp index 8d478413e4..c01bba570d 100644 --- a/tests/include/igl/copyleft/cgal/CSGTree.cpp +++ b/tests/include/igl/copyleft/cgal/CSGTree.cpp @@ -2,7 +2,7 @@ #include -TEST(CSGTree, extrusion) { +TEST_CASE("CSGTree: extrusion", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("extrusion.obj", V, F); @@ -12,6 +12,6 @@ TEST(CSGTree, extrusion) { Eigen::MatrixXd V2 = inter.cast_V(); Eigen::MatrixXi F2 = inter.F(); - ASSERT_EQ(V.rows(), V2.rows()); - ASSERT_EQ(F.rows(), F2.rows()); + REQUIRE (V2.rows() == V.rows()); + REQUIRE (F2.rows() == F.rows()); } diff --git a/tests/include/igl/copyleft/cgal/hausdorff.cpp b/tests/include/igl/copyleft/cgal/hausdorff.cpp index ca78f592e6..da4f9d5982 100644 --- a/tests/include/igl/copyleft/cgal/hausdorff.cpp +++ b/tests/include/igl/copyleft/cgal/hausdorff.cpp @@ -5,7 +5,7 @@ #include #include -TEST(hausdorff, knightVScheburashka) +TEST_CASE("hausdorff: knightVScheburashka", "[igl/copyleft/cgal]") { Eigen::MatrixXd VA,VB; Eigen::MatrixXi FA,FB; @@ -46,7 +46,7 @@ TEST(hausdorff, knightVScheburashka) { u4 = std::min(u4,U[j](i-u)); } - ASSERT_LE(u4,U[j-1](i/4)); + REQUIRE (U[j-1](i/4) >= u4); } } break; diff --git a/tests/include/igl/copyleft/cgal/main.cpp b/tests/include/igl/copyleft/cgal/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/copyleft/cgal/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp b/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp index 0784866f6e..f80ee7fb73 100644 --- a/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp +++ b/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp @@ -25,7 +25,7 @@ void assert_consistently_oriented(size_t num_faces, const std::vector& expected_face_order, const std::vector& e_order) { const size_t num_items = expected_face_order.size(); - ASSERT_EQ(num_items, e_order.size()); + REQUIRE (e_order.size() == num_items); std::vector order(num_items); std::transform(e_order.begin(), e_order.end(), order.begin(), @@ -33,7 +33,7 @@ void assert_consistently_oriented(size_t num_faces, size_t ref_start = index_of(order, expected_face_order[0]); for (size_t i=0; i fid); + REQUIRE (!flipped); } -TEST(OuterFacet, DuplicatedOppositeFaces) { +TEST_CASE("OuterFacet: DuplicatedOppositeFaces", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F1; test_common::load_mesh("cube.obj", V, F1); @@ -52,11 +52,11 @@ TEST(OuterFacet, DuplicatedOppositeFaces) { bool flipped; igl::copyleft::cgal::outer_facet(V, F, I, fid, flipped); - ASSERT_LT(fid, F.rows()); - ASSERT_FALSE(flipped); + REQUIRE (F.rows() > fid); + REQUIRE (!flipped); } -TEST(OuterFacet, FullyDegnerated) { +TEST_CASE("OuterFacet: FullyDegnerated", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("degenerated.obj", V, F); @@ -68,11 +68,11 @@ TEST(OuterFacet, FullyDegnerated) { bool flipped; igl::copyleft::cgal::outer_facet(V, F, I, fid, flipped); - ASSERT_LT(fid, F.rows()); - ASSERT_FALSE(flipped); + REQUIRE (F.rows() > fid); + REQUIRE (!flipped); } -TEST(OuterFacet, InvertedNormal) { +TEST_CASE("OuterFacet: InvertedNormal", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("cube.obj", V, F); @@ -85,11 +85,11 @@ TEST(OuterFacet, InvertedNormal) { bool flipped; igl::copyleft::cgal::outer_facet(V, F, I, fid, flipped); - ASSERT_LT(fid, F.rows()); - ASSERT_TRUE(flipped); + REQUIRE (F.rows() > fid); + REQUIRE (flipped); } -TEST(OuterFacet, SliverTet) { +TEST_CASE("OuterFacet: SliverTet", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("sliver_tet.ply", V, F); @@ -101,8 +101,8 @@ TEST(OuterFacet, SliverTet) { bool flipped; igl::copyleft::cgal::outer_facet(V, F, I, fid, flipped); - ASSERT_LT(fid, F.rows()); - ASSERT_FALSE(flipped); + REQUIRE (F.rows() > fid); + REQUIRE (!flipped); } } diff --git a/tests/include/igl/copyleft/cgal/outer_hull.cpp b/tests/include/igl/copyleft/cgal/outer_hull.cpp index 7046367477..fddc54224f 100644 --- a/tests/include/igl/copyleft/cgal/outer_hull.cpp +++ b/tests/include/igl/copyleft/cgal/outer_hull.cpp @@ -3,7 +3,7 @@ #include #include -TEST(OuterHull, CubeWithFold) { +TEST_CASE("OuterHull: CubeWithFold", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("cube_with_fold.ply", V, F); diff --git a/tests/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp b/tests/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp index e879d2713e..40ca2f4641 100644 --- a/tests/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp +++ b/tests/include/igl/copyleft/cgal/peel_outer_hull_layers.cpp @@ -11,12 +11,12 @@ #include -TEST(copyleft_cgal_peel_outer_hull_layers, TwoCubes) { +TEST_CASE("copyleft_cgal_peel_outer_hull_layers: TwoCubes", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("two-boxes-bad-self-union.ply", V, F); - ASSERT_EQ(486, V.rows()); - ASSERT_EQ(708, F.rows()); + REQUIRE (V.rows() == 486); + REQUIRE (F.rows() == 708); typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef K::FT Scalar; @@ -45,12 +45,12 @@ TEST(copyleft_cgal_peel_outer_hull_layers, TwoCubes) { vertices.data(), [](Scalar v) { return CGAL::to_double(v); }); igl::writeOBJ("debug.obj", vertices, Ft); - ASSERT_EQ(num_faces, I.rows()); - ASSERT_EQ(0, I.minCoeff()); - ASSERT_EQ(1, I.maxCoeff()); + REQUIRE (I.rows() == num_faces); + REQUIRE (I.minCoeff() == 0); + REQUIRE (I.maxCoeff() == 1); } -TEST(PeelOuterHullLayers, CubeWithFold) { +TEST_CASE("PeelOuterHullLayers: CubeWithFold", "[igl/copyleft/cgal]") Eigen::Matrix V; Eigen::MatrixXi F; test_common::load_mesh("cube_with_fold.ply", V, F); diff --git a/tests/include/igl/copyleft/cgal/points_inside_component.cpp b/tests/include/igl/copyleft/cgal/points_inside_component.cpp index 11265707f3..bfbe404d72 100644 --- a/tests/include/igl/copyleft/cgal/points_inside_component.cpp +++ b/tests/include/igl/copyleft/cgal/points_inside_component.cpp @@ -5,7 +5,7 @@ namespace PointInsideComponentHelper { -TEST(PointInsideComponent, simple) { +TEST_CASE("PointInsideComponent: simple", "[igl/copyleft/cgal]") Eigen::MatrixXd V1; Eigen::MatrixXi F1; test_common::load_mesh("cube.obj", V1, F1); @@ -17,14 +17,14 @@ TEST(PointInsideComponent, simple) { 0.0, 0.0, 1.0; Eigen::VectorXi inside; - EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P, inside)); - ASSERT_EQ(1, inside[0]); - ASSERT_EQ(0, inside[1]); - ASSERT_EQ(0, inside[2]); - ASSERT_EQ(0, inside[3]); + CHECK_NOTHROW (igl::copyleft::cgal::points_inside_component(V1, F1, P, inside)); + REQUIRE (inside[0] == 1); + REQUIRE (inside[1] == 0); + REQUIRE (inside[2] == 0); + REQUIRE (inside[3] == 0); } -TEST(PointInsideComponent, near_boundary) { +TEST_CASE("PointInsideComponent: near_boundary", "[igl/copyleft/cgal]") Eigen::MatrixXd V1; Eigen::MatrixXi F1; test_common::load_mesh("cube.obj", V1, F1); @@ -39,16 +39,16 @@ TEST(PointInsideComponent, near_boundary) { 0.0, 0.0, 0.5 - EPS; Eigen::VectorXi inside; - EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P, inside)); - ASSERT_EQ(0, inside[0]); - ASSERT_EQ(0, inside[1]); - ASSERT_EQ(0, inside[2]); - ASSERT_EQ(1, inside[3]); - ASSERT_EQ(1, inside[4]); - ASSERT_EQ(1, inside[5]); + CHECK_NOTHROW (igl::copyleft::cgal::points_inside_component(V1, F1, P, inside)); + REQUIRE (inside[0] == 0); + REQUIRE (inside[1] == 0); + REQUIRE (inside[2] == 0); + REQUIRE (inside[3] == 1); + REQUIRE (inside[4] == 1); + REQUIRE (inside[5] == 1); } -TEST(PointInsideComponent, near_corner) { +TEST_CASE("PointInsideComponent: near_corner", "[igl/copyleft/cgal]") Eigen::MatrixXd V1; Eigen::MatrixXi F1; test_common::load_mesh("cube.obj", V1, F1); @@ -65,8 +65,8 @@ TEST(PointInsideComponent, near_corner) { -0.5 - EPS,-0.5 - EPS,-0.5 - EPS; Eigen::VectorXi inside; - EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P_out, inside)); - ASSERT_TRUE((inside.array()==0).all()); + CHECK_NOTHROW (igl::copyleft::cgal::points_inside_component(V1, F1, P_out, inside)); + REQUIRE ((inside.array()==0).all()); Eigen::MatrixXd P_in(8, 3); P_in << 0.5 - EPS, 0.5 - EPS, 0.5 - EPS, @@ -77,8 +77,8 @@ TEST(PointInsideComponent, near_corner) { -0.5 + EPS, 0.5 - EPS,-0.5 + EPS, 0.5 - EPS,-0.5 + EPS,-0.5 + EPS, -0.5 + EPS,-0.5 + EPS,-0.5 + EPS; - EXPECT_NO_THROW(igl::copyleft::cgal::points_inside_component(V1, F1, P_in, inside)); - ASSERT_TRUE((inside.array()==1).all()); + CHECK_NOTHROW (igl::copyleft::cgal::points_inside_component(V1, F1, P_in, inside)); + REQUIRE ((inside.array()==1).all()); } } diff --git a/tests/include/igl/copyleft/cgal/remesh_self_intersections.cpp b/tests/include/igl/copyleft/cgal/remesh_self_intersections.cpp index 4921889466..e7b869d9ea 100644 --- a/tests/include/igl/copyleft/cgal/remesh_self_intersections.cpp +++ b/tests/include/igl/copyleft/cgal/remesh_self_intersections.cpp @@ -6,7 +6,7 @@ #include -TEST(RemeshSelfIntersections, CubeWithFold) { +TEST_CASE("RemeshSelfIntersections: CubeWithFold", "[igl/copyleft/cgal]") Eigen::MatrixXd V; Eigen::MatrixXi F; test_common::load_mesh("cube_with_fold.ply", V, F); diff --git a/tests/include/igl/copyleft/comiso/CMakeLists.txt b/tests/include/igl/copyleft/comiso/CMakeLists.txt deleted file mode 100644 index 8ca323a967..0000000000 --- a/tests/include/igl/copyleft/comiso/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_comiso_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_comiso_tests igl::core igl::comiso gtest_main) -add_test(NAME run_igl_comiso_tests COMMAND igl_comiso_tests) diff --git a/tests/include/igl/copyleft/comiso/main.cpp b/tests/include/igl/copyleft/comiso/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/copyleft/comiso/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/copyleft/comiso/miq.cpp b/tests/include/igl/copyleft/comiso/miq.cpp index 026e8e5482..1fc246e3d3 100644 --- a/tests/include/igl/copyleft/comiso/miq.cpp +++ b/tests/include/igl/copyleft/comiso/miq.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -18,7 +17,7 @@ #include #include -TEST(miq, 3_holes) +TEST_CASE("miq: 3_holes", "[igl/copyleft/comiso]") { using namespace Eigen; @@ -126,6 +125,6 @@ igl::copyleft::comiso::miq(V, igl::readDMAT(test_common::data_path("3holes-miq-UV.dmat"),UV_ref); igl::readDMAT(test_common::data_path("3holes-miq-FUV.dmat"),FUV_ref); - ASSERT_LT((UV-UV_ref).array().abs().maxCoeff() ,1e-6); - ASSERT_LT((FUV-FUV_ref).array().abs().maxCoeff() ,1e-6); + REQUIRE (1e-6 > (UV-UV_ref).array().abs().maxCoeff()); + REQUIRE (1e-6 > (FUV-FUV_ref).array().abs().maxCoeff()); } diff --git a/tests/include/igl/copyleft/tetgen/CMakeLists.txt b/tests/include/igl/copyleft/tetgen/CMakeLists.txt deleted file mode 100644 index 01338c817b..0000000000 --- a/tests/include/igl/copyleft/tetgen/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_tetgen_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_tetgen_tests igl::core igl::tetgen gtest_main) -add_test(NAME run_igl_tetgen_tests COMMAND igl_tetgen_tests) diff --git a/tests/include/igl/copyleft/tetgen/main.cpp b/tests/include/igl/copyleft/tetgen/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/copyleft/tetgen/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/copyleft/tetgen/tetrahedralize.cpp b/tests/include/igl/copyleft/tetgen/tetrahedralize.cpp index bfb717d647..bfb8b8834a 100644 --- a/tests/include/igl/copyleft/tetgen/tetrahedralize.cpp +++ b/tests/include/igl/copyleft/tetgen/tetrahedralize.cpp @@ -3,7 +3,8 @@ #include #include -TEST(tetrahedralize, single_tet) { +TEST_CASE("tetrahedralize: single_tet", "[igl/copyleft/tetgen]") +{ const Eigen::MatrixXd V = (Eigen::MatrixXd(4,3)<< 0,0,0, 1,0,0, @@ -13,19 +14,20 @@ TEST(tetrahedralize, single_tet) { Eigen::MatrixXd TV; Eigen::MatrixXi TT,TF; igl::copyleft::tetgen::tetrahedralize(V,F,"cpQ",TV,TT,TF); - ASSERT_EQ(TV.rows() , 4); - ASSERT_EQ(TT.rows() , 1); - ASSERT_EQ(TF.rows() , 4); + REQUIRE (4 == TV.rows()); + REQUIRE (1 == TT.rows()); + REQUIRE (4 == TF.rows()); Eigen::MatrixXi TTcorrect = (Eigen::MatrixXi(1,4)<<0,1,2,3).finished(); { Eigen::VectorXi TT_XOR,IA,IB; igl::setxor(TT,TTcorrect,TT_XOR,IA,IB); - ASSERT_EQ(TT_XOR.size(),0); + REQUIRE (0 == TT_XOR.size()); } test_common::assert_eq(TV,V); } -TEST(tetrahedralize, schoenhardt) { +TEST_CASE("tetrahedralize: schoenhardt", "[igl/copyleft/tetgen]") +{ const Eigen::MatrixXd V = (Eigen::MatrixXd(6,3)<< -246.2,-43.412,500, 160.7,-191.51,500, @@ -45,5 +47,5 @@ TEST(tetrahedralize, schoenhardt) { Eigen::MatrixXd TV; Eigen::MatrixXi TT,TF; igl::copyleft::tetgen::tetrahedralize(V,F,"pQ",TV,TT,TF); - ASSERT_GE(TV.rows() , V.rows()); + REQUIRE (V.rows() <= TV.rows()); } diff --git a/tests/include/igl/cotmatrix.cpp b/tests/include/igl/cotmatrix.cpp index a6e17af12c..5e0cc6329a 100644 --- a/tests/include/igl/cotmatrix.cpp +++ b/tests/include/igl/cotmatrix.cpp @@ -1,35 +1,35 @@ #include #include -class cotmatrix : public ::testing::TestWithParam {}; - -TEST_P(cotmatrix, constant_in_null_space) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - Eigen::SparseMatrix L; - // Load example mesh: GetParam() will be name of mesh file - test_common::load_mesh(GetParam(), V, F); - igl::cotmatrix(V,F,L); - ASSERT_EQ(V.rows(),L.rows()); - ASSERT_EQ(L.rows(),L.cols()); - Eigen::VectorXd C = Eigen::VectorXd::Ones(L.rows()); - Eigen::VectorXd Z = Eigen::VectorXd::Zero(L.rows()); - // ASSERT_EQ(a,b); - // ASSERT_TRUE(a==b); - // ASSERT_NEAR(a,b,1e-15) - ASSERT_LT(((L*C)-(Z)).norm(),1e-12); -} - -INSTANTIATE_TEST_CASE_P -( - all_meshes, - cotmatrix, - ::testing::ValuesIn(test_common::all_meshes()), - test_common::string_test_name -); - -TEST(cotmatrix, cube) +// class cotmatrix : public ::testing::TestWithParam {}; + +// TEST_P(cotmatrix, constant_in_null_space) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F; +// Eigen::SparseMatrix L; +// // Load example mesh: GetParam() will be name of mesh file +// test_common::load_mesh(GetParam(), V, F); +// igl::cotmatrix(V,F,L); +// REQUIRE (L.rows() == V.rows()); +// REQUIRE (L.cols() == L.rows()); +// Eigen::VectorXd C = Eigen::VectorXd::Ones(L.rows()); +// Eigen::VectorXd Z = Eigen::VectorXd::Zero(L.rows()); +// REQUIRE (b == a); +// REQUIRE (a==b); +// // ASSERT_NEAR(a,b,1e-15) +// REQUIRE (1e-12 > ((L*C)-(Z)).norm()); +// } + +// INSTANTIATE_TEST_CASE_P +// ( +// all_meshes, +// cotmatrix, +// ::testing::ValuesIn(test_common::all_meshes()), +// test_common::string_test_name +// ); + +TEST_CASE("cotmatrix: cube", "[igl]") { //The allowed error for this test const double epsilon = 1e-15; @@ -52,49 +52,48 @@ TEST(cotmatrix, cube) //So the cotangent matrix always are (0+0) or (0.5+0.5) Eigen::SparseMatrix L1; igl::cotmatrix(V,F,L1); - ASSERT_EQ(V.rows(), L1.rows()); - ASSERT_EQ(V.rows(), L1.cols()); + REQUIRE (L1.rows() == V.rows()); + REQUIRE (L1.cols() == V.rows()); for(int f = 0;f #include -TEST(cotmatrix_entries, simple) +TEST_CASE("cotmatrix_entries: simple", "[igl]") { //The allowed error for this test const double epsilon = 1e-15; @@ -23,8 +23,8 @@ TEST(cotmatrix_entries, simple) Eigen::MatrixXd C1; igl::cotmatrix_entries(V,F,C1); - ASSERT_EQ(F.rows(), C1.rows()); - ASSERT_EQ(3, C1.cols()); + REQUIRE (C1.rows() == F.rows()); + REQUIRE (C1.cols() == 3); //All angles in unit cube measure 45 or 90 degrees //Their (half)cotangent must value 0.5 or 0.0 for(int f = 0;f 0.1) - ASSERT_EQ(0.5, C1(f,v)); + REQUIRE (C1(f,v) == 0.5); else - ASSERT_EQ(0.0, C1(f,v)); + REQUIRE (C1(f,v) == 0.0); //All cotangents sum 1.0 for those triangles - ASSERT_EQ(1.0, C1.row(f).sum()); + REQUIRE (C1.row(f).sum() == 1.0); #else //Soft assert if we have not edge_lenght_squared for(int v = 0;v<3;v++) if (C1(f,v) > 0.1) - ASSERT_NEAR(0.5, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.5).margin( epsilon)); else - ASSERT_NEAR(0.0, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.0).margin( epsilon)); //All cotangents sum 1.0 for those triangles - ASSERT_NEAR(1.0, C1.row(f).sum(), epsilon); + REQUIRE (C1.row(f).sum() == Approx (1.0).margin( epsilon)); #endif } //Check the regular tetrahedron Eigen::MatrixXd C2; igl::cotmatrix_entries(V,F_tet,C2); - ASSERT_EQ(F_tet.rows(), C2.rows()); - ASSERT_EQ(3, C2.cols()); + REQUIRE (C2.rows() == F_tet.rows()); + REQUIRE (C2.cols() == 3); for(int f = 0;f 0.1) - ASSERT_EQ(0.5, C1(f,v)); + REQUIRE (C1(f,v) == 0.5); else - ASSERT_EQ(0.0, C1(f,v)); + REQUIRE (C1(f,v) == 0.0); //All cotangents sum 1.0 for those triangles - ASSERT_EQ(1.0, C1.row(f).sum()); + REQUIRE (C1.row(f).sum() == 1.0); #else //Soft assert if we have not edge_lenght_squared for(int v = 0;v<3;v++) if (C1(f,v) > 0.1) - ASSERT_NEAR(0.5, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.5).margin( epsilon)); else - ASSERT_NEAR(0.0, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.0).margin( epsilon)); //All cotangents sum 1.0 for those triangles - ASSERT_NEAR(1.0, C1.row(f).sum(), epsilon); + REQUIRE (C1.row(f).sum() == Approx (1.0).margin( epsilon)); #endif } //Check the huge regular tetrahedron igl::cotmatrix_entries(V_huge,F_tet,C2); - ASSERT_EQ(F_tet.rows(), C2.rows()); - ASSERT_EQ(3, C2.cols()); + REQUIRE (C2.rows() == F_tet.rows()); + REQUIRE (C2.cols() == 3); for(int f = 0;f 0.1) - ASSERT_NEAR(0.5, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.5).margin( epsilon)); else - ASSERT_NEAR(0.0, C1(f,v), epsilon); + REQUIRE (C1(f,v) == Approx (0.0).margin( epsilon)); //All cotangents sum 1.0 for those triangles - ASSERT_NEAR(1.0, C1.row(f).sum(), epsilon); + REQUIRE (C1.row(f).sum() == Approx (1.0).margin( epsilon)); } //Check the tiny regular tetrahedron igl::cotmatrix_entries(V_tiny,F_tet,C2); - ASSERT_EQ(F_tet.rows(), C2.rows()); - ASSERT_EQ(3, C2.cols()); + REQUIRE (C2.rows() == F_tet.rows()); + REQUIRE (C2.cols() == 3); for(int f = 0;f #include #include +#include namespace cut_to_disk_helper { template @@ -55,11 +56,12 @@ namespace cut_to_disk_helper { Eigen::MatrixXi E2; edges(F2, E2); const auto euler = V2.rows() - E2.rows() + F2.rows(); - ASSERT_TRUE(1 == euler || 2 == euler); + CHECK ((1 == euler || 2 == euler)); } } -TEST(cut_to_disk, simple_tet) { +TEST_CASE("cut_to_disk: simple_tet", "[igl]") +{ using namespace igl; Eigen::MatrixXi F(4, 3); F << 0, 2, 1, @@ -68,10 +70,11 @@ TEST(cut_to_disk, simple_tet) { 0, 1, 3; std::vector> cuts; cut_to_disk(F, cuts); - ASSERT_EQ(0, cuts.size()); + REQUIRE (cuts.size() == 0); } -TEST(cut_to_disk, two_disconnected_tet) { +TEST_CASE("cut_to_disk: two_disconnected_tet", "[igl]") +{ using namespace igl; Eigen::MatrixXi F(8, 3); F << 0, 2, 1, @@ -84,22 +87,24 @@ TEST(cut_to_disk, two_disconnected_tet) { 4, 5, 7; std::vector> cuts; cut_to_disk(F, cuts); - ASSERT_EQ(0, cuts.size()); + REQUIRE (cuts.size() == 0); } -TEST(cut_to_disk, simple_square) { +TEST_CASE("cut_to_disk: simple_square", "[igl]") +{ using namespace igl; Eigen::MatrixXi F(2, 3); F << 0, 1, 2, 2, 1, 3; std::vector> cuts; cut_to_disk(F, cuts); - ASSERT_EQ(1, cuts.size()); - ASSERT_EQ(5, cuts[0].size()); - ASSERT_EQ(cuts[0][0], cuts[0][4]); + REQUIRE (cuts.size() == 1); + REQUIRE (cuts[0].size() == 5); + REQUIRE (cuts[0][4] == cuts[0][0]); } -TEST(cut_to_disk, torus) { +TEST_CASE("cut_to_disk: torus", "[igl]") +{ using namespace igl; Eigen::MatrixXd V; Eigen::MatrixXi F; @@ -107,12 +112,13 @@ TEST(cut_to_disk, torus) { std::vector> cuts; cut_to_disk(F, cuts); - ASSERT_EQ(2, cuts.size()); + REQUIRE (cuts.size() == 2); cut_to_disk_helper::assert_is_disk(V, F, cuts); } -TEST(cut_to_disk, cube) { +TEST_CASE("cut_to_disk: cube", "[igl]") +{ using namespace igl; Eigen::MatrixXd V; Eigen::MatrixXi F; @@ -120,7 +126,7 @@ TEST(cut_to_disk, cube) { std::vector> cuts; cut_to_disk(F, cuts); - ASSERT_EQ(0, cuts.size()); + REQUIRE (cuts.size() == 0); cut_to_disk_helper::assert_is_disk(V, F, cuts); } diff --git a/tests/include/igl/decimate.cpp b/tests/include/igl/decimate.cpp index e5e07e5479..3979eafa8d 100644 --- a/tests/include/igl/decimate.cpp +++ b/tests/include/igl/decimate.cpp @@ -7,9 +7,9 @@ #include #include -class decimate : public ::testing::TestWithParam {}; +// class decimate : public ::testing::TestWithParam {}; -TEST(decimate,hemisphere) +TEST_CASE("decimate: hemisphere", "[igl]") { // Load a hemisphere centered at the origin. For each original vertex compute // its "perfect normal" (i.e., its position treated as unit vectors). @@ -31,8 +31,8 @@ TEST(decimate,hemisphere) Eigen::MatrixXd NU = U.rowwise().normalized(); Eigen::MatrixXd NVI; igl::slice(NV,I,1,NVI); - ASSERT_EQ(NVI.rows(),NU.rows()); - ASSERT_EQ(NVI.cols(),NU.cols()); + REQUIRE (NU.rows() == NVI.rows()); + REQUIRE (NU.cols() == NVI.cols()); // Dot product Eigen::VectorXd D = (NU.array()*NVI.array()).rowwise().sum(); Eigen::VectorXd O = Eigen::VectorXd::Ones(D.rows()); @@ -40,38 +40,38 @@ TEST(decimate,hemisphere) test_common::assert_near(D,O,0.02); } -TEST_P(decimate, closed) -{ - Eigen::MatrixXd V,U; - Eigen::MatrixXi F,G; - Eigen::VectorXi J; - // Load example mesh: GetParam() will be name of mesh file - test_common::load_mesh(GetParam(), V, F); - igl::decimate(V,F,0,U,G,J); - ASSERT_EQ(U.rows(),4); - ASSERT_EQ(G.rows(),4); - { - Eigen::MatrixXi I; - igl::sort(Eigen::MatrixXi(G),2,true,G,I); - } - { - Eigen::VectorXi I; - igl::sortrows(Eigen::MatrixXi(G),true,G,I); - } - // Tet with sorted faces - Eigen::MatrixXi T(4,3); - T<< - 0,1,2, - 0,1,3, - 0,2,3, - 1,2,3; - test_common::assert_eq(G,T); -} +// TEST_P(decimate, closed) +// { +// Eigen::MatrixXd V,U; +// Eigen::MatrixXi F,G; +// Eigen::VectorXi J; +// // Load example mesh: GetParam() will be name of mesh file +// test_common::load_mesh(GetParam(), V, F); +// igl::decimate(V,F,0,U,G,J); +// REQUIRE (4 == U.rows()); +// REQUIRE (4 == G.rows()); +// { +// Eigen::MatrixXi I; +// igl::sort(Eigen::MatrixXi(G),2,true,G,I); +// } +// { +// Eigen::VectorXi I; +// igl::sortrows(Eigen::MatrixXi(G),true,G,I); +// } +// // Tet with sorted faces +// Eigen::MatrixXi T(4,3); +// T<< +// 0,1,2, +// 0,1,3, +// 0,2,3, +// 1,2,3; +// test_common::assert_eq(G,T); +// } -INSTANTIATE_TEST_CASE_P -( - closed_genus_0_meshes, - decimate, - ::testing::ValuesIn(test_common::closed_genus_0_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// closed_genus_0_meshes, +// decimate, +// ::testing::ValuesIn(test_common::closed_genus_0_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/dirname.cpp b/tests/include/igl/dirname.cpp index ee883d743b..4511b90f08 100644 --- a/tests/include/igl/dirname.cpp +++ b/tests/include/igl/dirname.cpp @@ -5,7 +5,7 @@ #include #include -TEST(dirname, examples) +TEST_CASE("dirname: examples", "[igl]") { const std::vector< std::tuple > @@ -41,7 +41,7 @@ TEST(dirname, examples) { std::string d; d = igl::dirname(std::get<0>(example)); - ASSERT_EQ(std::get<1>(example),d); + REQUIRE (d == std::get<1>(example)); } } diff --git a/tests/include/igl/doublearea.cpp b/tests/include/igl/doublearea.cpp index a0bbb46222..10e9a8f752 100644 --- a/tests/include/igl/doublearea.cpp +++ b/tests/include/igl/doublearea.cpp @@ -1,39 +1,39 @@ #include #include -class doublearea : public ::testing::TestWithParam {}; +// class doublearea : public ::testing::TestWithParam {}; -TEST_P(doublearea, VF_vs_ABC ) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - test_common::load_mesh(GetParam(), V, F); +// TEST_P(doublearea, VF_vs_ABC ) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F; +// test_common::load_mesh(GetParam(), V, F); - // Check that computing double area with (V,F) is the same as computing - // double area with (V1,V2,V2) - Eigen::VectorXd A1,A2; - igl::doublearea(V,F,A1); - Eigen::MatrixXd A(F.rows(),3); - Eigen::MatrixXd B(F.rows(),3); - Eigen::MatrixXd C(F.rows(),3); - for(int f = 0;f #include -class edge_flaps : public ::testing::TestWithParam {}; +// class edge_flaps : public ::testing::TestWithParam {}; -TEST_P(edge_flaps, verify) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - test_common::load_mesh(GetParam(), V, F); +// TEST_P(edge_flaps, verify) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F; +// test_common::load_mesh(GetParam(), V, F); - Eigen::MatrixXi efE,efEF,efEI; - Eigen::VectorXi efEMAP; - igl::edge_flaps(F,efE,efEMAP,efEF,efEI); - ASSERT_EQ(efE.rows(),efEF.rows()); - ASSERT_EQ(efE.cols(),2); - ASSERT_EQ(efE.cols(),efEF.cols()); - // for each edge, make sure edge appears in face - for(int e = 0;e= 0) - { - EXPECT_TRUE( - // Either efE(e,[1 2]) = [i,j] appears after vertex c of face f - ((efE(e,0) == F(f,(c+1)%3)) && (efE(e,1) == F(f,(c+2)%3))) || - // Or efE(e,[2 1]) = [j,i] appears after vertex c of face f - ((efE(e,1) == F(f,(c+1)%3)) && (efE(e,0) == F(f,(c+2)%3)))); - } - } - } -} +// Eigen::MatrixXi efE,efEF,efEI; +// Eigen::VectorXi efEMAP; +// igl::edge_flaps(F,efE,efEMAP,efEF,efEI); +// REQUIRE (efEF.rows() == efE.rows()); +// REQUIRE (2 == efE.cols()); +// REQUIRE (efEF.cols() == efE.cols()); +// // for each edge, make sure edge appears in face +// for(int e = 0;e= 0) +// { +// EXPECT_TRUE( +// // Either efE(e,[1 2]) = [i,j] appears after vertex c of face f +// ((efE(e,0) == F(f,(c+1)%3)) && (efE(e,1) == F(f,(c+2)%3))) || +// // Or efE(e,[2 1]) = [j,i] appears after vertex c of face f +// ((efE(e,1) == F(f,(c+1)%3)) && (efE(e,0) == F(f,(c+2)%3)))); +// } +// } +// } +// } -INSTANTIATE_TEST_CASE_P -( - all_meshes, - edge_flaps, - ::testing::ValuesIn(test_common::all_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// all_meshes, +// edge_flaps, +// ::testing::ValuesIn(test_common::all_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/edge_lengths.cpp b/tests/include/igl/edge_lengths.cpp index 1c9847cb1e..4f60a5d432 100644 --- a/tests/include/igl/edge_lengths.cpp +++ b/tests/include/igl/edge_lengths.cpp @@ -2,7 +2,7 @@ #include #include -TEST(edge_lengths, cube) +TEST_CASE("edge_lengths: cube", "[igl]") { //The allowed error for this test const double epsilon = 1e-15; @@ -29,19 +29,19 @@ TEST(edge_lengths, cube) double diag = sqrt(2.0); //lenght of a diagonal Eigen::MatrixXd L; igl::edge_lengths(V,F,L); - ASSERT_EQ(F.rows(), L.rows()); - ASSERT_EQ(3, L.cols()); + REQUIRE (L.rows() == F.rows()); + REQUIRE (L.cols() == 3); //All edges in unit cube measure 1.0 or sqrt(2) in diagonals for(int f = 0;f 1.1*side) - ASSERT_EQ(diag, L(f,e)); + REQUIRE (L(f,e) == diag); else - ASSERT_EQ(side, L(f,e)); + REQUIRE (L(f,e) == side); //All sides sum exactly side + side + diag - ASSERT_EQ(L.row(f).sum(), side + side + diag); + REQUIRE (side + side + diag == L.row(f).sum()); } //Check the cube of huge sides @@ -49,18 +49,18 @@ TEST(edge_lengths, cube) side = scale; //lenght of a side diag = scale*sqrt(2.0); //lenght of a diagonal igl::edge_lengths(V_huge,F,L); - ASSERT_EQ(F.rows(), L.rows()); - ASSERT_EQ(3, L.cols()); + REQUIRE (L.rows() == F.rows()); + REQUIRE (L.cols() == 3); for(int f = 0;f 1.1*side) - ASSERT_EQ(diag, L(f,e)); + REQUIRE (L(f,e) == diag); else - ASSERT_EQ(side, L(f,e)); + REQUIRE (L(f,e) == side); //All sides sum exactly side + side + diag - ASSERT_NEAR(L.row(f).sum(), side + side + diag, epsilon); + REQUIRE (side + side + diag == Approx (L.row(f).sum()).margin( epsilon)); } //Check the cube of tiny sides @@ -68,18 +68,18 @@ TEST(edge_lengths, cube) side = scale; //lenght of a side diag = scale*sqrt(2.0); //lenght of a diagonal igl::edge_lengths(V_tiny,F,L); - ASSERT_EQ(F.rows(), L.rows()); - ASSERT_EQ(3, L.cols()); + REQUIRE (L.rows() == F.rows()); + REQUIRE (L.cols() == 3); for(int f = 0;f 1.1*side) - ASSERT_EQ(diag, L(f,e)); + REQUIRE (L(f,e) == diag); else - ASSERT_EQ(side, L(f,e)); + REQUIRE (L(f,e) == side); //All sides sum exactly side + side + diag - ASSERT_EQ(L.row(f).sum(), side + side + diag); + REQUIRE (side + side + diag == L.row(f).sum()); } } diff --git a/tests/include/igl/guess_extension.cpp b/tests/include/igl/guess_extension.cpp index 0e0cf28354..75102b5275 100644 --- a/tests/include/igl/guess_extension.cpp +++ b/tests/include/igl/guess_extension.cpp @@ -4,27 +4,27 @@ #include #include -class guess_extension : public ::testing::TestWithParam {}; +// class guess_extension : public ::testing::TestWithParam {}; -TEST_P(guess_extension, all_meshes) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - std::string path(test_common::data_path(GetParam())); - // Load example mesh: GetParam() will be name of mesh file - std::string d,b,e,f; - igl::pathinfo(path,d,b,e,f); - // Convert extension to lower case - std::transform(e.begin(), e.end(), e.begin(), ::tolower); - FILE * fp = fopen(path.c_str(),"r"); - std::string guess = igl::guess_extension(fp); - ASSERT_EQ(guess,e); -} +// TEST_P(guess_extension, all_meshes) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F; +// std::string path(test_common::data_path(GetParam())); +// // Load example mesh: GetParam() will be name of mesh file +// std::string d,b,e,f; +// igl::pathinfo(path,d,b,e,f); +// // Convert extension to lower case +// std::transform(e.begin(), e.end(), e.begin(), ::tolower); +// FILE * fp = fopen(path.c_str(),"r"); +// std::string guess = igl::guess_extension(fp); +// REQUIRE (e == guess); +// } -INSTANTIATE_TEST_CASE_P -( - all_meshes, - guess_extension, - ::testing::ValuesIn(test_common::all_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// all_meshes, +// guess_extension, +// ::testing::ValuesIn(test_common::all_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/is_edge_manifold.cpp b/tests/include/igl/is_edge_manifold.cpp index 089d7cb7fa..afffd211d3 100644 --- a/tests/include/igl/is_edge_manifold.cpp +++ b/tests/include/igl/is_edge_manifold.cpp @@ -1,29 +1,29 @@ #include #include -class is_edge_manifold : public ::testing::TestWithParam {}; +// class is_edge_manifold : public ::testing::TestWithParam {}; -TEST_P(is_edge_manifold, positive) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - test_common::load_mesh(GetParam(), V, F); - ASSERT_TRUE( igl::is_edge_manifold(F) ); -} +// TEST_P(is_edge_manifold, positive) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F; +// test_common::load_mesh(GetParam(), V, F); +// REQUIRE ( igl::is_edge_manifold(F) ); +// } -TEST(is_edge_manifold, negative) +TEST_CASE("is_edge_manifold: negative", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F; // Known non-manifold mesh test_common::load_mesh("truck.obj", V, F); - ASSERT_FALSE( igl::is_edge_manifold(F) ); + REQUIRE (! igl::is_edge_manifold(F) ); } -INSTANTIATE_TEST_CASE_P -( - manifold_meshes, - is_edge_manifold, - ::testing::ValuesIn(test_common::manifold_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// manifold_meshes, +// is_edge_manifold, +// ::testing::ValuesIn(test_common::manifold_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/is_symmetric.cpp b/tests/include/igl/is_symmetric.cpp index d7762dfddf..9bbe2ea2cc 100644 --- a/tests/include/igl/is_symmetric.cpp +++ b/tests/include/igl/is_symmetric.cpp @@ -2,34 +2,34 @@ #include #include -TEST(is_symmetric, sparse) +TEST_CASE("is_symmetric: sparse", "[igl]") { { Eigen::MatrixXd M(3,3); M<<1,2,3,4,5,6,7,8,9; Eigen::SparseMatrix S = M.sparseView(); - ASSERT_FALSE(igl::is_symmetric(S)); + REQUIRE (!igl::is_symmetric(S)); } { Eigen::MatrixXd M(3,3); M<<1,2,3,2,4,5,3,5,6; Eigen::SparseMatrix S = M.sparseView(); - ASSERT_FALSE(igl::is_symmetric(S)); + REQUIRE (!igl::is_symmetric(S)); } } -TEST(is_symmetric, dense) +TEST_CASE("is_symmetric: dense", "[igl]") { { Eigen::MatrixXd M(3,3); M<<1,2,3,4,5,6,7,8,9; - ASSERT_FALSE(igl::is_symmetric(M)); + REQUIRE (!igl::is_symmetric(M)); } { Eigen::MatrixXd M(3,3); M<<1,2,3, 2,4,5, 3,5,6; - ASSERT_FALSE(igl::is_symmetric(M)); + REQUIRE (!igl::is_symmetric(M)); } } diff --git a/tests/include/igl/ismember.cpp b/tests/include/igl/ismember.cpp index b2ce25511e..cb3a031169 100644 --- a/tests/include/igl/ismember.cpp +++ b/tests/include/igl/ismember.cpp @@ -2,7 +2,7 @@ #include #include -TEST(ismember, simple) +TEST_CASE("ismember: simple", "[igl]") { Eigen::MatrixXi A(3,4); A<<11,12,13,14,21,22,23,24,31,32,33,34; @@ -29,14 +29,14 @@ TEST(ismember, simple) } if(IA(i,j)) { - ASSERT_GE(LOCB(i,j),0); - ASSERT_LT(LOCB(i,j),B.size()); - ASSERT_EQ(vB(LOCB(i,j)),A(i,j)); - ASSERT_EQ(LOCB(i,j),bi); + REQUIRE (0 <= LOCB(i,j)); + REQUIRE (B.size() > LOCB(i,j)); + REQUIRE (A(i,j) == vB(LOCB(i,j))); + REQUIRE (bi == LOCB(i,j)); }else { - ASSERT_EQ(LOCB(i,j),-1); - ASSERT_EQ(bi,B.size()); + REQUIRE (-1 == LOCB(i,j)); + REQUIRE (B.size() == bi); } } } diff --git a/tests/include/igl/list_to_matrix.cpp b/tests/include/igl/list_to_matrix.cpp index 845ca15809..1dd2844847 100644 --- a/tests/include/igl/list_to_matrix.cpp +++ b/tests/include/igl/list_to_matrix.cpp @@ -3,52 +3,52 @@ #include #include -namespace list_to_matrix -{ - typedef std::tuple NM; - inline std::string NM_test_name( - const ::testing::TestParamInfo& info) - { - return STR( - std::get<0>(info.param)<<"x"<< - std::get<1>(info.param)<<"_"); - }; -} -class ListToMatrixTest : public ::testing::TestWithParam {}; +// namespace list_to_matrix +// { +// typedef std::tuple NM; +// inline std::string NM_test_name( +// const ::testing::TestParamInfo& info) +// { +// return STR( +// std::get<0>(info.param)<<"x"<< +// std::get<1>(info.param)<<"_"); +// }; +// } +// class ListToMatrixTest : public ::testing::TestWithParam {}; -TEST_P(ListToMatrixTest,matrix) -{ - const int n = std::get<0>(GetParam()); - const int m = std::get<1>(GetParam()); - std::vector > vX(n,std::vector(m)); - for(int i = 0;i(GetParam()); +// const int m = std::get<1>(GetParam()); +// std::vector > vX(n,std::vector(m)); +// for(int i = 0;i >( - std::vector{ - list_to_matrix::NM{100,4}, - list_to_matrix::NM{4,100}, - list_to_matrix::NM{100,1}, - list_to_matrix::NM{1,100}, - }), - list_to_matrix::NM_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// suite, +// ListToMatrixTest, +// ::testing::ValuesIn >( +// std::vector{ +// list_to_matrix::NM{100,4}, +// list_to_matrix::NM{4,100}, +// list_to_matrix::NM{100,1}, +// list_to_matrix::NM{1,100}, +// }), +// list_to_matrix::NM_test_name +// ); diff --git a/tests/include/igl/main.cpp b/tests/include/igl/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/mosek/CMakeLists.txt b/tests/include/igl/mosek/CMakeLists.txt deleted file mode 100644 index d31ddef597..0000000000 --- a/tests/include/igl/mosek/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -file(GLOB TEST_SRC_FILES *.cpp main.cpp) -file(GLOB TEST_INC_FILES *.h *.inl) - -add_executable(igl_mosek_tests ${TEST_SRC_FILES} ${TEST_INC_FILES}) -target_link_libraries(igl_mosek_tests igl::core igl::mosek gtest_main) -add_test(NAME run_igl_mosek_tests COMMAND igl_mosek_tests) diff --git a/tests/include/igl/mosek/bbw.cpp b/tests/include/igl/mosek/bbw.cpp index c8aa70f278..f30665527c 100644 --- a/tests/include/igl/mosek/bbw.cpp +++ b/tests/include/igl/mosek/bbw.cpp @@ -5,7 +5,7 @@ #include #include -TEST(mosek_bbw, decimated_knight) +TEST_CASE("mosek_bbw: decimated_knight", "[igl/copyleft/mosek]") { Eigen::MatrixXd V,C; Eigen::MatrixXi T,F,E; @@ -22,5 +22,5 @@ TEST(mosek_bbw, decimated_knight) igl::mosek::bbw(V,T,b,bc,params,mosek_params,Wmo); igl::writeDMAT("decimated-knight-mo.dmat",Wmo); // Mosek is less accurate - ASSERT_LT( (Wmo-W_groundtruth).array().abs().maxCoeff() ,1e-3); + REQUIRE (1e-3 > (Wmo-W_groundtruth).array().abs().maxCoeff()); } diff --git a/tests/include/igl/mosek/main.cpp b/tests/include/igl/mosek/main.cpp deleted file mode 100644 index 61fa98bde1..0000000000 --- a/tests/include/igl/mosek/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/include/igl/pathinfo.cpp b/tests/include/igl/pathinfo.cpp index 8812e526ca..0469ca9e36 100644 --- a/tests/include/igl/pathinfo.cpp +++ b/tests/include/igl/pathinfo.cpp @@ -5,7 +5,7 @@ #include #include -TEST(pathinfo, examples) +TEST_CASE("pathinfo: examples", "[igl]") { const std::vector< std::tuple > @@ -27,9 +27,9 @@ TEST(pathinfo, examples) { std::string d,b,e,f; igl::pathinfo(std::get<0>(example),d,b,e,f); - ASSERT_EQ(std::get<1>(example),d); - ASSERT_EQ(std::get<2>(example),b); - ASSERT_EQ(std::get<3>(example),e); - ASSERT_EQ(std::get<4>(example),f); + REQUIRE (d == std::get<1>(example)); + REQUIRE (b == std::get<2>(example)); + REQUIRE (e == std::get<3>(example)); + REQUIRE (f == std::get<4>(example)); } } diff --git a/tests/include/igl/per_face_normals.cpp b/tests/include/igl/per_face_normals.cpp index f44bf647dc..4eb0af3719 100644 --- a/tests/include/igl/per_face_normals.cpp +++ b/tests/include/igl/per_face_normals.cpp @@ -3,36 +3,36 @@ #include #include -class per_face_normals : public ::testing::TestWithParam {}; +// class per_face_normals : public ::testing::TestWithParam {}; -TEST_P(per_face_normals, dot) -{ - Eigen::MatrixXd V,N; - Eigen::MatrixXi F; - // Load example mesh: GetParam() will be name of mesh file - test_common::load_mesh(GetParam(), V, F); - igl::per_face_normals(V,F,N); - ASSERT_EQ(F.rows(),N.rows()); - for(int f = 0;f a); +// } -INSTANTIATE_TEST_CASE_P -( - all_meshes, - per_face_normals, - ::testing::ValuesIn(test_common::all_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// all_meshes, +// per_face_normals, +// ::testing::ValuesIn(test_common::all_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/qslim.cpp b/tests/include/igl/qslim.cpp index 0fa8afeee1..91804f82ce 100644 --- a/tests/include/igl/qslim.cpp +++ b/tests/include/igl/qslim.cpp @@ -6,7 +6,7 @@ //#include #include -TEST(qslim,cylinder) +TEST_CASE("qslim: cylinder", "[igl]") { using namespace igl; const int axis_devisions = 5; @@ -18,7 +18,7 @@ TEST(qslim,cylinder) Eigen::MatrixXi G; Eigen::VectorXi I,J; qslim(V,F,2*axis_devisions,U,G,I,J); - ASSERT_EQ(axis_devisions*2,U.rows()); + REQUIRE (U.rows() == axis_devisions*2); double l,u; igl::writePLY("qslim-cylinder-vf.ply",V,F); igl::writePLY("qslim-cylinder-ug.ply",U,G); @@ -38,7 +38,7 @@ TEST(qslim,cylinder) return D.array().sqrt().maxCoeff(); }; //igl::hausdorff(V,F,U,G,1e-14,l,u); - ASSERT_NEAR(hausdorff_lower_bound(V,F,U,G),0,2e-10); + REQUIRE (0 == Approx (hausdorff_lower_bound(V,F,U,G)).margin(2e-10)); //igl::hausdorff(U,G,V,F,1e-14,l,u); - ASSERT_NEAR(hausdorff_lower_bound(U,G,V,F),0,2e-10); + REQUIRE (0 == Approx (hausdorff_lower_bound(U,G,V,F)).margin(2e-10)); } diff --git a/tests/include/igl/readDMAT.cpp b/tests/include/igl/readDMAT.cpp index 7f5df5d54b..7660e907f9 100644 --- a/tests/include/igl/readDMAT.cpp +++ b/tests/include/igl/readDMAT.cpp @@ -1,19 +1,20 @@ #include -TEST(readDMAT, Comp) { +TEST_CASE("readDMAT: Comp", "[igl]") +{ Eigen::MatrixXd N1, N2; test_common::load_matrix("duplicated_faces_N1.dmat", N1); test_common::load_matrix("duplicated_faces_N2.dmat", N2); - ASSERT_EQ(N1.rows(), N2.rows()); - ASSERT_EQ(N1.cols(), N2.cols()); - ASSERT_FALSE(((N1-N2).array() != 0.0).all()); + REQUIRE (N2.rows() == N1.rows()); + REQUIRE (N2.cols() == N1.cols()); + REQUIRE (!((N1-N2).array() != 0.0).all()); const size_t rows = N1.rows(); const size_t cols = N1.cols(); for (size_t i=0; i -TEST(readOBJ, simple) { +TEST_CASE("readOBJ: simple", "[igl]") +{ Eigen::MatrixXd V; Eigen::MatrixXi F; // wait... so this is actually testing test_common::load_mesh not readOBJ // directly... test_common::load_mesh("cube.obj", V, F); - ASSERT_EQ(8, V.rows()); - ASSERT_EQ(12, F.rows()); + REQUIRE (V.rows() == 8); + REQUIRE (F.rows() == 12); } diff --git a/tests/include/igl/readOFF.cpp b/tests/include/igl/readOFF.cpp index 19f7a4902a..607ca15c28 100644 --- a/tests/include/igl/readOFF.cpp +++ b/tests/include/igl/readOFF.cpp @@ -1,13 +1,14 @@ #include -TEST(readOFF, simple) { +TEST_CASE("readOFF: simple", "[igl]") +{ Eigen::MatrixXd V; Eigen::MatrixXi F; // wait... so this is actually testing test_common::load_mesh not readOFF // directly... test_common::load_mesh("cube.off", V, F); - ASSERT_EQ(8, V.rows()); //has 8 vertex - ASSERT_EQ(3, V.cols()); //3D coordinates - ASSERT_EQ(12, F.rows()); //has 6*2=12 facets - ASSERT_EQ(3, F.cols()); //facets are triangles + REQUIRE (V.rows() == 8); + REQUIRE (V.cols() == 3); + REQUIRE (F.rows() == 12); + REQUIRE (F.cols() == 3); } diff --git a/tests/include/igl/seam_edges.cpp b/tests/include/igl/seam_edges.cpp index 95a086d066..d9e66d97af 100644 --- a/tests/include/igl/seam_edges.cpp +++ b/tests/include/igl/seam_edges.cpp @@ -2,7 +2,7 @@ #include #include -TEST(seam_edges, tet) +TEST_CASE("seam_edges: tet", "[igl]") { Eigen::MatrixXd V,TC,CN; Eigen::MatrixXi F,FTC,FN; @@ -17,7 +17,7 @@ TEST(seam_edges, tet) 3,0,0,2, 1,0,3,2; test_common::assert_eq(seams,seams_gt); - ASSERT_EQ(boundaries.size(),0); - ASSERT_EQ(foldovers.size(),0); + REQUIRE (0 == boundaries.size()); + REQUIRE (0 == foldovers.size()); } diff --git a/tests/include/igl/setdiff.cpp b/tests/include/igl/setdiff.cpp index 5deea03610..b7d67a3b6b 100644 --- a/tests/include/igl/setdiff.cpp +++ b/tests/include/igl/setdiff.cpp @@ -1,7 +1,7 @@ #include #include -TEST(setdiff,matrix) +TEST_CASE("setdiff: matrix", "[igl]") { // Base cases { @@ -35,10 +35,10 @@ TEST(setdiff,matrix) igl::setdiff(A,B,C,IA); for(int i = 0;i #include -TEST(slice, dense_identity) +TEST_CASE("slice: dense_identity", "[igl]") { // https://en.wikipedia.org/wiki/Monkey_testing Eigen::MatrixXd A = Eigen::MatrixXd::Random(10,9); @@ -25,7 +25,7 @@ TEST(slice, dense_identity) } } -TEST(slice, sparse_identity) +TEST_CASE("slice: sparse_identity", "[igl]") { Eigen::SparseMatrix A = Eigen::MatrixXd::Random(10,9).sparseView(); Eigen::VectorXi I = igl::LinSpaced(A.rows(),0,A.rows()-1); @@ -47,7 +47,7 @@ TEST(slice, sparse_identity) } } -TEST(slice,density_reverse) +TEST_CASE("slice: density_reverse", "[igl]") { { Eigen::MatrixXd A = Eigen::MatrixXd::Random(10,9); @@ -71,7 +71,7 @@ TEST(slice,density_reverse) } } -TEST(slice,random) +TEST_CASE("slice: random", "[igl]") { // Test whether unsorted indices are handled correctly by Randomly grow and // shrink a matrix by slicing out rows and columns: note that growing will diff --git a/tests/include/igl/slice_into.cpp b/tests/include/igl/slice_into.cpp index c346b12054..c70421d1a6 100644 --- a/tests/include/igl/slice_into.cpp +++ b/tests/include/igl/slice_into.cpp @@ -2,7 +2,7 @@ #include #include -TEST(slice_into, dense_identity) +TEST_CASE("slice_into: dense_identity", "[igl]") { Eigen::MatrixXd A = Eigen::MatrixXd::Random(10,9); Eigen::VectorXi I = igl::LinSpaced(A.rows(),0,A.rows()-1); @@ -24,7 +24,7 @@ TEST(slice_into, dense_identity) } } -TEST(slice_into,density_reverse) +TEST_CASE("slice_into: density_reverse", "[igl]") { { Eigen::MatrixXd A = Eigen::MatrixXd::Random(10,9); @@ -49,7 +49,7 @@ TEST(slice_into,density_reverse) } -TEST(slice_into, sparse_identity) +TEST_CASE("slice_into: sparse_identity", "[igl]") { Eigen::SparseMatrix A = Eigen::MatrixXd::Random(10,9).sparseView(); Eigen::VectorXi I = igl::LinSpaced(A.rows(),0,A.rows()-1); diff --git a/tests/include/igl/sort.cpp b/tests/include/igl/sort.cpp index d1ef08cd44..24f96fc84e 100644 --- a/tests/include/igl/sort.cpp +++ b/tests/include/igl/sort.cpp @@ -3,89 +3,89 @@ #include #include -namespace sort -{ - typedef std::tuple - NMDimAscending; - inline std::string NMDimAscending_test_name( - const ::testing::TestParamInfo& info) - { - return STR( - std::get<0>(info.param)<<"x"<< - std::get<1>(info.param)<<"_"<< - "dim_"<(info.param)<<"_"<< - "ascending_"<<(std::get<3>(info.param)?"true":"false")); - }; -} -class SortTest : public ::testing::TestWithParam {}; +// namespace sort +// { +// typedef std::tuple +// NMDimAscending; +// inline std::string NMDimAscending_test_name( +// const ::testing::TestParamInfo& info) +// { +// return STR( +// std::get<0>(info.param)<<"x"<< +// std::get<1>(info.param)<<"_"<< +// "dim_"<(info.param)<<"_"<< +// "ascending_"<<(std::get<3>(info.param)?"true":"false")); +// }; +// } +// class SortTest : public ::testing::TestWithParam {}; -TEST_P(SortTest,random) -{ - const int n = std::get<0>(GetParam()); - const int m = std::get<1>(GetParam()); - const int dim = std::get<2>(GetParam()); - const bool ascending = std::get<3>(GetParam()); - Eigen::MatrixXd X = Eigen::MatrixXd::Random(n,m); - // sort ascending - Eigen::MatrixXd Y; - Eigen::MatrixXi IX; - igl::sort(X,dim,ascending,Y,IX); - ASSERT_EQ(X.rows(),Y.rows()); - ASSERT_EQ(X.cols(),Y.cols()); - ASSERT_EQ(X.rows(),IX.rows()); - ASSERT_EQ(X.cols(),IX.cols()); - for(int i = 0;i(GetParam()); +// const int m = std::get<1>(GetParam()); +// const int dim = std::get<2>(GetParam()); +// const bool ascending = std::get<3>(GetParam()); +// Eigen::MatrixXd X = Eigen::MatrixXd::Random(n,m); +// // sort ascending +// Eigen::MatrixXd Y; +// Eigen::MatrixXi IX; +// igl::sort(X,dim,ascending,Y,IX); +// REQUIRE (Y.rows() == X.rows()); +// REQUIRE (Y.cols() == X.cols()); +// REQUIRE (IX.rows() == X.rows()); +// REQUIRE (IX.cols() == X.cols()); +// for(int i = 0;i= Y(i-(dim==1?1:0),j-(dim==2?1:0))); +// }else +// { +// REQUIRE (Y(i,j) <= Y(i-(dim==1?1:0),j-(dim==2?1:0))); +// } +// } +// } +// } -INSTANTIATE_TEST_CASE_P -( - suite, - SortTest, - ::testing::ValuesIn >( - std::vector { - sort::NMDimAscending{100,3,1,true}, - sort::NMDimAscending{100,3,2,true}, - sort::NMDimAscending{100,3,1,false}, - sort::NMDimAscending{100,3,2,false}, - sort::NMDimAscending{3,100,1,true}, - sort::NMDimAscending{3,100,2,true}, - sort::NMDimAscending{3,100,1,false}, - sort::NMDimAscending{3,100,2,false}, - sort::NMDimAscending{100,2,1,true}, - sort::NMDimAscending{100,2,2,true}, - sort::NMDimAscending{100,2,1,false}, - sort::NMDimAscending{100,2,2,false}, - sort::NMDimAscending{2,100,1,true}, - sort::NMDimAscending{2,100,2,true}, - sort::NMDimAscending{2,100,1,false}, - sort::NMDimAscending{2,100,2,false}, - sort::NMDimAscending{100,4,1,true}, - sort::NMDimAscending{100,4,2,true}, - sort::NMDimAscending{100,4,1,false}, - sort::NMDimAscending{100,4,2,false}, - sort::NMDimAscending{4,100,1,true}, - sort::NMDimAscending{4,100,2,true}, - sort::NMDimAscending{4,100,1,false}, - sort::NMDimAscending{4,100,2,false}, - }), - sort::NMDimAscending_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// suite, +// SortTest, +// ::testing::ValuesIn >( +// std::vector { +// sort::NMDimAscending{100,3,1,true}, +// sort::NMDimAscending{100,3,2,true}, +// sort::NMDimAscending{100,3,1,false}, +// sort::NMDimAscending{100,3,2,false}, +// sort::NMDimAscending{3,100,1,true}, +// sort::NMDimAscending{3,100,2,true}, +// sort::NMDimAscending{3,100,1,false}, +// sort::NMDimAscending{3,100,2,false}, +// sort::NMDimAscending{100,2,1,true}, +// sort::NMDimAscending{100,2,2,true}, +// sort::NMDimAscending{100,2,1,false}, +// sort::NMDimAscending{100,2,2,false}, +// sort::NMDimAscending{2,100,1,true}, +// sort::NMDimAscending{2,100,2,true}, +// sort::NMDimAscending{2,100,1,false}, +// sort::NMDimAscending{2,100,2,false}, +// sort::NMDimAscending{100,4,1,true}, +// sort::NMDimAscending{100,4,2,true}, +// sort::NMDimAscending{100,4,1,false}, +// sort::NMDimAscending{100,4,2,false}, +// sort::NMDimAscending{4,100,1,true}, +// sort::NMDimAscending{4,100,2,true}, +// sort::NMDimAscending{4,100,1,false}, +// sort::NMDimAscending{4,100,2,false}, +// }), +// sort::NMDimAscending_test_name +// ); diff --git a/tests/include/igl/squared_edge_lengths.cpp b/tests/include/igl/squared_edge_lengths.cpp index a4f46d5134..fa554529e0 100644 --- a/tests/include/igl/squared_edge_lengths.cpp +++ b/tests/include/igl/squared_edge_lengths.cpp @@ -3,7 +3,7 @@ #include -TEST(squared_edge_lengths, cube) +TEST_CASE("squared_edge_lengths: cube", "[igl]") { //The allowed error for this test const double epsilon = 1e-15; @@ -30,31 +30,31 @@ TEST(squared_edge_lengths, cube) double diag_sq = 2.0; //squared lenght of a diagonal Eigen::MatrixXd L_sq; igl::squared_edge_lengths(V,F,L_sq); - ASSERT_EQ(F.rows(), L_sq.rows()); - ASSERT_EQ(3, L_sq.cols()); + REQUIRE (L_sq.rows() == F.rows()); + REQUIRE (L_sq.cols() == 3); //All edges in unit cube measure 1.0 or sqrt(2) in diagonals for(int f = 0;f 1.1) - ASSERT_EQ(diag_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == diag_sq); else - ASSERT_EQ(side_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == side_sq); //All sides sum exactly side_sq + side_sq + diag_sq - ASSERT_EQ(L_sq.row(f).sum(), side_sq + side_sq + diag_sq); + REQUIRE (side_sq + side_sq + diag_sq == L_sq.row(f).sum()); } //Check the regular tetrahedron igl::squared_edge_lengths(V,F_tet,L_sq); - ASSERT_EQ(F_tet.rows(), L_sq.rows()); - ASSERT_EQ(3, L_sq.cols()); + REQUIRE (L_sq.rows() == F_tet.rows()); + REQUIRE (L_sq.cols() == 3); //All edges measure sqrt(2) for(int f = 0;f 1.1*side_sq) - ASSERT_EQ(diag_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == diag_sq); else - ASSERT_EQ(side_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == side_sq); //All sides sum exactly side_sq + side_sq + diag_sq - ASSERT_EQ(L_sq.row(f).sum(), side_sq + side_sq + diag_sq); + REQUIRE (side_sq + side_sq + diag_sq == L_sq.row(f).sum()); } //Check the equilateral triangles igl::squared_edge_lengths(V_huge,F_tet,L_sq); - ASSERT_EQ(F_tet.rows(), L_sq.rows()); - ASSERT_EQ(3, L_sq.cols()); + REQUIRE (L_sq.rows() == F_tet.rows()); + REQUIRE (L_sq.cols() == 3); //All edges measure sqrt(2) for(int f = 0;f 1.1*side_sq) - ASSERT_EQ(diag_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == diag_sq); else - ASSERT_EQ(side_sq, L_sq(f,e)); + REQUIRE (L_sq(f,e) == side_sq); //All sides sum exactly side_sq + side_sq + diag_sq - ASSERT_EQ(L_sq.row(f).sum(), side_sq + side_sq + diag_sq); + REQUIRE (side_sq + side_sq + diag_sq == L_sq.row(f).sum()); } //Check the regular tetrahedron igl::squared_edge_lengths(V_tiny,F_tet,L_sq); - ASSERT_EQ(F_tet.rows(), L_sq.rows()); - ASSERT_EQ(3, L_sq.cols()); + REQUIRE (L_sq.rows() == F_tet.rows()); + REQUIRE (L_sq.cols() == 3); //All edges measure sqrt(2) for(int f = 0;f -class tet_tet_adjacency : public ::testing::TestWithParam {}; +// class tet_tet_adjacency : public ::testing::TestWithParam {}; -TEST_P(tet_tet_adjacency, dot) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F, T, TT,TTi; - // Load example mesh: GetParam() will be name of mesh file - igl::readMESH(test_common::data_path(GetParam()), V, T, F); - igl::tet_tet_adjacency(T, TT, TTi); - ASSERT_EQ(T.rows(), TT.rows()); - ASSERT_EQ(T.rows(), TTi.rows()); - ASSERT_EQ(T.cols(),TT.cols()); - ASSERT_EQ(T.cols(),TTi.cols()); - for(int t = 0;t= 0) - { - ASSERT_LT(TT(t, c), T.rows()); - ASSERT_GE(TTi(t, c), 0); - ASSERT_LT(TTi(t, c), 4); - ASSERT_EQ(TT(TT(t, c), TTi(t,c)) , t); - } - } - } -} +// TEST_P(tet_tet_adjacency, dot) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F, T, TT,TTi; +// // Load example mesh: GetParam() will be name of mesh file +// igl::readMESH(test_common::data_path(GetParam()), V, T, F); +// igl::tet_tet_adjacency(T, TT, TTi); +// REQUIRE (TT.rows() == T.rows()); +// REQUIRE (TTi.rows() == T.rows()); +// REQUIRE (TT.cols() == T.cols()); +// REQUIRE (TTi.cols() == T.cols()); +// for(int t = 0;t= 0) +// { +// REQUIRE (T.rows() > TT(t, c)); +// REQUIRE (0 <= TTi(t, c)); +// REQUIRE (4 > TTi(t, c)); +// REQUIRE (t == TT(TT(t, c), TTi(t,c))); +// } +// } +// } +// } -INSTANTIATE_TEST_CASE_P -( - tet_meshes, - tet_tet_adjacency, - ::testing::ValuesIn(test_common::tet_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// tet_meshes, +// tet_tet_adjacency, +// ::testing::ValuesIn(test_common::tet_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/triangle_triangle_adjacency.cpp b/tests/include/igl/triangle_triangle_adjacency.cpp index c2406f6a42..62f4f2940d 100644 --- a/tests/include/igl/triangle_triangle_adjacency.cpp +++ b/tests/include/igl/triangle_triangle_adjacency.cpp @@ -3,42 +3,42 @@ #include #include -class triangle_triangle_adjacency : public ::testing::TestWithParam {}; +// class triangle_triangle_adjacency : public ::testing::TestWithParam {}; -TEST_P(triangle_triangle_adjacency, dot) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F,TT,TTi; - // Load example mesh: GetParam() will be name of mesh file - test_common::load_mesh(GetParam(), V, F); - igl::triangle_triangle_adjacency(F,TT,TTi); - ASSERT_EQ(F.rows(),TT.rows()); - ASSERT_EQ(F.rows(),TTi.rows()); - ASSERT_EQ(F.cols(),TT.cols()); - ASSERT_EQ(F.cols(),TTi.cols()); - for(int f = 0;f= 0) - { - ASSERT_LT(TT(f,c) , F.rows()); - ASSERT_GE(TTi(f,c) , 0); - ASSERT_LT(TTi(f,c) , 3); - ASSERT_EQ( TT(TT(f,c),TTi(f,c)) , f); - } - } - } - // ASSERT_EQ(a,b); - // ASSERT_TRUE(a==b); - // ASSERT_NEAR(a,b,1e-15) - // ASSERT_LT(a,1e-12); -} +// TEST_P(triangle_triangle_adjacency, dot) +// { +// Eigen::MatrixXd V; +// Eigen::MatrixXi F,TT,TTi; +// // Load example mesh: GetParam() will be name of mesh file +// test_common::load_mesh(GetParam(), V, F); +// igl::triangle_triangle_adjacency(F,TT,TTi); +// REQUIRE (TT.rows() == F.rows()); +// REQUIRE (TTi.rows() == F.rows()); +// REQUIRE (TT.cols() == F.cols()); +// REQUIRE (TTi.cols() == F.cols()); +// for(int f = 0;f= 0) +// { +// REQUIRE (F.rows() > TT(f,c)); +// REQUIRE (0 <= TTi(f,c)); +// REQUIRE (3 > TTi(f,c)); +// REQUIRE (f == TT(TT(f,c),TTi(f,c))); +// } +// } +// } +// REQUIRE (b == a); +// REQUIRE (a==b); +// // ASSERT_NEAR(a,b,1e-15) +// REQUIRE (1e-12 > a); +// } -INSTANTIATE_TEST_CASE_P -( - manifold_meshes, - triangle_triangle_adjacency, - ::testing::ValuesIn(test_common::manifold_meshes()), - test_common::string_test_name -); +// INSTANTIATE_TEST_CASE_P +// ( +// manifold_meshes, +// triangle_triangle_adjacency, +// ::testing::ValuesIn(test_common::manifold_meshes()), +// test_common::string_test_name +// ); diff --git a/tests/include/igl/unique.cpp b/tests/include/igl/unique.cpp index c4e5ca983f..20d3738a1f 100644 --- a/tests/include/igl/unique.cpp +++ b/tests/include/igl/unique.cpp @@ -2,7 +2,7 @@ #include #include -TEST(unique,matrix) +TEST_CASE("unique: matrix", "[igl]") { Eigen::VectorXi A(12); A = (Eigen::VectorXd::Random(A.size(),1).array().abs()*9).cast(); @@ -12,37 +12,37 @@ TEST(unique,matrix) for(int i = 0;i inC(inA.size(),false); // Expect a column vector - ASSERT_EQ(1,C.cols()); + REQUIRE (C.cols() == 1); for(int i = 0;i(); Eigen::MatrixXi C; Eigen::VectorXi IA,IC; igl::unique_rows(A,C,IA,IC); - ASSERT_EQ(A.cols(),C.cols()); - ASSERT_EQ(A.rows(),IC.size()); - ASSERT_EQ(C.rows(),IA.size()); + REQUIRE (C.cols() == A.cols()); + REQUIRE (IC.size() == A.rows()); + REQUIRE (IA.size() == C.rows()); std::map,bool> inA; for(int i = 0;i,bool> inC; @@ -62,23 +62,23 @@ TEST(unique_rows,matrix) std::vector vCi; igl::matrix_to_list(Ci,vCi); // Should be the first time finding this - ASSERT_FALSE(inC[vCi]); + REQUIRE (!inC[vCi]); // Mark as found inC[vCi] = true; // Should be something also found in A - ASSERT_TRUE(inA[vCi]); + REQUIRE (inA[vCi]); for(int j = 0;j #include -class upsample : public ::testing::TestWithParam {}; +// class upsample : public ::testing::TestWithParam {}; -TEST(upsample, single_triangle) +TEST_CASE("upsample: single_triangle", "[igl]") { Eigen::MatrixXi NF_groundtruth(4,3); NF_groundtruth << 0,3,5 ,1,4,3 ,3,4,5 ,4,2,5; @@ -28,30 +28,30 @@ TEST(upsample, single_triangle) test_common::assert_eq(NV_groundtruth,NV); } -TEST_P(upsample, V_comes_first_F_ordering) -{ - Eigen::MatrixXd V,NV; - Eigen::MatrixXi F,NF; - // Load example mesh: GetParam() will be name of mesh file - test_common::load_mesh(GetParam(), V, F); - igl::upsample(V,F,NV,NF); - ASSERT_GE(NV.rows(),V.rows()); - ASSERT_EQ(NF.rows(),4*F.rows()); - // V should be first part of V - test_common::assert_eq(V,NV.topLeftCorner(V.rows(),V.cols())); - // Expect a particular order - for(int f = 0;f #include -#include +#include #include #include @@ -16,18 +16,18 @@ namespace test_common { - // Input: - // s arbitrary string - // Returns s with all non-alphanumeric characters replaced with underscores '_' - inline std::string safe_test_name(std::string s) - { - std::for_each(s.begin(),s.end(),[](char &c){if(!std::isalnum(c)) c='_';}); - return s; - }; - inline std::string string_test_name(const ::testing::TestParamInfo& info) - { - return test_common::safe_test_name(info.param); - }; + // // Input: + // // s arbitrary string + // // Returns s with all non-alphanumeric characters replaced with underscores '_' + // inline std::string safe_test_name(std::string s) + // { + // std::for_each(s.begin(),s.end(),[](char &c){if(!std::isalnum(c)) c='_';}); + // return s; + // }; + // inline std::string string_test_name(const ::testing::TestParamInfo& info) + // { + // return test_common::safe_test_name(info.param); + // }; inline std::vector closed_genus_0_meshes() { return @@ -60,7 +60,7 @@ namespace test_common }; inline std::vector tet_meshes() { - return + return { "decimated-knight.mesh" }; @@ -84,7 +84,7 @@ namespace test_common // igl::read_triangle_mesh(test_common::data_path(X),...) template void load_mesh( - const std::string& filename, + const std::string& filename, Eigen::PlainObjectBase& V, Eigen::PlainObjectBase& F) { @@ -107,8 +107,8 @@ namespace test_common const Eigen::MatrixBase & B) { // Sizes should match - ASSERT_EQ(A.rows(),B.rows()); - ASSERT_EQ(A.cols(),B.cols()); + REQUIRE(A.rows() == B.rows()); + REQUIRE(A.cols() == B.cols()); for(int i = 0;i Aijv {i,j,A(i,j)}; std::tuple Bijv {i,j,B(i,j)}; - ASSERT_EQ(Aijv,Bijv); + REQUIRE(Aijv == Bijv); } } } @@ -127,8 +127,8 @@ namespace test_common const Eigen::SparseMatrix & B) { // Sizes should match - ASSERT_EQ(A.rows(),B.rows()); - ASSERT_EQ(A.cols(),B.cols()); + REQUIRE(A.rows() == B.rows()); + REQUIRE(A.cols() == B.cols()); Eigen::Matrix AI,AJ; Eigen::Matrix BI,BJ; Eigen::Matrix AV; @@ -150,8 +150,8 @@ namespace test_common const EpsType & eps) { // Sizes should match - ASSERT_EQ(A.rows(),B.rows()); - ASSERT_EQ(A.cols(),B.cols()); + REQUIRE(A.rows() == B.rows()); + REQUIRE(A.cols() == B.cols()); for(int i = 0;i Aijv {i,j,A(i,j)}; - std::tuple Bijv {i,j,B(i,j)+eps}; - ASSERT_LT(Aijv,Bijv); + // std::tuple Aijv {i,j,A(i,j)}; + // std::tuple Bijv {i,j,B(i,j)+eps}; + REQUIRE(A(i,j) < B(i,j)+eps); } { - std::tuple Aijv {i,j,A(i,j)+eps}; - std::tuple Bijv {i,j,B(i,j)}; - ASSERT_GT(Aijv,Bijv); + // std::tuple Aijv {i,j,A(i,j)+eps}; + // std::tuple Bijv {i,j,B(i,j)}; + REQUIRE(A(i,j)+eps > B(i,j)); } } } From 49a74590d4d9e3abaa8aa6a840952a20c58bc39a Mon Sep 17 00:00:00 2001 From: Teseo Schneider Date: Mon, 22 Oct 2018 16:05:42 -0400 Subject: [PATCH 2/4] cleand cmake and added INSTANTIATE_TEST_CASE_P --- tests/CMakeLists.txt | 28 +-- tests/include/igl/cotmatrix.cpp | 50 +++--- tests/include/igl/cotmatrix_entries.cpp | 2 +- tests/include/igl/decimate.cpp | 65 ++++--- tests/include/igl/doublearea.cpp | 62 ++++--- tests/include/igl/edge_flaps.cpp | 76 ++++---- tests/include/igl/guess_extension.cpp | 40 ++--- tests/include/igl/is_edge_manifold.cpp | 28 ++- tests/include/igl/list_to_matrix.cpp | 91 +++++----- tests/include/igl/per_face_normals.cpp | 57 +++--- tests/include/igl/sort.cpp | 164 +++++++++--------- tests/include/igl/squared_edge_lengths.cpp | 2 +- tests/include/igl/tet_tet_adjacency.cpp | 62 ++++--- .../igl/triangle_triangle_adjacency.cpp | 70 ++++---- tests/include/igl/upsample.cpp | 50 +++--- tests/main.cpp | 6 + tests/test_common.h | 25 ++- 17 files changed, 415 insertions(+), 463 deletions(-) create mode 100644 tests/main.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a450d3e78f..fe738dec61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,10 +16,7 @@ set(IGL_TEST_DATA ${LIBIGL_EXTERNAL}/../tests/data) ### Download Google unit test framework. igl_download_catch2() - -SET(TEST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/Catch2/contrib) -INCLUDE_DIRECTORIES(${TEST_ROOT_DIR}) @@ -28,9 +25,12 @@ INCLUDE_DIRECTORIES(${TEST_ROOT_DIR}) add_library(catch INTERFACE) target_include_directories(catch SYSTEM INTERFACE ${LIBIGL_EXTERNAL}/catch2/single_include) + # Create test executable add_executable(libigl_tests main.cpp test_common.h) target_link_libraries(libigl_tests PUBLIC igl::core catch) +target_include_directories(libigl_tests PUBLIC ${CMAKE_CURRENT_LIST_DIR}) + # Set TEST_DIR definition set(DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data/") target_compile_definitions(libigl_tests PUBLIC -DLIBIGL_DATA_DIR="${IGL_TEST_DATA}") @@ -39,40 +39,40 @@ target_compile_definitions(libigl_tests PUBLIC -DLIBIGL_DATA_DIR="${IGL_TEST_DAT # Process code in each subdirectories: add in decreasing order of complexity # (last added will run first and those should be the fastest tests) IF(LIBIGL_WITH_MOSEK) - file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/mosek/*.cpp) - file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/mosek/*.h ${TEST_ROOT_DIR}/include/igl/mosek/*.inl) + file(GLOB TEST_SRC_FILES ./include/igl/mosek/*.cpp) + file(GLOB TEST_INC_FILES ./include/igl/mosek/*.h ./include/igl/mosek/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) target_link_libraries(libigl_tests PUBLIC igl::mosek) ENDIF() IF(LIBIGL_WITH_CGAL) - file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.cpp ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.cpp) - file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.inl ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.inl) + file(GLOB TEST_SRC_FILES ./include/igl/copyleft/boolean/*.cpp ./include/igl/copyleft/cgal/*.cpp) + file(GLOB TEST_INC_FILES ./include/igl/copyleft/boolean/*.h ./include/igl/copyleft/cgal/*.h ./include/igl/copyleft/boolean/*.inl ./include/igl/copyleft/cgal/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) - target_link_libraries(libigl_tests PUBLIC igl::igl::cgal) + target_link_libraries(libigl_tests PUBLIC igl::cgal) ENDIF() IF(LIBIGL_WITH_TETGEN) - file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.cpp) - file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/tetgen/*.inl) + file(GLOB TEST_SRC_FILES ./include/igl/copyleft/tetgen/*.cpp) + file(GLOB TEST_INC_FILES ./include/igl/copyleft/tetgen/*.h ./include/igl/copyleft/tetgen/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) target_link_libraries(libigl_tests PUBLIC igl::tetgen) ENDIF() IF(LIBIGL_WITH_COMISO) - file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.cpp) - file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/comiso/*.inl) + file(GLOB TEST_SRC_FILES ./include/igl/copyleft/comiso/*.cpp) + file(GLOB TEST_INC_FILES ./include/igl/copyleft/comiso/*.h ./include/igl/copyleft/comiso/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) target_link_libraries(libigl_tests PUBLIC igl::comiso) ENDIF() -file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/*.cpp) -file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/*.h ${TEST_ROOT_DIR}/include/igl/*.inl) +file(GLOB TEST_SRC_FILES ./include/igl/*.cpp) +file(GLOB TEST_INC_FILES ./include/igl/*.h ./include/igl/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) diff --git a/tests/include/igl/cotmatrix.cpp b/tests/include/igl/cotmatrix.cpp index 5e0cc6329a..6cf84d33a0 100644 --- a/tests/include/igl/cotmatrix.cpp +++ b/tests/include/igl/cotmatrix.cpp @@ -1,33 +1,29 @@ #include #include -// class cotmatrix : public ::testing::TestWithParam {}; - -// TEST_P(cotmatrix, constant_in_null_space) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F; -// Eigen::SparseMatrix L; -// // Load example mesh: GetParam() will be name of mesh file -// test_common::load_mesh(GetParam(), V, F); -// igl::cotmatrix(V,F,L); -// REQUIRE (L.rows() == V.rows()); -// REQUIRE (L.cols() == L.rows()); -// Eigen::VectorXd C = Eigen::VectorXd::Ones(L.rows()); -// Eigen::VectorXd Z = Eigen::VectorXd::Zero(L.rows()); -// REQUIRE (b == a); -// REQUIRE (a==b); -// // ASSERT_NEAR(a,b,1e-15) -// REQUIRE (1e-12 > ((L*C)-(Z)).norm()); -// } - -// INSTANTIATE_TEST_CASE_P -// ( -// all_meshes, -// cotmatrix, -// ::testing::ValuesIn(test_common::all_meshes()), -// test_common::string_test_name -// ); + +TEST_CASE("cotmatrix: constant_in_null_space", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + Eigen::SparseMatrix L; + // Load example mesh: GetParam() will be name of mesh file + test_common::load_mesh(param, V, F); + igl::cotmatrix(V,F,L); + REQUIRE (L.rows() == V.rows()); + REQUIRE (L.cols() == L.rows()); + Eigen::VectorXd C = Eigen::VectorXd::Ones(L.rows()); + Eigen::VectorXd Z = Eigen::VectorXd::Zero(L.rows()); + // REQUIRE (b == a); + // REQUIRE (a==b); + // ASSERT_NEAR(a,b,1e-15) + REQUIRE (1e-12 > ((L*C)-(Z)).norm()); + }; + + test_common::run_test_cases(test_common::all_meshes(), test_case); +} TEST_CASE("cotmatrix: cube", "[igl]") { diff --git a/tests/include/igl/cotmatrix_entries.cpp b/tests/include/igl/cotmatrix_entries.cpp index 6b4d5515c6..2d3c74c3bf 100644 --- a/tests/include/igl/cotmatrix_entries.cpp +++ b/tests/include/igl/cotmatrix_entries.cpp @@ -70,7 +70,7 @@ TEST_CASE("cotmatrix_entries: simple", "[igl]") //All angles still measure 45 or 90 degrees //Their (half)cotangent must value 0.5 or 0.0 for(int f = 0;f #include -// class doublearea : public ::testing::TestWithParam {}; -// TEST_P(doublearea, VF_vs_ABC ) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F; -// test_common::load_mesh(GetParam(), V, F); +TEST_CASE("doublearea: VF_vs_ABC", "[igl]") +{ + auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + test_common::load_mesh(param, V, F); -// // Check that computing double area with (V,F) is the same as computing -// // double area with (V1,V2,V2) -// Eigen::VectorXd A1,A2; -// igl::doublearea(V,F,A1); -// Eigen::MatrixXd A(F.rows(),3); -// Eigen::MatrixXd B(F.rows(),3); -// Eigen::MatrixXd C(F.rows(),3); -// for(int f = 0;f #include -// class edge_flaps : public ::testing::TestWithParam {}; -// TEST_P(edge_flaps, verify) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F; -// test_common::load_mesh(GetParam(), V, F); +TEST_CASE("edge_flaps: verify", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + test_common::load_mesh(param, V, F); -// Eigen::MatrixXi efE,efEF,efEI; -// Eigen::VectorXi efEMAP; -// igl::edge_flaps(F,efE,efEMAP,efEF,efEI); -// REQUIRE (efEF.rows() == efE.rows()); -// REQUIRE (2 == efE.cols()); -// REQUIRE (efEF.cols() == efE.cols()); -// // for each edge, make sure edge appears in face -// for(int e = 0;e= 0) -// { -// EXPECT_TRUE( -// // Either efE(e,[1 2]) = [i,j] appears after vertex c of face f -// ((efE(e,0) == F(f,(c+1)%3)) && (efE(e,1) == F(f,(c+2)%3))) || -// // Or efE(e,[2 1]) = [j,i] appears after vertex c of face f -// ((efE(e,1) == F(f,(c+1)%3)) && (efE(e,0) == F(f,(c+2)%3)))); -// } -// } -// } -// } + Eigen::MatrixXi efE,efEF,efEI; + Eigen::VectorXi efEMAP; + igl::edge_flaps(F,efE,efEMAP,efEF,efEI); + REQUIRE (efEF.rows() == efE.rows()); + REQUIRE (2 == efE.cols()); + REQUIRE (efEF.cols() == efE.cols()); + // for each edge, make sure edge appears in face + for(int e = 0;e= 0) + { + // Either efE(e,[1 2]) = [i,j] appears after vertex c of face f + // Or efE(e,[2 1]) = [j,i] appears after vertex c of face f + CHECK(( + ((efE(e,0) == F(f,(c+1)%3)) && (efE(e,1) == F(f,(c+2)%3))) || + ((efE(e,1) == F(f,(c+1)%3)) && (efE(e,0) == F(f,(c+2)%3))))); + } + } + } + }; -// INSTANTIATE_TEST_CASE_P -// ( -// all_meshes, -// edge_flaps, -// ::testing::ValuesIn(test_common::all_meshes()), -// test_common::string_test_name -// ); + test_common::run_test_cases(test_common::all_meshes(), test_case); +} diff --git a/tests/include/igl/guess_extension.cpp b/tests/include/igl/guess_extension.cpp index 75102b5275..e0b8c72a3b 100644 --- a/tests/include/igl/guess_extension.cpp +++ b/tests/include/igl/guess_extension.cpp @@ -4,27 +4,23 @@ #include #include -// class guess_extension : public ::testing::TestWithParam {}; -// TEST_P(guess_extension, all_meshes) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F; -// std::string path(test_common::data_path(GetParam())); -// // Load example mesh: GetParam() will be name of mesh file -// std::string d,b,e,f; -// igl::pathinfo(path,d,b,e,f); -// // Convert extension to lower case -// std::transform(e.begin(), e.end(), e.begin(), ::tolower); -// FILE * fp = fopen(path.c_str(),"r"); -// std::string guess = igl::guess_extension(fp); -// REQUIRE (e == guess); -// } +TEST_CASE("guess_extension: all_meshes", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + std::string path(test_common::data_path(param)); + // Load example mesh: GetParam() will be name of mesh file + std::string d,b,e,f; + igl::pathinfo(path,d,b,e,f); + // Convert extension to lower case + std::transform(e.begin(), e.end(), e.begin(), ::tolower); + FILE * fp = fopen(path.c_str(),"r"); + std::string guess = igl::guess_extension(fp); + REQUIRE (e == guess); + }; -// INSTANTIATE_TEST_CASE_P -// ( -// all_meshes, -// guess_extension, -// ::testing::ValuesIn(test_common::all_meshes()), -// test_common::string_test_name -// ); + test_common::run_test_cases(test_common::all_meshes(), test_case); +} diff --git a/tests/include/igl/is_edge_manifold.cpp b/tests/include/igl/is_edge_manifold.cpp index afffd211d3..72da6a26e3 100644 --- a/tests/include/igl/is_edge_manifold.cpp +++ b/tests/include/igl/is_edge_manifold.cpp @@ -1,15 +1,19 @@ #include #include -// class is_edge_manifold : public ::testing::TestWithParam {}; -// TEST_P(is_edge_manifold, positive) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F; -// test_common::load_mesh(GetParam(), V, F); -// REQUIRE ( igl::is_edge_manifold(F) ); -// } +TEST_CASE("is_edge_manifold: positive", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + test_common::load_mesh(param, V, F); + REQUIRE ( igl::is_edge_manifold(F) ); + }; + + test_common::run_test_cases(test_common::manifold_meshes(), test_case); +} TEST_CASE("is_edge_manifold: negative", "[igl]") { @@ -19,11 +23,3 @@ TEST_CASE("is_edge_manifold: negative", "[igl]") test_common::load_mesh("truck.obj", V, F); REQUIRE (! igl::is_edge_manifold(F) ); } - -// INSTANTIATE_TEST_CASE_P -// ( -// manifold_meshes, -// is_edge_manifold, -// ::testing::ValuesIn(test_common::manifold_meshes()), -// test_common::string_test_name -// ); diff --git a/tests/include/igl/list_to_matrix.cpp b/tests/include/igl/list_to_matrix.cpp index 1dd2844847..ae984dc89d 100644 --- a/tests/include/igl/list_to_matrix.cpp +++ b/tests/include/igl/list_to_matrix.cpp @@ -3,52 +3,49 @@ #include #include -// namespace list_to_matrix -// { -// typedef std::tuple NM; -// inline std::string NM_test_name( -// const ::testing::TestParamInfo& info) -// { -// return STR( -// std::get<0>(info.param)<<"x"<< -// std::get<1>(info.param)<<"_"); -// }; -// } -// class ListToMatrixTest : public ::testing::TestWithParam {}; +namespace list_to_matrix +{ + typedef std::tuple NM; + // inline std::string NM_test_name( + // const ::testing::TestParamInfo& info) + // { + // return STR( + // std::get<0>(info.param)<<"x"<< + // std::get<1>(info.param)<<"_"); + // }; +} -// TEST_P(ListToMatrixTest,matrix) -// { -// const int n = std::get<0>(GetParam()); -// const int m = std::get<1>(GetParam()); -// std::vector > vX(n,std::vector(m)); -// for(int i = 0;i(param); + const int m = std::get<1>(param); + std::vector > vX(n,std::vector(m)); + for(int i = 0;i >( -// std::vector{ -// list_to_matrix::NM{100,4}, -// list_to_matrix::NM{4,100}, -// list_to_matrix::NM{100,1}, -// list_to_matrix::NM{1,100}, -// }), -// list_to_matrix::NM_test_name -// ); + std::vector params = { + list_to_matrix::NM{100,4}, + list_to_matrix::NM{4,100}, + list_to_matrix::NM{100,1}, + list_to_matrix::NM{1,100}, + }; + + test_common::run_test_cases(params, test_case); +} diff --git a/tests/include/igl/per_face_normals.cpp b/tests/include/igl/per_face_normals.cpp index 4eb0af3719..8406c3905c 100644 --- a/tests/include/igl/per_face_normals.cpp +++ b/tests/include/igl/per_face_normals.cpp @@ -3,36 +3,29 @@ #include #include -// class per_face_normals : public ::testing::TestWithParam {}; +TEST_CASE("per_face_normals: dot", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V,N; + Eigen::MatrixXi F; + // Load example mesh: GetParam() will be name of mesh file + test_common::load_mesh(param, V, F); + igl::per_face_normals(V,F,N); + REQUIRE (N.rows() == F.rows()); + for(int f = 0;f a); + }; -// TEST_P(per_face_normals, dot) -// { -// Eigen::MatrixXd V,N; -// Eigen::MatrixXi F; -// // Load example mesh: GetParam() will be name of mesh file -// test_common::load_mesh(GetParam(), V, F); -// igl::per_face_normals(V,F,N); -// REQUIRE (N.rows() == F.rows()); -// for(int f = 0;f a); -// } - -// INSTANTIATE_TEST_CASE_P -// ( -// all_meshes, -// per_face_normals, -// ::testing::ValuesIn(test_common::all_meshes()), -// test_common::string_test_name -// ); + test_common::run_test_cases(test_common::all_meshes(), test_case); +} diff --git a/tests/include/igl/sort.cpp b/tests/include/igl/sort.cpp index 24f96fc84e..0887542106 100644 --- a/tests/include/igl/sort.cpp +++ b/tests/include/igl/sort.cpp @@ -3,89 +3,85 @@ #include #include -// namespace sort -// { -// typedef std::tuple -// NMDimAscending; -// inline std::string NMDimAscending_test_name( -// const ::testing::TestParamInfo& info) -// { -// return STR( -// std::get<0>(info.param)<<"x"<< -// std::get<1>(info.param)<<"_"<< -// "dim_"<(info.param)<<"_"<< -// "ascending_"<<(std::get<3>(info.param)?"true":"false")); -// }; -// } -// class SortTest : public ::testing::TestWithParam {}; +namespace sort +{ + typedef std::tuple NMDimAscending; + // inline std::string NMDimAscending_test_name( + // const ::testing::TestParamInfo& info) + // { + // return STR( + // std::get<0>(info.param)<<"x"<< + // std::get<1>(info.param)<<"_"<< + // "dim_"<(info.param)<<"_"<< + // "ascending_"<<(std::get<3>(info.param)?"true":"false")); + // }; +} -// TEST_P(SortTest,random) -// { -// const int n = std::get<0>(GetParam()); -// const int m = std::get<1>(GetParam()); -// const int dim = std::get<2>(GetParam()); -// const bool ascending = std::get<3>(GetParam()); -// Eigen::MatrixXd X = Eigen::MatrixXd::Random(n,m); -// // sort ascending -// Eigen::MatrixXd Y; -// Eigen::MatrixXi IX; -// igl::sort(X,dim,ascending,Y,IX); -// REQUIRE (Y.rows() == X.rows()); -// REQUIRE (Y.cols() == X.cols()); -// REQUIRE (IX.rows() == X.rows()); -// REQUIRE (IX.cols() == X.cols()); -// for(int i = 0;i= Y(i-(dim==1?1:0),j-(dim==2?1:0))); -// }else -// { -// REQUIRE (Y(i,j) <= Y(i-(dim==1?1:0),j-(dim==2?1:0))); -// } -// } -// } -// } +TEST_CASE("SortTest: random", "[igl]") +{ + const auto test_case = [](const sort::NMDimAscending ¶m) + { + const int n = std::get<0>(param); + const int m = std::get<1>(param); + const int dim = std::get<2>(param); + const bool ascending = std::get<3>(param); + Eigen::MatrixXd X = Eigen::MatrixXd::Random(n,m); + // sort ascending + Eigen::MatrixXd Y; + Eigen::MatrixXi IX; + igl::sort(X,dim,ascending,Y,IX); + REQUIRE (Y.rows() == X.rows()); + REQUIRE (Y.cols() == X.cols()); + REQUIRE (IX.rows() == X.rows()); + REQUIRE (IX.cols() == X.cols()); + for(int i = 0;i= Y(i-(dim==1?1:0),j-(dim==2?1:0))); + }else + { + REQUIRE (Y(i,j) <= Y(i-(dim==1?1:0),j-(dim==2?1:0))); + } + } + } + }; -// INSTANTIATE_TEST_CASE_P -// ( -// suite, -// SortTest, -// ::testing::ValuesIn >( -// std::vector { -// sort::NMDimAscending{100,3,1,true}, -// sort::NMDimAscending{100,3,2,true}, -// sort::NMDimAscending{100,3,1,false}, -// sort::NMDimAscending{100,3,2,false}, -// sort::NMDimAscending{3,100,1,true}, -// sort::NMDimAscending{3,100,2,true}, -// sort::NMDimAscending{3,100,1,false}, -// sort::NMDimAscending{3,100,2,false}, -// sort::NMDimAscending{100,2,1,true}, -// sort::NMDimAscending{100,2,2,true}, -// sort::NMDimAscending{100,2,1,false}, -// sort::NMDimAscending{100,2,2,false}, -// sort::NMDimAscending{2,100,1,true}, -// sort::NMDimAscending{2,100,2,true}, -// sort::NMDimAscending{2,100,1,false}, -// sort::NMDimAscending{2,100,2,false}, -// sort::NMDimAscending{100,4,1,true}, -// sort::NMDimAscending{100,4,2,true}, -// sort::NMDimAscending{100,4,1,false}, -// sort::NMDimAscending{100,4,2,false}, -// sort::NMDimAscending{4,100,1,true}, -// sort::NMDimAscending{4,100,2,true}, -// sort::NMDimAscending{4,100,1,false}, -// sort::NMDimAscending{4,100,2,false}, -// }), -// sort::NMDimAscending_test_name -// ); + std::vector params = { + sort::NMDimAscending{100,3,1,true}, + sort::NMDimAscending{100,3,2,true}, + sort::NMDimAscending{100,3,1,false}, + sort::NMDimAscending{100,3,2,false}, + sort::NMDimAscending{3,100,1,true}, + sort::NMDimAscending{3,100,2,true}, + sort::NMDimAscending{3,100,1,false}, + sort::NMDimAscending{3,100,2,false}, + sort::NMDimAscending{100,2,1,true}, + sort::NMDimAscending{100,2,2,true}, + sort::NMDimAscending{100,2,1,false}, + sort::NMDimAscending{100,2,2,false}, + sort::NMDimAscending{2,100,1,true}, + sort::NMDimAscending{2,100,2,true}, + sort::NMDimAscending{2,100,1,false}, + sort::NMDimAscending{2,100,2,false}, + sort::NMDimAscending{100,4,1,true}, + sort::NMDimAscending{100,4,2,true}, + sort::NMDimAscending{100,4,1,false}, + sort::NMDimAscending{100,4,2,false}, + sort::NMDimAscending{4,100,1,true}, + sort::NMDimAscending{4,100,2,true}, + sort::NMDimAscending{4,100,1,false}, + sort::NMDimAscending{4,100,2,false}, + }; + + test_common::run_test_cases(params, test_case); +} diff --git a/tests/include/igl/squared_edge_lengths.cpp b/tests/include/igl/squared_edge_lengths.cpp index fa554529e0..a0f0060ebc 100644 --- a/tests/include/igl/squared_edge_lengths.cpp +++ b/tests/include/igl/squared_edge_lengths.cpp @@ -75,7 +75,7 @@ TEST_CASE("squared_edge_lengths: cube", "[igl]") //All sides sum exactly side_sq + side_sq + diag_sq REQUIRE (side_sq + side_sq + diag_sq == L_sq.row(f).sum()); } - + //Check the equilateral triangles igl::squared_edge_lengths(V_huge,F_tet,L_sq); REQUIRE (L_sq.rows() == F_tet.rows()); diff --git a/tests/include/igl/tet_tet_adjacency.cpp b/tests/include/igl/tet_tet_adjacency.cpp index 3019b32463..c86136a74e 100644 --- a/tests/include/igl/tet_tet_adjacency.cpp +++ b/tests/include/igl/tet_tet_adjacency.cpp @@ -4,38 +4,34 @@ #include -// class tet_tet_adjacency : public ::testing::TestWithParam {}; -// TEST_P(tet_tet_adjacency, dot) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F, T, TT,TTi; -// // Load example mesh: GetParam() will be name of mesh file -// igl::readMESH(test_common::data_path(GetParam()), V, T, F); -// igl::tet_tet_adjacency(T, TT, TTi); -// REQUIRE (TT.rows() == T.rows()); -// REQUIRE (TTi.rows() == T.rows()); -// REQUIRE (TT.cols() == T.cols()); -// REQUIRE (TTi.cols() == T.cols()); -// for(int t = 0;t= 0) -// { -// REQUIRE (T.rows() > TT(t, c)); -// REQUIRE (0 <= TTi(t, c)); -// REQUIRE (4 > TTi(t, c)); -// REQUIRE (t == TT(TT(t, c), TTi(t,c))); -// } -// } -// } -// } +TEST_CASE("tet_tet_adjacency: dot", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F, T, TT,TTi; + // Load example mesh: GetParam() will be name of mesh file + igl::readMESH(test_common::data_path(param), V, T, F); + igl::tet_tet_adjacency(T, TT, TTi); + REQUIRE (TT.rows() == T.rows()); + REQUIRE (TTi.rows() == T.rows()); + REQUIRE (TT.cols() == T.cols()); + REQUIRE (TTi.cols() == T.cols()); + for(int t = 0;t= 0) + { + REQUIRE (T.rows() > TT(t, c)); + REQUIRE (0 <= TTi(t, c)); + REQUIRE (4 > TTi(t, c)); + REQUIRE (t == TT(TT(t, c), TTi(t,c))); + } + } + } + }; -// INSTANTIATE_TEST_CASE_P -// ( -// tet_meshes, -// tet_tet_adjacency, -// ::testing::ValuesIn(test_common::tet_meshes()), -// test_common::string_test_name -// ); + test_common::run_test_cases(test_common::tet_meshes(), test_case); +} diff --git a/tests/include/igl/triangle_triangle_adjacency.cpp b/tests/include/igl/triangle_triangle_adjacency.cpp index 62f4f2940d..5ba8322708 100644 --- a/tests/include/igl/triangle_triangle_adjacency.cpp +++ b/tests/include/igl/triangle_triangle_adjacency.cpp @@ -3,42 +3,38 @@ #include #include -// class triangle_triangle_adjacency : public ::testing::TestWithParam {}; -// TEST_P(triangle_triangle_adjacency, dot) -// { -// Eigen::MatrixXd V; -// Eigen::MatrixXi F,TT,TTi; -// // Load example mesh: GetParam() will be name of mesh file -// test_common::load_mesh(GetParam(), V, F); -// igl::triangle_triangle_adjacency(F,TT,TTi); -// REQUIRE (TT.rows() == F.rows()); -// REQUIRE (TTi.rows() == F.rows()); -// REQUIRE (TT.cols() == F.cols()); -// REQUIRE (TTi.cols() == F.cols()); -// for(int f = 0;f= 0) -// { -// REQUIRE (F.rows() > TT(f,c)); -// REQUIRE (0 <= TTi(f,c)); -// REQUIRE (3 > TTi(f,c)); -// REQUIRE (f == TT(TT(f,c),TTi(f,c))); -// } -// } -// } -// REQUIRE (b == a); -// REQUIRE (a==b); -// // ASSERT_NEAR(a,b,1e-15) -// REQUIRE (1e-12 > a); -// } +TEST_CASE("triangle_triangle_adjacency: dot", "[igl]") +{ + const auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F,TT,TTi; + // Load example mesh: GetParam() will be name of mesh file + test_common::load_mesh(param, V, F); + igl::triangle_triangle_adjacency(F,TT,TTi); + REQUIRE (TT.rows() == F.rows()); + REQUIRE (TTi.rows() == F.rows()); + REQUIRE (TT.cols() == F.cols()); + REQUIRE (TTi.cols() == F.cols()); + for(int f = 0;f= 0) + { + REQUIRE (F.rows() > TT(f,c)); + REQUIRE (0 <= TTi(f,c)); + REQUIRE (3 > TTi(f,c)); + REQUIRE (f == TT(TT(f,c),TTi(f,c))); + } + } + } + // REQUIRE (b == a); + // REQUIRE (a==b); + // REQUIRE(a == Approx(b).margin(1e-15)) + // REQUIRE (1e-12 > a); + }; -// INSTANTIATE_TEST_CASE_P -// ( -// manifold_meshes, -// triangle_triangle_adjacency, -// ::testing::ValuesIn(test_common::manifold_meshes()), -// test_common::string_test_name -// ); + test_common::run_test_cases(test_common::manifold_meshes(), test_case); +} diff --git a/tests/include/igl/upsample.cpp b/tests/include/igl/upsample.cpp index 6a76c97224..5bd57e9a08 100644 --- a/tests/include/igl/upsample.cpp +++ b/tests/include/igl/upsample.cpp @@ -2,7 +2,6 @@ #include #include -// class upsample : public ::testing::TestWithParam {}; TEST_CASE("upsample: single_triangle", "[igl]") { @@ -28,30 +27,27 @@ TEST_CASE("upsample: single_triangle", "[igl]") test_common::assert_eq(NV_groundtruth,NV); } -// TEST_P(upsample, V_comes_first_F_ordering) -// { -// Eigen::MatrixXd V,NV; -// Eigen::MatrixXi F,NF; -// // Load example mesh: GetParam() will be name of mesh file -// test_common::load_mesh(GetParam(), V, F); -// igl::upsample(V,F,NV,NF); -// REQUIRE (V.rows() <= NV.rows()); -// REQUIRE (4*F.rows() == NF.rows()); -// // V should be first part of V -// test_common::assert_eq(V,NV.topLeftCorner(V.rows(),V.cols())); -// // Expect a particular order -// for(int f = 0;f \ No newline at end of file diff --git a/tests/test_common.h b/tests/test_common.h index 00bf31eeaa..241e6b4b3c 100644 --- a/tests/test_common.h +++ b/tests/test_common.h @@ -14,23 +14,18 @@ #include #include -namespace test_common +namespace test_common { - // // Input: - // // s arbitrary string - // // Returns s with all non-alphanumeric characters replaced with underscores '_' - // inline std::string safe_test_name(std::string s) - // { - // std::for_each(s.begin(),s.end(),[](char &c){if(!std::isalnum(c)) c='_';}); - // return s; - // }; - // inline std::string string_test_name(const ::testing::TestParamInfo& info) - // { - // return test_common::safe_test_name(info.param); - // }; + template + void run_test_cases(const std::vector ¶ms, Fun test_case) + { + for(const auto &p : params) + test_case(p); + } + inline std::vector closed_genus_0_meshes() { - return + return { "cube.obj", "decimated-knight.obj", @@ -97,7 +92,7 @@ namespace test_common template void load_matrix( const std::string& filename, - Eigen::PlainObjectBase& M) + Eigen::PlainObjectBase& M) { igl::readDMAT(data_path(filename), M); } From 6b13d5a70b361d40078b0ebe2a26729e2cb4c70e Mon Sep 17 00:00:00 2001 From: Teseo Schneider Date: Tue, 23 Oct 2018 09:47:30 -0400 Subject: [PATCH 3/4] fixed typo in cmake test --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fe738dec61..56f7c403fe 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,7 @@ set(IGL_TEST_DATA ${LIBIGL_EXTERNAL}/../tests/data) ### Download Google unit test framework. igl_download_catch2() -list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/Catch2/contrib) +list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/catch2/contrib) From 1c3c7c7b6fca8262787c98d31ecd2e816bae08f8 Mon Sep 17 00:00:00 2001 From: Teseo Schneider Date: Mon, 29 Oct 2018 16:39:58 -0400 Subject: [PATCH 4/4] ported new tests to catch2 --- tests/include/igl/circulation.cpp | 2 +- .../copyleft/cgal/delaunay_triangulation.cpp | 6 +- tests/include/igl/cotmatrix_entries.cpp | 2 +- tests/include/igl/cotmatrix_intrinsic.cpp | 46 +++++++-------- tests/include/igl/cumprod.cpp | 4 +- tests/include/igl/cumsum.cpp | 4 +- tests/include/igl/edge_exists_near.cpp | 4 +- tests/include/igl/grad.cpp | 2 +- tests/include/igl/grad_intrinsic.cpp | 2 +- tests/include/igl/grid.cpp | 4 +- .../igl/intrinsic_delaunay_cotmatrix.cpp | 56 +++++++++---------- .../igl/intrinsic_delaunay_triangulation.cpp | 8 +-- tests/include/igl/is_delaunay.cpp | 8 +-- tests/include/igl/is_intrinsic_delaunay.cpp | 8 +-- tests/include/igl/triangulated_grid.cpp | 8 +-- tests/include/igl/unique_simplices.cpp | 4 +- 16 files changed, 80 insertions(+), 88 deletions(-) diff --git a/tests/include/igl/circulation.cpp b/tests/include/igl/circulation.cpp index 4911ec324a..d7709ffbd6 100644 --- a/tests/include/igl/circulation.cpp +++ b/tests/include/igl/circulation.cpp @@ -4,7 +4,7 @@ #include #include -TEST(circulation,single_edge) +TEST_CASE("circulation: single_edge", "[igl]") { // 7 // /₆|₇\ diff --git a/tests/include/igl/copyleft/cgal/delaunay_triangulation.cpp b/tests/include/igl/copyleft/cgal/delaunay_triangulation.cpp index f28241e402..51b687b96b 100644 --- a/tests/include/igl/copyleft/cgal/delaunay_triangulation.cpp +++ b/tests/include/igl/copyleft/cgal/delaunay_triangulation.cpp @@ -3,7 +3,7 @@ #include #include -TEST(igl_copyleft_cgal_delaunay_triangulation, two_triangles) +TEST_CASE("igl_copyleft_cgal_delaunay_triangulation: two_triangles", "[igl/copyleft/cgal]") { const Eigen::MatrixXd V = (Eigen::MatrixXd(4,2)<< @@ -15,12 +15,12 @@ TEST(igl_copyleft_cgal_delaunay_triangulation, two_triangles) igl::copyleft::cgal::delaunay_triangulation(V,F); // Ground truth Eigen::MatrixXi Fgt = (Eigen::MatrixXi(2,3)<<0,1,3,0,3,2).finished(); - ASSERT_EQ(F.rows(),2); + REQUIRE (2 == F.rows()); Eigen::MatrixXi Fu; Eigen::VectorXi IA,IC; igl::unique_simplices( (Eigen::MatrixXi(4,3)< #include -class cotmatrix_intrinsic : public ::testing::TestWithParam {}; - -TEST(cotmatrix_intrinsic, periodic) +TEST_CASE("cotmatrix_intrinsic: periodic", "[igl]") { const Eigen::MatrixXi F = (Eigen::MatrixXi(18,3)<< 0,3,1, @@ -63,28 +61,26 @@ TEST(cotmatrix_intrinsic, periodic) test_common::assert_near(L_d,L_gt,igl::EPS()); } -TEST_P(cotmatrix_intrinsic , manifold_meshes) +TEST_CASE("cotmatrix_intrinsic: manifold_meshes", "[igl]") { - Eigen::MatrixXd V; - Eigen::MatrixXi F; - test_common::load_mesh(GetParam(), V, F); - Eigen::MatrixXd l; - igl::edge_lengths(V,F,l); - Eigen::SparseMatrix L,Li; - igl::cotmatrix(V,F,L); - igl::cotmatrix_intrinsic(l,F,Li); - // Augh, we don't have assert_near for sparse matrices... - // Instead test that bilinear form is near equal for 2 random vectors - const Eigen::VectorXd u = Eigen::VectorXd::Random(V.rows(),1); - const Eigen::VectorXd v = Eigen::VectorXd::Random(V.rows(),1); - const double uv = u.norm()*v.norm(); - ASSERT_NEAR( u.dot(L*v)/uv, u.dot(Li*v)/uv, igl::EPS()); + auto test_case = [](const std::string ¶m) + { + Eigen::MatrixXd V; + Eigen::MatrixXi F; + test_common::load_mesh(param, V, F); + Eigen::MatrixXd l; + igl::edge_lengths(V,F,l); + Eigen::SparseMatrix L,Li; + igl::cotmatrix(V,F,L); + igl::cotmatrix_intrinsic(l,F,Li); + // Augh, we don't have assert_near for sparse matrices... + // Instead test that bilinear form is near equal for 2 random vectors + const Eigen::VectorXd u = Eigen::VectorXd::Random(V.rows(),1); + const Eigen::VectorXd v = Eigen::VectorXd::Random(V.rows(),1); + const double uv = u.norm()*v.norm(); + REQUIRE (u.dot(Li*v)/uv == Approx (u.dot(L*v)/uv).margin( igl::EPS())); + }; + + test_common::run_test_cases(test_common::manifold_meshes(), test_case); } -INSTANTIATE_TEST_CASE_P -( - manifold_meshes, - cotmatrix_intrinsic, - ::testing::ValuesIn(test_common::manifold_meshes()), - test_common::string_test_name -); diff --git a/tests/include/igl/cumprod.cpp b/tests/include/igl/cumprod.cpp index 01139931ad..23990a1428 100644 --- a/tests/include/igl/cumprod.cpp +++ b/tests/include/igl/cumprod.cpp @@ -1,7 +1,7 @@ #include #include -TEST(cumprod,col_factorial) +TEST_CASE("cumprod: col_factorial", "[igl]") { Eigen::Vector4d X(1,2,3,4); Eigen::Vector4d Y; @@ -10,7 +10,7 @@ TEST(cumprod,col_factorial) test_common::assert_eq(Y,Ygt); } -TEST(cumprod,row_factorial) +TEST_CASE("cumprod: row_factorial", "[igl]") { Eigen::RowVector4d X(1,2,3,4); Eigen::RowVector4d Y; diff --git a/tests/include/igl/cumsum.cpp b/tests/include/igl/cumsum.cpp index bbdd2893ca..3546b42cf1 100644 --- a/tests/include/igl/cumsum.cpp +++ b/tests/include/igl/cumsum.cpp @@ -1,7 +1,7 @@ #include #include -TEST(cumsum,col) +TEST_CASE("cumsum: col", "[igl]") { Eigen::Vector4d X(1,2,3,4); Eigen::Vector4d Y; @@ -10,7 +10,7 @@ TEST(cumsum,col) test_common::assert_eq(Y,Ygt); } -TEST(cumsum,row) +TEST_CASE("cumsum: row", "[igl]") { Eigen::RowVector4d X(1,2,3,4); Eigen::RowVector4d Y; diff --git a/tests/include/igl/edge_exists_near.cpp b/tests/include/igl/edge_exists_near.cpp index 05c78ee518..eacae8b0bd 100644 --- a/tests/include/igl/edge_exists_near.cpp +++ b/tests/include/igl/edge_exists_near.cpp @@ -2,7 +2,7 @@ #include #include -TEST(edge_exists_near,tet) +TEST_CASE("edge_exists_near: tet", "[igl]") { const Eigen::MatrixXi F = (Eigen::MatrixXi(4,3)<< 0,1,2, @@ -21,7 +21,7 @@ TEST(edge_exists_near,tet) { if(i != j) { - ASSERT_TRUE(igl::edge_exists_near(uE,EMAP,uE2E,i,j,uei)); + REQUIRE (igl::edge_exists_near(uE,EMAP,uE2E,i,j,uei)); } } } diff --git a/tests/include/igl/grad.cpp b/tests/include/igl/grad.cpp index 6cd76364af..7e86a773b9 100644 --- a/tests/include/igl/grad.cpp +++ b/tests/include/igl/grad.cpp @@ -6,7 +6,7 @@ #include #include -TEST(grad,laplace_grid) +TEST_CASE("grad: laplace_grid", "[igl]") { Eigen::MatrixXd V2; Eigen::MatrixXi F; diff --git a/tests/include/igl/grad_intrinsic.cpp b/tests/include/igl/grad_intrinsic.cpp index bee4690a4a..4f3e91f878 100644 --- a/tests/include/igl/grad_intrinsic.cpp +++ b/tests/include/igl/grad_intrinsic.cpp @@ -6,7 +6,7 @@ #include #include -TEST(grad_intrinsic,laplace_grid) +TEST_CASE("grad_intrinsic: laplace_grid", "[igl]") { Eigen::MatrixXd V2; Eigen::MatrixXi F; diff --git a/tests/include/igl/grid.cpp b/tests/include/igl/grid.cpp index cebb017081..0d7ca378c6 100644 --- a/tests/include/igl/grid.cpp +++ b/tests/include/igl/grid.cpp @@ -2,7 +2,7 @@ #include #include -TEST(grid,3d) +TEST_CASE("grid: 3d", "[igl]") { Eigen::Vector3i res(3,3,3); Eigen::MatrixXd GV; @@ -39,7 +39,7 @@ TEST(grid,3d) test_common::assert_eq(GV,GVgt); } -TEST(grid,2d) +TEST_CASE("grid: 2d", "[igl]") { Eigen::Vector2i res(3,3); Eigen::MatrixXd GV; diff --git a/tests/include/igl/intrinsic_delaunay_cotmatrix.cpp b/tests/include/igl/intrinsic_delaunay_cotmatrix.cpp index 846e6dfdcb..4b84be39e3 100644 --- a/tests/include/igl/intrinsic_delaunay_cotmatrix.cpp +++ b/tests/include/igl/intrinsic_delaunay_cotmatrix.cpp @@ -4,9 +4,7 @@ #include #include -class intrinsic_delaunay_cotmatrix : public ::testing::TestWithParam {}; - -TEST(intrinsic_delaunay_cotmatrix,skewed_grid) +TEST_CASE("intrinsic_delaunay_cotmatrix: skewed_grid", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F; @@ -34,40 +32,38 @@ TEST(intrinsic_delaunay_cotmatrix,skewed_grid) { if(LI(k) != LJ(k) && !is_boundary_edge(LI(k),LJ(k),s)) { - ASSERT_GT(LV(k),-igl::EPS()); + REQUIRE (-igl::EPS() < LV(k)); } } } -TEST_P(intrinsic_delaunay_cotmatrix,manifold_meshes) +TEST_CASE("intrinsic_delaunay_cotmatrix: manifold_meshes", "[igl]") { - Eigen::MatrixXd V; - Eigen::MatrixXi F; - test_common::load_mesh(GetParam(), V, F); - Eigen::SparseMatrix L; - Eigen::MatrixXi F_intrinsic; - Eigen::MatrixXd l_intrinsic; - igl::intrinsic_delaunay_cotmatrix(V,F,L,l_intrinsic,F_intrinsic); - Eigen::VectorXi LI,LJ; - Eigen::VectorXd LV; - igl::find(L,LI,LJ,LV); - - const std::vector is_boundary_vertex = igl::is_border_vertex(F); - // Off diagonals should be all non-positive - for(int k = 0;k L; + Eigen::MatrixXi F_intrinsic; + Eigen::MatrixXd l_intrinsic; + igl::intrinsic_delaunay_cotmatrix(V,F,L,l_intrinsic,F_intrinsic); + Eigen::VectorXi LI,LJ; + Eigen::VectorXd LV; + igl::find(L,LI,LJ,LV); + + const std::vector is_boundary_vertex = igl::is_border_vertex(F); + // Off diagonals should be all non-positive + for(int k = 0;k()); + if(LI(k) != LJ(k) && + !(is_boundary_vertex[LI(k)] && is_boundary_vertex[LJ(k)])) + { + REQUIRE (-igl::EPS() < LV(k)); + } } - } + }; + + test_common::run_test_cases(test_common::manifold_meshes(), test_case); } -INSTANTIATE_TEST_CASE_P -( - manifold_meshes, - intrinsic_delaunay_cotmatrix, - ::testing::ValuesIn(test_common::manifold_meshes()), - test_common::string_test_name -); diff --git a/tests/include/igl/intrinsic_delaunay_triangulation.cpp b/tests/include/igl/intrinsic_delaunay_triangulation.cpp index 39b666b121..cf27a4672f 100644 --- a/tests/include/igl/intrinsic_delaunay_triangulation.cpp +++ b/tests/include/igl/intrinsic_delaunay_triangulation.cpp @@ -9,7 +9,7 @@ #include #include -TEST(intrinsic_delaunay_triangulation, two_triangles) +TEST_CASE("intrinsic_delaunay_triangulation: two_triangles", "[igl]") { const Eigen::MatrixXd V = (Eigen::MatrixXd(4,2)<< @@ -31,7 +31,7 @@ TEST(intrinsic_delaunay_triangulation, two_triangles) test_common::assert_near(l,lext,1e-10); } -TEST(intrinsic_delaunay_triangulation, skewed_grid) +TEST_CASE("intrinsic_delaunay_triangulation: skewed_grid", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F_in; @@ -53,7 +53,7 @@ TEST(intrinsic_delaunay_triangulation, skewed_grid) test_common::assert_eq(D,Dtrue); } -TEST(intrinsic_delaunay_triangulation, peaks) +TEST_CASE("intrinsic_delaunay_triangulation: peaks", "[igl]") { Eigen::MatrixXd V2; Eigen::MatrixXi F_in; @@ -86,7 +86,7 @@ TEST(intrinsic_delaunay_triangulation, peaks) test_common::assert_eq(D,D_gt); } -TEST(intrinsic_delaunay_triangulation,tet) +TEST_CASE("intrinsic_delaunay_triangulation: tet", "[igl]") { const Eigen::MatrixXd V = (Eigen::MatrixXd(4,3)<< 10, 4,7, diff --git a/tests/include/igl/is_delaunay.cpp b/tests/include/igl/is_delaunay.cpp index 296499f17a..091688667a 100644 --- a/tests/include/igl/is_delaunay.cpp +++ b/tests/include/igl/is_delaunay.cpp @@ -1,7 +1,7 @@ #include #include -TEST(is_delaunay, two_triangles) +TEST_CASE("is_delaunay: two_triangles", "[igl]") { const Eigen::MatrixXd V = (Eigen::MatrixXd(4,2)<< @@ -19,7 +19,7 @@ TEST(is_delaunay, two_triangles) { for(int c=0;c #include -TEST(is_intrinsic_delaunay, two_triangles) +TEST_CASE("is_intrinsic_delaunay: two_triangles", "[igl]") { const Eigen::MatrixXd V = (Eigen::MatrixXd(4,2)<< @@ -22,7 +22,7 @@ TEST(is_intrinsic_delaunay, two_triangles) { for(int c=0;c #include -TEST(triangulated_grid,area) +TEST_CASE("triangulated_grid: area", "[igl]") { Eigen::MatrixXd V; Eigen::MatrixXi F; const int nx = 4; const int ny = 7; igl::triangulated_grid(nx,ny,V,F); - ASSERT_EQ(V.rows(),nx*ny); - ASSERT_EQ(F.rows(),2*(nx-1)*(ny-1)); + REQUIRE (nx*ny == V.rows()); + REQUIRE (2*(nx-1)*(ny-1) == F.rows()); Eigen::VectorXd dblA; igl::doublearea(V,F,dblA); - ASSERT_NEAR(dblA.array().sum(),2.0,1e-10); + REQUIRE (2.0 == Approx (dblA.array().sum()).margin(1e-10)); const Eigen::VectorXd dblAgt = Eigen::VectorXd::Constant( 2*(nx-1)*(ny-1), diff --git a/tests/include/igl/unique_simplices.cpp b/tests/include/igl/unique_simplices.cpp index 4b31b58705..4183ca66b5 100644 --- a/tests/include/igl/unique_simplices.cpp +++ b/tests/include/igl/unique_simplices.cpp @@ -1,7 +1,7 @@ #include #include -TEST(igl_unique_simplices, duplicate_triangles) +TEST_CASE("igl_unique_simplices: duplicate_triangles", "[igl]") { const Eigen::MatrixXi F = (Eigen::MatrixXi(2,3)<<0,1,2,0,1,2).finished(); @@ -24,7 +24,7 @@ TEST(igl_unique_simplices, duplicate_triangles) Eigen::VectorXi IA,IC; igl::unique_simplices(Fij,Fu,IA,IC); // There's only one unique simplex - ASSERT_EQ(Fu.rows(),1); + REQUIRE (1 == Fu.rows()); } } }