Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test for joint creation.
  • Loading branch information
Antonio El Khoury committed Oct 11, 2012
1 parent f55b12f commit de15c7e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -48,6 +48,6 @@ ADD_ROSPACK_DEPENDENCY("rbdl")
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})

ADD_SUBDIRECTORY(src)
# ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tests)

SETUP_PROJECT_FINALIZE()
29 changes: 29 additions & 0 deletions tests/CMakeLists.txt
@@ -0,0 +1,29 @@
# Add Boost path to include directories.
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

# Make Boost.Test generates the main function in test cases.
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)

# ADD_TESTCASE(NAME)
# ------------------------
#
# Define a test named `NAME'.
#
# This macro will create a binary from `NAME.cc', link it against
# Boost and add it to the test suite.
#
MACRO(ADD_TESTCASE NAME)
ADD_EXECUTABLE(${NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.cc)
ADD_TEST(${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/${NAME})

PKG_CONFIG_USE_DEPENDENCY(${NAME} abstract-robot-dynamics)
ROSPACK_USE_DEPENDENCY(${NAME} rbdl)

# Link against package library.
TARGET_LINK_LIBRARIES(${NAME}
${Boost_LIBRARIES}
${PROJECT_NAME})
ENDMACRO(ADD_TESTCASE)

# Generated tests.
ADD_TESTCASE(create-joint)
54 changes: 54 additions & 0 deletions tests/create-joint.cc
@@ -0,0 +1,54 @@
// Copyright (C) 2012 by Antonio El Khoury.
//
// This file is part of the ard-rbdl.
//
// ard-rbdl is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// ard-rbdl is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with ard-rbdl. If not, see
// <http://www.gnu.org/licenses/>.

#define BOOST_TEST_MODULE create-joint

#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>

#include <ard/rbdl/tools/util.hh>
#include <ard/rbdl/model/joint.hh>
#include <ard/rbdl/model/robot-dynamics-object-factory.hh>

BOOST_AUTO_TEST_CASE (create_joint)
{
using namespace ard::rbdl;

// Create joint with defaut constructor.
ardJointShPtr_t joint (new joint_t ());

BOOST_CHECK_EQUAL (!joint, 0);

// Create joints from factory.
RobotDynamicsObjectFactory factory = RobotDynamicsObjectFactory ();
matrix4d mat;
mat.setIdentity ();

ardJointShPtr_t jointRotation = factory.createJointRotation (mat);
ardJointShPtr_t jointTranslation = factory.createJointTranslation (mat);

BOOST_CHECK_EQUAL (!jointRotation, 0);
BOOST_CHECK_EQUAL (!jointTranslation, 0);

// Create joint with copy constructor.
jointShPtr_t jointRotationDynCast;
getPtrFromBase (jointRotationDynCast, jointRotation);
ardJointShPtr_t jointRotationCopy (new joint_t (*jointRotationDynCast));

BOOST_CHECK_EQUAL (!jointRotationCopy, 0);
}

0 comments on commit de15c7e

Please sign in to comment.