diff --git a/test/unit/UnitTestPCH.h b/test/unit/UnitTestPCH.h index d3d87747f..9cc4df3a6 100644 --- a/test/unit/UnitTestPCH.h +++ b/test/unit/UnitTestPCH.h @@ -12,5 +12,26 @@ #include +template +struct TDataArray { + size_t m_numItems; + T *m_items; + + TDataArray( size_t numItems ) + : m_numItems( numItems ) + , m_items( nullptr ) { + m_items = new T[ numItems ]; + } + + ~TDataArray() { + delete [] m_items; + } + + T operator [] ( size_t index ) const { + EXPECT_TRUE( index < m_numItems ); + return m_items[ index ]; + } +}; + #undef min #undef max diff --git a/test/unit/utColladaExportCamera.cpp b/test/unit/utColladaExportCamera.cpp index cfa0ea60f..325bc6052 100644 --- a/test/unit/utColladaExportCamera.cpp +++ b/test/unit/utColladaExportCamera.cpp @@ -64,13 +64,10 @@ public: } protected: - - Assimp::Exporter* ex; Assimp::Importer* im; }; -// ------------------------------------------------------------------------------------------------ TEST_F(ColladaExportCamera, testExportCamera) { const char* file = "cameraExp.dae"; @@ -82,18 +79,21 @@ TEST_F(ColladaExportCamera, testExportCamera) EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file)); const unsigned int origNumCams( pTest->mNumCameras ); - float *origFOV = new float[ origNumCams ]; - float *orifClipPlaneNear = new float[ origNumCams ]; - float *orifClipPlaneFar = new float[ origNumCams ]; - aiString *names = new aiString[ origNumCams ]; - aiVector3D *pos = new aiVector3D[ origNumCams ]; + //float *origFOV = new float[ origNumCams ]; + TDataArray origFOV( origNumCams ); + TDataArray orifClipPlaneNear( origNumCams ); + TDataArray orifClipPlaneFar( origNumCams ); + TDataArray names( origNumCams ); + TDataArray pos( origNumCams ); for (size_t i = 0; i < origNumCams; i++) { const aiCamera *orig = pTest->mCameras[ i ]; - origFOV[ i ] = orig->mHorizontalFOV; - orifClipPlaneNear[ i ] = orig->mClipPlaneNear; - orifClipPlaneFar[ i ] = orig->mClipPlaneFar; - names[ i ] = orig->mName; - pos[ i ] = orig->mPosition; + ASSERT_TRUE( orig != nullptr ); + + origFOV.m_items[ i ] = orig->mHorizontalFOV; + orifClipPlaneNear.m_items[ i ] = orig->mClipPlaneNear; + orifClipPlaneFar.m_items[ i ] = orig->mClipPlaneFar; + names.m_items[ i ] = orig->mName; + pos.m_items[ i ] = orig->mPosition; } const aiScene* imported = im->ReadFile(file,0); @@ -114,15 +114,8 @@ TEST_F(ColladaExportCamera, testExportCamera) EXPECT_FLOAT_EQ( pos[ i ].y,read->mPosition.y); EXPECT_FLOAT_EQ( pos[ i ].z,read->mPosition.z); } - - delete [] origFOV; - delete [] orifClipPlaneNear; - delete [] orifClipPlaneFar; - delete [] names; - delete [] pos; - } -#endif +#endif // ASSIMP_BUILD_NO_EXPORT