From 1939aca31c3dbd319939eabc2dd47ca0a097bf73 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 23 Nov 2016 22:00:52 +0100 Subject: [PATCH] anim-header: fix some review findings + andd base tests. --- include/assimp/anim.h | 28 +++++++++++++++------------- test/unit/utAnim.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/include/assimp/anim.h b/include/assimp/anim.h index f2ace4416..2a0b0e06e 100644 --- a/include/assimp/anim.h +++ b/include/assimp/anim.h @@ -291,8 +291,10 @@ struct aiNodeAnim { , mNumRotationKeys( 0 ) , mRotationKeys( NULL ) , mNumScalingKeys( 0 ) - , mScalingKeys( NULL ) { - mPreState = mPostState = aiAnimBehaviour_DEFAULT; + , mScalingKeys( NULL ) + , mPreState( aiAnimBehaviour_DEFAULT ) + , mPostState( aiAnimBehaviour_DEFAULT ) { + // empty } ~aiNodeAnim() { @@ -372,21 +374,20 @@ struct aiAnimation { #ifdef __cplusplus aiAnimation() - : mDuration(-1.) - , mTicksPerSecond() - , mNumChannels() - , mChannels() - , mNumMeshChannels() - , mMeshChannels() - { + : mDuration(-1.) + , mTicksPerSecond(0.) + , mNumChannels(0) + , mChannels(nullptr) + , mNumMeshChannels(0) + , mMeshChannels(nullptr) { + // empty } - ~aiAnimation() - { + ~aiAnimation() { // DO NOT REMOVE THIS ADDITIONAL CHECK - if (mNumChannels && mChannels) { + if ( mNumChannels && mChannels ) { for( unsigned int a = 0; a < mNumChannels; a++) { - delete mChannels[a]; + delete mChannels[ a ]; } delete [] mChannels; @@ -403,6 +404,7 @@ struct aiAnimation { }; #ifdef __cplusplus + } /// @brief Some C++ utilities for inter- and extrapolation diff --git a/test/unit/utAnim.cpp b/test/unit/utAnim.cpp index f2db2c251..90d6d36b3 100644 --- a/test/unit/utAnim.cpp +++ b/test/unit/utAnim.cpp @@ -72,4 +72,36 @@ TEST_F( utAnim, aiQuatKeyTest ) { aiQuatKey constrWithValuesTest( 1.0, q ); EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime ); EXPECT_EQ( q, constrWithValuesTest.mValue ); +} + +TEST_F( utAnim, aiNodeAnimTest ) { + bool ok( true ); + try { + aiNodeAnim myAnim; + EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPreState ); + EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPostState ); + } catch ( ... ) { + ok = false; + } + EXPECT_TRUE( ok ); +} + +TEST_F( utAnim, aiMeshAnimTest ) { + bool ok( true ); + try { + aiMeshAnim myMeshAnim; + } catch ( ... ) { + ok = false; + } + EXPECT_TRUE( ok ); +} + +TEST_F( utAnim, aiAnimationTest ) { + bool ok( true ); + try { + aiAnimation myAnimation; + } catch ( ... ) { + ok = false; + } + EXPECT_TRUE( ok ); } \ No newline at end of file