Tudat/Astrodynamics/BasicAstrodynamics/UnitTests/unitTestAccelerationModel.cpp
//! Test whether DerivedAccelerationModel (acceleration data type=Eigen::Vector1i) functions
//! correctly.
Test whether DerivedAccelerationModel (acceleration data type=Eigen::Vector1i) functions
correctly.
Test whether DerivedAccelerationModel ( acceleration data type = Eigen :: Vector1i ) functions correctly .
BOOST_AUTO_TEST_CASE( test_derived1iAccelerationModel )
{
    typedef TestBody< 1, int > TestBody1i;
    typedef std::shared_ptr< TestBody1i > TestBody1iPointer;
    typedef AccelerationModel< int > AccelerationModel1i;
    typedef std::shared_ptr< AccelerationModel1i > AccelerationModel1iPointer;
    typedef DerivedAccelerationModel< int, int, int > DerivedAccelerationModel1i;
    TestBody1iPointer body = std::make_shared< TestBody1i >( Eigen::Vector2i( 20, 1 ), 2 );
    AccelerationModel1iPointer accelerationModeli1
            = std::make_shared< DerivedAccelerationModel1i >(
                std::bind( ( &TestBody1i::getCurrentPosition ), body ),
                std::bind( ( &TestBody1i::getCurrentTime ), body ) );
    std::vector< int > computedAccelerations( 3 );
    computedAccelerations.at( 0 ) = accelerationModeli1->getAcceleration( );
    body->setCurrentTimeAndState( -3, Eigen::Vector2i( 90, 3 ) );
    accelerationModeli1->updateMembers( );
    computedAccelerations.at( 1 ) = accelerationModeli1->getAcceleration( );
    body->setCurrentTimeAndState( 4, Eigen::Vector2i( 16, -4 ) );
    computedAccelerations.at( 2 ) = updateAndGetAcceleration( accelerationModeli1 );
    const std::vector< int > expectedAccelerations = { 20 / ( 2 * 2 ), 90 / ( -3 * -3 ), 16 / ( 4 * 4 ) };
    for ( unsigned int i = 0; i < computedAccelerations.size( ); i++ )
    {
        BOOST_CHECK_EQUAL( computedAccelerations.at( i ), expectedAccelerations.at( i ) );
    }
}
BOOST_AUTO_TEST_CASE ( test_derived1iAccelerationModel ) { typedef TestBody < 1 , int > TestBody1i ; typedef std :: shared_ptr < TestBody1i > TestBody1iPointer ; typedef AccelerationModel < int > AccelerationModel1i ; typedef std :: shared_ptr < AccelerationModel1i > AccelerationModel1iPointer ; typedef DerivedAccelerationModel < int , int , int > DerivedAccelerationModel1i ; TestBody1iPointer body = std :: make_shared < TestBody1i > ( Eigen :: Vector2i ( 20 , 1 ) , 2 ) ; AccelerationModel1iPointer accelerationModeli1 = std :: make_shared < DerivedAccelerationModel1i > ( std :: bind ( ( & TestBody1i :: getCurrentPosition ) , body ) , std :: bind ( ( & TestBody1i :: getCurrentTime ) , body ) ) ; std :: vector < int > computedAccelerations ( 3 ) ; computedAccelerations . at ( 0 ) = accelerationModeli1 -> getAcceleration ( ) ; body -> setCurrentTimeAndState ( -3 , Eigen :: Vector2i ( 90 , 3 ) ) ; accelerationModeli1 -> updateMembers ( ) ; computedAccelerations . at ( 1 ) = accelerationModeli1 -> getAcceleration ( ) ; body -> setCurrentTimeAndState ( 4 , Eigen :: Vector2i ( 16 , -4 ) ) ; computedAccelerations . at ( 2 ) = updateAndGetAcceleration ( accelerationModeli1 ) ; const std :: vector < int > expectedAccelerations = { 20 / ( 2 * 2 ) , 90 / ( -3 * -3 ) , 16 / ( 4 * 4 ) } ; for ( unsigned int i = 0 ; i < computedAccelerations . size ( ) ; i ++ ) { BOOST_CHECK_EQUAL ( computedAccelerations . at ( i ) , expectedAccelerations . at ( i ) ) ; } }
Test whether DerivedAccelerationModel (acceleration data type=Eigen::Vector1i) functions
correctly.
Test whether DerivedAccelerationModel ( acceleration data type = Eigen :: Vector1i ) functions correctly .
// Shortcuts. // Create body with initial state and time. // Create acceleration model using DerivedAccelerationModel class, and pass pointers to // functions in body. // Declare container of computed accelerations. // Get scalar acceleration before members are updated. // Update time and state. // Update acceleration model members. // Get scalar acceleration, now after members have been updated. // Update time and state. // Update and get scalar acceleration with single function. // Set expected accelerations. // Check that the acceleration vectors before and after the update match expected values.