Fix resource leaks in unit tests.
This commit is contained in:
@@ -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<aiLight[]> origLights( new aiLight[ origNumLights ] );
|
||||
std::vector<std::string> 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
|
||||
|
||||
Reference in New Issue
Block a user