diff --git a/test/unit/UnitTestPCH.h b/test/unit/UnitTestPCH.h index 9cc4df3a6..890bedd0c 100644 --- a/test/unit/UnitTestPCH.h +++ b/test/unit/UnitTestPCH.h @@ -7,31 +7,9 @@ // We need to be sure to have the same STL settings as Assimp #include - #include - +#include #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 325bc6052..1d03b62a1 100644 --- a/test/unit/utColladaExportCamera.cpp +++ b/test/unit/utColladaExportCamera.cpp @@ -79,21 +79,20 @@ TEST_F(ColladaExportCamera, testExportCamera) EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file)); const unsigned int origNumCams( pTest->mNumCameras ); - //float *origFOV = new float[ origNumCams ]; - TDataArray origFOV( origNumCams ); - TDataArray orifClipPlaneNear( origNumCams ); - TDataArray orifClipPlaneFar( origNumCams ); - TDataArray names( origNumCams ); - TDataArray pos( origNumCams ); + std::unique_ptr origFOV( new float[ origNumCams ] ); + std::unique_ptr orifClipPlaneNear( new float[ origNumCams ] ); + std::unique_ptr orifClipPlaneFar( new float[ origNumCams ] ); + std::unique_ptr names( new aiString[ origNumCams ] ); + std::unique_ptr pos( new aiVector3D[ origNumCams ] ); for (size_t i = 0; i < origNumCams; i++) { const aiCamera *orig = pTest->mCameras[ i ]; 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; + origFOV[ i ] = orig->mHorizontalFOV; + orifClipPlaneNear[ i ] = orig->mClipPlaneNear; + orifClipPlaneFar[ i ] = orig->mClipPlaneFar; + names[ i ] = orig->mName; + pos[ i ] = orig->mPosition; } const aiScene* imported = im->ReadFile(file,0); diff --git a/test/unit/utColladaExportLight.cpp b/test/unit/utColladaExportLight.cpp index 28548f636..2c502b987 100644 --- a/test/unit/utColladaExportLight.cpp +++ b/test/unit/utColladaExportLight.cpp @@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class ColladaExportLight : public ::testing::Test { public: - virtual void SetUp() { ex = new Assimp::Exporter(); @@ -63,8 +62,6 @@ public: } protected: - - Assimp::Exporter* ex; Assimp::Importer* im; }; @@ -79,7 +76,7 @@ TEST_F(ColladaExportLight, testExportLight) ASSERT_TRUE(pTest->HasLights()); const unsigned int origNumLights( pTest->mNumLights ); - aiLight *origLights = new aiLight[ origNumLights ]; + std::unique_ptr origLights( new aiLight[ origNumLights ] ); std::vector origNames; for (size_t i = 0; i < origNumLights; i++) { origNames.push_back( pTest->mLights[ i ]->mName.C_Str() ); @@ -94,14 +91,11 @@ TEST_F(ColladaExportLight, testExportLight) EXPECT_TRUE(imported->HasLights()); EXPECT_EQ( origNumLights,imported->mNumLights ); - for(size_t i=0; i< origNumLights; i++){ - + for(size_t i=0; i< origNumLights; i++) { const aiLight *orig = &origLights[ i ]; - const aiLight *read = imported->mLights[i]; - - EXPECT_EQ(0,strncmp(origNames[ i ].c_str(),read->mName.C_Str(), origNames[ i ].size() ) ); - EXPECT_EQ(orig->mType,read->mType); + EXPECT_EQ( 0,strncmp(origNames[ i ].c_str(),read->mName.C_Str(), origNames[ i ].size() ) ); + EXPECT_EQ( orig->mType,read->mType); EXPECT_FLOAT_EQ(orig->mAttenuationConstant,read->mAttenuationConstant); EXPECT_FLOAT_EQ(orig->mAttenuationLinear,read->mAttenuationLinear); EXPECT_NEAR(orig->mAttenuationQuadratic,read->mAttenuationQuadratic, 0.001f); @@ -121,12 +115,6 @@ TEST_F(ColladaExportLight, testExportLight) EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001); EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001); } - - delete [] origLights; - } - -#endif - - +#endif // ASSIMP_BUILD_NO_EXPORT diff --git a/test/unit/utFindDegenerates.cpp b/test/unit/utFindDegenerates.cpp index ccd4d5ab3..8df160107 100644 --- a/test/unit/utFindDegenerates.cpp +++ b/test/unit/utFindDegenerates.cpp @@ -46,15 +46,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace std; using namespace Assimp; -class FindDegeneratesProcessTest : public ::testing::Test -{ +class FindDegeneratesProcessTest : public ::testing::Test { public: - virtual void SetUp(); virtual void TearDown(); protected: - aiMesh* mesh; FindDegeneratesProcess* process; }; diff --git a/test/unit/utFindInvalidData.cpp b/test/unit/utFindInvalidData.cpp index c99d53e09..0fe291c80 100644 --- a/test/unit/utFindInvalidData.cpp +++ b/test/unit/utFindInvalidData.cpp @@ -50,12 +50,10 @@ using namespace Assimp; class FindInvalidDataProcessTest : public ::testing::Test { public: - virtual void SetUp(); virtual void TearDown(); protected: - aiMesh* pcMesh; FindInvalidDataProcess* piProcess; }; diff --git a/test/unit/utGenNormals.cpp b/test/unit/utGenNormals.cpp index 21ca784df..b108242da 100644 --- a/test/unit/utGenNormals.cpp +++ b/test/unit/utGenNormals.cpp @@ -41,14 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "UnitTestPCH.h" #include - -using namespace std; -using namespace Assimp; +using namespace ::std; +using namespace ::Assimp; class GenNormalsTest : public ::testing::Test { public: - virtual void SetUp(); virtual void TearDown(); diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index a56b64a0c..db71f8206 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -46,15 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -using namespace std; -using namespace Assimp; +using namespace ::std; +using namespace ::Assimp; class ImporterTest : public ::testing::Test { public: - - virtual void SetUp() { pImp = new Importer(); } - virtual void TearDown() { delete pImp; } + virtual void SetUp() { + pImp = new Importer(); + } + + virtual void TearDown() { + delete pImp; + } protected: Importer* pImp; @@ -109,7 +113,6 @@ static unsigned char InputData_abRawBlock[1310] = { #define AIUT_DEF_ERROR_TEXT "sorry, this is a test" - static const aiImporterDesc desc = { "UNIT TEST - IMPORTER", "", @@ -123,11 +126,9 @@ static const aiImporterDesc desc = { "apple mac linux windows" }; - class TestPlugin : public BaseImporter { public: - virtual bool CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*test*/) const { diff --git a/test/unit/utJoinVertices.cpp b/test/unit/utJoinVertices.cpp index 66e37487c..f9ad2cc98 100644 --- a/test/unit/utJoinVertices.cpp +++ b/test/unit/utJoinVertices.cpp @@ -50,12 +50,10 @@ using namespace Assimp; class JoinVerticesTest : public ::testing::Test { public: - virtual void SetUp(); virtual void TearDown(); protected: - JoinVerticesProcess* piProcess; aiMesh* pcMesh; };