Skip to content

Commit aa373fc

Browse files
author
Ioan Sucan
committed
fix tests
1 parent d51e649 commit aa373fc

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ target_link_libraries(${PROJECT_NAME} ${ASSIMP_LIBRARIES} ${QHULL_LIBRARIES} ${c
6565

6666

6767
# Unit tests
68-
catkin_add_gtest(test_point_inclusion test/test_point_inclusion.cpp)
69-
target_link_libraries(test_point_inclusion ${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES})
70-
68+
add_subdirectory(test)
7169

7270
install(TARGETS ${PROJECT_NAME}
7371
ARCHIVE DESTINATION lib

test/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources" TEST_RESOURCES_DIR)
2+
if(WIN32)
3+
# Correct directory separator for Windows
4+
string(REPLACE "\\" "\\\\" TEST_RESOURCES_DIR "${TEST_RESOURCES_DIR}")
5+
endif(WIN32)
6+
configure_file("${TEST_RESOURCES_DIR}/config.h.in" "${TEST_RESOURCES_DIR}/config.h")
7+
include_directories(.)
8+
catkin_add_gtest(test_point_inclusion test_point_inclusion.cpp)
9+
target_link_libraries(test_point_inclusion ${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES})

test/resources/config.h.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifndef GEOMETRIC_SHAPES_TEST_RESOURCES_CONFIG_
2+
#define GEOMETRIC_SHAPES_TEST_RESOURCES_CONFIG_
3+
4+
#define TEST_RESOURCES_DIR "@TEST_RESOURCES_DIR@"
5+
#endif

test/test_point_inclusion.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <geometric_shapes/body_operations.h>
4040
#include <boost/filesystem.hpp>
4141
#include <gtest/gtest.h>
42-
42+
#include "resources/config.h"
4343

4444
TEST(SpherePointContainment, SimpleInside)
4545
{
@@ -259,7 +259,7 @@ TEST(CylinderPointContainment, CylinderPadding)
259259

260260
TEST(MeshPointContainment, Pr2Forearm)
261261
{
262-
shapes::Mesh *ms = shapes::createMeshFromResource("file://" + (boost::filesystem::current_path() / "test/resources/forearm_roll.stl").string());
262+
shapes::Mesh *ms = shapes::createMeshFromResource("file://" + (boost::filesystem::path(TEST_RESOURCES_DIR) / "/forearm_roll.stl").string());
263263
EXPECT_EQ(ms->vertex_count, 2338);
264264
bodies::Body *m = new bodies::ConvexMesh(ms);
265265
Eigen::Affine3d t(Eigen::Affine3d::Identity());

0 commit comments

Comments
 (0)