瀏覽代碼

anim-header: fix some review findings + andd base tests.

Kim Kulling 8 年之前
父節點
當前提交
1939aca31c
共有 2 個文件被更改,包括 47 次插入13 次删除
  1. 15 13
      include/assimp/anim.h
  2. 32 0
      test/unit/utAnim.cpp

+ 15 - 13
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

+ 32 - 0
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 );
 }