reformat unittests.
This commit is contained in:
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -43,19 +41,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "UnitTestPCH.h"
|
||||
|
||||
#include <assimp/cexport.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
class ColladaExportCamera : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override{
|
||||
void SetUp() override {
|
||||
ex = new Assimp::Exporter();
|
||||
im = new Assimp::Importer();
|
||||
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -66,53 +63,52 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
Assimp::Exporter* ex;
|
||||
Assimp::Importer* im;
|
||||
Assimp::Exporter *ex;
|
||||
Assimp::Importer *im;
|
||||
};
|
||||
|
||||
TEST_F(ColladaExportCamera, testExportCamera) {
|
||||
const char* file = "cameraExp.dae";
|
||||
const char *file = "cameraExp.dae";
|
||||
|
||||
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE( nullptr, pTest );
|
||||
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(nullptr, pTest);
|
||||
ASSERT_TRUE(pTest->HasCameras());
|
||||
|
||||
|
||||
EXPECT_EQ( AI_SUCCESS, ex->Export(pTest,"collada",file));
|
||||
const unsigned int origNumCams( pTest->mNumCameras );
|
||||
std::unique_ptr<float[]> origFOV( new float[ origNumCams ] );
|
||||
std::unique_ptr<float[]> orifClipPlaneNear( new float[ origNumCams ] );
|
||||
std::unique_ptr<float[]> orifClipPlaneFar( new float[ origNumCams ] );
|
||||
std::unique_ptr<aiString[]> names( new aiString[ origNumCams ] );
|
||||
std::unique_ptr<aiVector3D[]> pos( new aiVector3D[ origNumCams ] );
|
||||
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
|
||||
const unsigned int origNumCams(pTest->mNumCameras);
|
||||
std::unique_ptr<float[]> origFOV(new float[origNumCams]);
|
||||
std::unique_ptr<float[]> orifClipPlaneNear(new float[origNumCams]);
|
||||
std::unique_ptr<float[]> orifClipPlaneFar(new float[origNumCams]);
|
||||
std::unique_ptr<aiString[]> names(new aiString[origNumCams]);
|
||||
std::unique_ptr<aiVector3D[]> pos(new aiVector3D[origNumCams]);
|
||||
for (size_t i = 0; i < origNumCams; i++) {
|
||||
const aiCamera *orig = pTest->mCameras[ i ];
|
||||
ASSERT_NE(nullptr, orig );
|
||||
const aiCamera *orig = pTest->mCameras[i];
|
||||
ASSERT_NE(nullptr, orig);
|
||||
|
||||
origFOV[ i ] = orig->mHorizontalFOV;
|
||||
orifClipPlaneNear[ i ] = orig->mClipPlaneNear;
|
||||
orifClipPlaneFar[ i ] = orig->mClipPlaneFar;
|
||||
names[ i ] = orig->mName;
|
||||
pos[ 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, aiProcess_ValidateDataStructure);
|
||||
const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
|
||||
|
||||
ASSERT_NE(nullptr, imported );
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
EXPECT_TRUE( imported->HasCameras() );
|
||||
EXPECT_EQ( origNumCams, imported->mNumCameras );
|
||||
EXPECT_TRUE(imported->HasCameras());
|
||||
EXPECT_EQ(origNumCams, imported->mNumCameras);
|
||||
|
||||
for(size_t i=0; i< imported->mNumCameras;i++){
|
||||
const aiCamera *read = imported->mCameras[ i ];
|
||||
for (size_t i = 0; i < imported->mNumCameras; i++) {
|
||||
const aiCamera *read = imported->mCameras[i];
|
||||
|
||||
EXPECT_TRUE( names[ i ] == read->mName );
|
||||
EXPECT_NEAR( origFOV[ i ],read->mHorizontalFOV, 0.0001f );
|
||||
EXPECT_FLOAT_EQ( orifClipPlaneNear[ i ], read->mClipPlaneNear);
|
||||
EXPECT_FLOAT_EQ( orifClipPlaneFar[ i ], read->mClipPlaneFar);
|
||||
EXPECT_TRUE(names[i] == read->mName);
|
||||
EXPECT_NEAR(origFOV[i], read->mHorizontalFOV, 0.0001f);
|
||||
EXPECT_FLOAT_EQ(orifClipPlaneNear[i], read->mClipPlaneNear);
|
||||
EXPECT_FLOAT_EQ(orifClipPlaneFar[i], read->mClipPlaneFar);
|
||||
|
||||
EXPECT_FLOAT_EQ( pos[ i ].x,read->mPosition.x);
|
||||
EXPECT_FLOAT_EQ( pos[ i ].y,read->mPosition.y);
|
||||
EXPECT_FLOAT_EQ( pos[ i ].z,read->mPosition.z);
|
||||
EXPECT_FLOAT_EQ(pos[i].x, read->mPosition.x);
|
||||
EXPECT_FLOAT_EQ(pos[i].y, read->mPosition.y);
|
||||
EXPECT_FLOAT_EQ(pos[i].z, read->mPosition.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user