Replace cppunit with the googletest framework

The GTest framework has a more active support base, and natively
supports CMake. Introduce it as an external dependency (using CMake's
ExternalProject_Add), replacing cppunit and porting the associated unit
tests.
This commit is contained in:
Jared Duke
2014-09-07 16:52:03 -07:00
parent a51a0b36f0
commit 66e608a393
272 changed files with 914 additions and 81855 deletions

View File

@@ -1,11 +1,28 @@
#include "UnitTestPCH.h"
#include "utRemoveComponent.h"
#include <assimp/scene.h>
#include <RemoveVCProcess.h>
#include <MaterialSystem.h>
CPPUNIT_TEST_SUITE_REGISTRATION (RemoveVCProcessTest);
using namespace std;
using namespace Assimp;
void RemoveVCProcessTest :: setUp (void)
class RemoveVCProcessTest : public ::testing::Test
{
public:
virtual void SetUp();
virtual void TearDown();
protected:
RemoveVCProcess* piProcess;
aiScene* pScene;
};
// ------------------------------------------------------------------------------------------------
void RemoveVCProcessTest::SetUp()
{
// construct the process
piProcess = new RemoveVCProcess();
@@ -50,100 +67,122 @@ void RemoveVCProcessTest :: setUp (void)
// COMPILE TEST: aiMaterial may no add any extra members,
// so we don't need a virtual destructor
char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1];
check[0] = 0;
check[0] = 0;
}
void RemoveVCProcessTest :: tearDown (void)
// ------------------------------------------------------------------------------------------------
void RemoveVCProcessTest::TearDown()
{
delete pScene;
delete piProcess;
}
void RemoveVCProcessTest::testMeshRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshRemove)
{
piProcess->SetDeleteFlags(aiComponent_MESHES);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(NULL == pScene->mMeshes && 0 == pScene->mNumMeshes);
CPPUNIT_ASSERT(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
EXPECT_TRUE(NULL == pScene->mMeshes);
EXPECT_EQ(0U, pScene->mNumMeshes);
EXPECT_TRUE(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
}
void RemoveVCProcessTest::testAnimRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testAnimRemove)
{
piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(NULL == pScene->mAnimations && 0 == pScene->mNumAnimations);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_TRUE(NULL == pScene->mAnimations);
EXPECT_EQ(0U, pScene->mNumAnimations);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testMaterialRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMaterialRemove)
{
piProcess->SetDeleteFlags(aiComponent_MATERIALS);
piProcess->Execute(pScene);
// there should be one default material now ...
CPPUNIT_ASSERT(1 == pScene->mNumMaterials &&
EXPECT_TRUE(1 == pScene->mNumMaterials &&
pScene->mMeshes[0]->mMaterialIndex == 0 &&
pScene->mMeshes[1]->mMaterialIndex == 0);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testTextureRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testTextureRemove)
{
piProcess->SetDeleteFlags(aiComponent_TEXTURES);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(NULL == pScene->mTextures && 0 == pScene->mNumTextures);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_TRUE(NULL == pScene->mTextures);
EXPECT_EQ(0U, pScene->mNumTextures);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testCameraRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testCameraRemove)
{
piProcess->SetDeleteFlags(aiComponent_CAMERAS);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(NULL == pScene->mCameras && 0 == pScene->mNumCameras);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_TRUE(NULL == pScene->mCameras);
EXPECT_EQ(0U, pScene->mNumCameras);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testLightRemove (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testLightRemove)
{
piProcess->SetDeleteFlags(aiComponent_LIGHTS);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(NULL == pScene->mLights && 0 == pScene->mNumLights);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_TRUE(NULL == pScene->mLights);
EXPECT_EQ(0U, pScene->mNumLights);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testMeshComponentsRemoveA (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveA)
{
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_TEXCOORDSn(2) | aiComponent_TEXCOORDSn(3));
piProcess->Execute(pScene);
CPPUNIT_ASSERT(pScene->mMeshes[0]->mTextureCoords[0] &&
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
!pScene->mMeshes[0]->mTextureCoords[1] &&
!pScene->mMeshes[0]->mTextureCoords[2] &&
!pScene->mMeshes[0]->mTextureCoords[3]);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testMeshComponentsRemoveB (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testMeshComponentsRemoveB)
{
piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_NORMALS);
piProcess->Execute(pScene);
CPPUNIT_ASSERT(pScene->mMeshes[0]->mTextureCoords[0] &&
EXPECT_TRUE(pScene->mMeshes[0]->mTextureCoords[0] &&
pScene->mMeshes[0]->mTextureCoords[1] &&
pScene->mMeshes[0]->mTextureCoords[2] && // shift forward ...
!pScene->mMeshes[0]->mTextureCoords[3] &&
!pScene->mMeshes[0]->mNormals);
CPPUNIT_ASSERT(pScene->mFlags == 0);
EXPECT_EQ(0U, pScene->mFlags);
}
void RemoveVCProcessTest::testRemoveEverything (void)
// ------------------------------------------------------------------------------------------------
TEST_F(RemoveVCProcessTest, testRemoveEverything)
{
piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
aiComponent_MATERIALS | aiComponent_MESHES | aiComponent_CAMERAS | aiComponent_TEXTURES);
piProcess->Execute(pScene);
EXPECT_EQ(0U, pScene->mNumAnimations);
EXPECT_EQ(0U, pScene->mNumCameras);
EXPECT_EQ(0U, pScene->mNumLights);
EXPECT_EQ(0U, pScene->mNumMeshes);
EXPECT_EQ(0U, pScene->mNumTextures);
// Only the default material should remain.
EXPECT_EQ(1U, pScene->mNumMaterials);
}