From b4e6e24368da6654a19429b3c291879afee64e5b Mon Sep 17 00:00:00 2001 From: Andrea Settimi Date: Thu, 13 Jun 2024 14:03:16 +0200 Subject: [PATCH] WIP-MERGE: cleaning from merge diffcheck joint detector --- CMakeLists.txt | 49 ++++++++++++++++++++++------ deps/eigen | 2 +- deps/pybind11 | 2 +- tests/entry_test.cc | 17 ++++++++++ tests/unit_tests/DFPointCloudTest.cc | 21 ++++++++++++ 5 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 tests/entry_test.cc create mode 100644 tests/unit_tests/DFPointCloudTest.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 431b56d9..6802e8f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,15 +115,6 @@ target_include_directories(${APP_NAME_EXE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ) -#-------------------------------------------------------------------------- -# Tests -#-------------------------------------------------------------------------- - -# include(CTest) -# enable_testing() - -# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests/global_registrations) - #-------------------------------------------------------------------------- # pybind11 #-------------------------------------------------------------------------- @@ -167,4 +158,42 @@ if (BUILD_PYTHON_MODULE) ) endforeach() -endif() \ No newline at end of file +endif() + +#-------------------------------------------------------------------------- +# Tests +#-------------------------------------------------------------------------- + +# include(CTest) +# enable_testing() +# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/googletest) +# set(TESTS_OUT_DIR ${CMAKE_BINARY_DIR}/tests/) + + +# # Unit testing ------------------------------------------------------------ +# set(UNIT_TESTS unit_tests) +# add_executable(${UNIT_TESTS} tests/unit_tests/DFPointCloudTest.cc) +# set_target_properties(${UNIT_TESTS} PROPERTIES +# RUNTIME_OUTPUT_DIRECTORY ${TESTS_OUT_DIR} +# ) + +# target_link_libraries(${UNIT_TESTS} gtest gtest_main) +# target_link_libraries(${UNIT_TESTS} ${SHARED_LIB_NAME}) + +# add_test(NAME ${UNIT_TESTS} COMMAND ${UNIT_TESTS}) + +# Integration testing ----------------------------------------------------- +# Component testing ------------------------------------------------------- +# etc --------------------------------------------------------------------- + +# # TODO: a better way to copy the dlls to the tests directory for the tests +# # get all the files -dlls in the bin directory and copy them one by one to tests dir +# file(GLOB files ${CMAKE_BINARY_DIR}/bin/Release/*.dll) +# foreach(file ${files}) +# message(STATUS "Copying ${file} to ${TESTS_OUT_DIR}") +# add_custom_command(TARGET ${UNIT_TESTS} POST_BUILD +# COMMAND ${CMAKE_COMMAND} -E copy +# ${file} +# ${TESTS_OUT_DIR}/Release +# ) +# endforeach() \ No newline at end of file diff --git a/deps/eigen b/deps/eigen index 27f81762..02bcf9b5 160000 --- a/deps/eigen +++ b/deps/eigen @@ -1 +1 @@ -Subproject commit 27f8176254a6e84400db662a62f1825cc5c65bc0 +Subproject commit 02bcf9b5918d46016bc88e5e9abebb6caa5a80b7 diff --git a/deps/pybind11 b/deps/pybind11 index 1a0ff405..ab955f15 160000 --- a/deps/pybind11 +++ b/deps/pybind11 @@ -1 +1 @@ -Subproject commit 1a0ff405498b6aac4b57cf0d95670010e5e37973 +Subproject commit ab955f158c0f34320d0e65048459a6495f62978e diff --git a/tests/entry_test.cc b/tests/entry_test.cc new file mode 100644 index 00000000..e6dd32ce --- /dev/null +++ b/tests/entry_test.cc @@ -0,0 +1,17 @@ +#include + +// Function to test +int add(int a, int b) { + return a + b; +} + +// Test case +TEST(AddTest, HandlesPositiveInput) { + EXPECT_EQ(6, add(2, 4)); +} + +// Main function +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/tests/unit_tests/DFPointCloudTest.cc b/tests/unit_tests/DFPointCloudTest.cc new file mode 100644 index 00000000..8e552928 --- /dev/null +++ b/tests/unit_tests/DFPointCloudTest.cc @@ -0,0 +1,21 @@ +#include +#include "diffCheck.hh" + + +TEST(DFPointCloudTest, TestConstructor) { + std::vector points = {Eigen::Vector3d(1, 2, 3)}; + std::vector colors = {Eigen::Vector3d(255, 255, 255)}; + std::vector normals = {Eigen::Vector3d(0, 0, 1)}; + + diffCheck::geometry::DFPointCloud dfPointCloud(points, colors, normals); + + // Verify that the points, colors, and normals are set correctly + EXPECT_EQ(dfPointCloud.Points[0], points[0]); + EXPECT_EQ(dfPointCloud.Colors[0], colors[0]); + EXPECT_EQ(dfPointCloud.Normals[0], normals[0]); +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file