Commit b78d39b6 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Tests] add unit test for MinimumJerk

parent 28d0313e
ADD_UNIT_TEST(curves_tests Main.cpp)
ADD_UNIT_TEST(test-constant test-constant.cpp)
ADD_UNIT_TEST(test-sinusoidal test-sinusoidal.cpp)
ADD_UNIT_TEST(test-minjerk test-minjerk.cpp)
TARGET_LINK_LIBRARIES(curves_tests ${PROJECT_NAME} ${Boost_LIBRARIES})
TARGET_COMPILE_DEFINITIONS(curves_tests PRIVATE -DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/")
TARGET_LINK_LIBRARIES(test-constant ${PROJECT_NAME} ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(test-sinusoidal ${PROJECT_NAME} ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(test-minjerk ${PROJECT_NAME} ${Boost_LIBRARIES})
#define BOOST_TEST_MODULE test_minjerk
#include "curves/fwd.h"
#include "curves/polynomial.h"
#include <boost/test/included/unit_test.hpp>
using namespace curves;
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
BOOST_AUTO_TEST_CASE (without_timing){
point3_t a(1.5, -2, 3.7);
point3_t b(2, 3, -4.);
polynomial_t c = polynomial_t::MinimumJerk(a, b);
BOOST_CHECK_EQUAL(c.min(), 0.);
BOOST_CHECK_EQUAL(c.max(), 1.);
BOOST_CHECK_EQUAL(c.dim(), 3);
BOOST_CHECK_EQUAL(c.degree(), 5);
BOOST_CHECK(c(0.).isApprox(a));
BOOST_CHECK(c(1.).isApprox(b));
}
BOOST_AUTO_TEST_CASE (with_timing){
point3_t a(1.5, -2, 3.7);
point3_t b(2, 3, -4.);
polynomial_t c = polynomial_t::MinimumJerk(a, b, 1., 5.);
BOOST_CHECK_EQUAL(c.min(), 1.);
BOOST_CHECK_EQUAL(c.max(), 5.);
BOOST_CHECK_EQUAL(c.dim(), 3);
BOOST_CHECK_EQUAL(c.degree(), 5);
BOOST_CHECK(c(1.).isApprox(a));
BOOST_CHECK(c(5.).isApprox(b));
}
BOOST_AUTO_TEST_CASE (constructor_error){
pointX_t a(3);
a<<1.5, -2, 3.7;
pointX_t b(4);
b<<2, 3, -4., 5.;
BOOST_CHECK_THROW(polynomial_t::MinimumJerk(a, b);, std::invalid_argument);
point3_t a1(1.5, -2, 3.7);
point3_t b1(2, 3, -4.);
BOOST_CHECK_THROW(polynomial_t::MinimumJerk(a1, b1, 1., 0.5);, std::invalid_argument);
}
BOOST_AUTO_TEST_CASE (evaluate){
point3_t a(1.5, -2, 3.7);
point3_t b(2, 3, -4.);
polynomial_t c = polynomial_t::MinimumJerk(a, b, 0., 1.5);
BOOST_CHECK(c.derivate(0., 1).isZero());
BOOST_CHECK(c.derivate(0., 2).isZero());
BOOST_CHECK(c.derivate(1.5, 1).isZero());
BOOST_CHECK(c.derivate(1.5, 2).isZero());
BOOST_CHECK(c.derivate(1., 6).isZero());
}
BOOST_AUTO_TEST_SUITE_END()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment