New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed from google test to catch #961
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,90 @@ | ||
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 | ||
igl_download_test_data() | ||
set(IGL_TEST_DATA ${LIBIGL_EXTERNAL}/../tests/data) | ||
|
||
### Download Google unit test framework. | ||
igl_download_googletest() | ||
igl_download_catch2() | ||
list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/Catch2/contrib) | ||
|
||
|
||
|
||
|
||
# Add catch2 | ||
add_library(catch INTERFACE) | ||
target_include_directories(catch SYSTEM INTERFACE ${LIBIGL_EXTERNAL}/catch2/single_include) | ||
|
||
|
||
SET(TEST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||
INCLUDE_DIRECTORIES(${TEST_ROOT_DIR}) | ||
# 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 | ||
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 ./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) | ||
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/boolean) | ||
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/cgal) | ||
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::cgal) | ||
ENDIF() | ||
|
||
IF(LIBIGL_WITH_TETGEN) | ||
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/tetgen) | ||
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) | ||
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/copyleft/comiso) | ||
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() | ||
|
||
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl) | ||
|
||
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}) | ||
|
||
|
||
|
||
|
||
# Register tests | ||
set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON) | ||
include(Catch) | ||
catch_discover_tests(libigl_tests) | ||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
#include <iostream> | ||
|
||
|
||
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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove the space between the macro and the parenthesis (to keep it consistent). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part was autogenerated with a script. There might be a lot of cases like that. I dont think it is worth to time investment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On mac you need |
||
|
||
//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)); | ||
|
||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of date comment.