reformat unittests.

This commit is contained in:
Kim Kulling
2020-03-22 12:13:09 +01:00
parent edc73552cd
commit 68a9fa2df3
77 changed files with 2555 additions and 1632 deletions
+37 -53
View File
@@ -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,
@@ -42,8 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "UnitTestPCH.h"
#include <assimp/types.h>
#include <assimp/mesh.h>
#include <assimp/types.h>
#include "Common/VertexTriangleAdjacency.h"
@@ -52,12 +50,11 @@ using namespace Assimp;
class VTAdjacencyTest : public ::testing::Test {
protected:
void checkMesh(const aiMesh& mesh);
void checkMesh(const aiMesh &mesh);
};
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, largeRandomDataSet)
{
TEST_F(VTAdjacencyTest, largeRandomDataSet) {
// build a test mesh with randomized input data
// *******************************************************************************
aiMesh mesh;
@@ -67,27 +64,26 @@ TEST_F(VTAdjacencyTest, largeRandomDataSet)
mesh.mFaces = new aiFace[600];
unsigned int iCurrent = 0;
for (unsigned int i = 0; i < 600;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int i = 0; i < 600; ++i) {
aiFace &face = mesh.mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
if (499 == iCurrent)iCurrent = 0;
if (499 == iCurrent) iCurrent = 0;
face.mIndices[0] = iCurrent++;
while(face.mIndices[0] == ( face.mIndices[1] = (unsigned int)(((float)rand()/RAND_MAX)*499)));
while(face.mIndices[0] == ( face.mIndices[2] = (unsigned int)(((float)rand()/RAND_MAX)*499)) ||
face.mIndices[1] == face.mIndices[2]);
while (face.mIndices[0] == (face.mIndices[1] = (unsigned int)(((float)rand() / RAND_MAX) * 499)))
;
while (face.mIndices[0] == (face.mIndices[2] = (unsigned int)(((float)rand() / RAND_MAX) * 499)) ||
face.mIndices[1] == face.mIndices[2])
;
}
checkMesh(mesh);
}
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, smallDataSet)
{
TEST_F(VTAdjacencyTest, smallDataSet) {
// build a test mesh - this one is extremely small
// *******************************************************************************
@@ -120,8 +116,7 @@ TEST_F(VTAdjacencyTest, smallDataSet)
}
// ------------------------------------------------------------------------------------------------
TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
{
TEST_F(VTAdjacencyTest, unreferencedVerticesSet) {
// build a test mesh which does not reference all vertices
// *******************************************************************************
aiMesh mesh;
@@ -131,60 +126,53 @@ TEST_F(VTAdjacencyTest, unreferencedVerticesSet)
mesh.mFaces = new aiFace[600];
unsigned int iCurrent = 0;
for (unsigned int i = 0; i < 600;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int i = 0; i < 600; ++i) {
aiFace &face = mesh.mFaces[i];
face.mNumIndices = 3;
face.mIndices = new unsigned int[3];
if (499 == iCurrent)iCurrent = 0;
if (499 == iCurrent) iCurrent = 0;
face.mIndices[0] = iCurrent++;
if (499 == iCurrent)iCurrent = 0;
if (499 == iCurrent) iCurrent = 0;
face.mIndices[1] = iCurrent++;
if (499 == iCurrent)iCurrent = 0;
if (499 == iCurrent) iCurrent = 0;
face.mIndices[2] = iCurrent++;
if (rand() > RAND_MAX/2 && face.mIndices[0])
{
if (rand() > RAND_MAX / 2 && face.mIndices[0]) {
face.mIndices[0]--;
}
else if (face.mIndices[1]) face.mIndices[1]--;
} else if (face.mIndices[1])
face.mIndices[1]--;
}
checkMesh(mesh);
}
// ------------------------------------------------------------------------------------------------
void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
{
VertexTriangleAdjacency adj(mesh.mFaces,mesh.mNumFaces,mesh.mNumVertices,true);
void VTAdjacencyTest::checkMesh(const aiMesh &mesh) {
VertexTriangleAdjacency adj(mesh.mFaces, mesh.mNumFaces, mesh.mNumVertices, true);
unsigned int* const piNum = adj.mLiveTriangles;
unsigned int *const piNum = adj.mLiveTriangles;
// check the primary adjacency table and check whether all faces
// are contained in the list
unsigned int maxOfs = 0;
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3 ;++qq)
{
for (unsigned int i = 0; i < mesh.mNumFaces; ++i) {
aiFace &face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3; ++qq) {
const unsigned int idx = face.mIndices[qq];
const unsigned int num = piNum[idx];
// go to this offset
const unsigned int ofs = adj.mOffsetTable[idx];
maxOfs = std::max(ofs+num,maxOfs);
unsigned int* pi = &adj.mAdjacencyTable[ofs];
maxOfs = std::max(ofs + num, maxOfs);
unsigned int *pi = &adj.mAdjacencyTable[ofs];
// and search for us ...
unsigned int tt = 0;
for (; tt < num;++tt,++pi)
{
if (i == *pi)
{
for (; tt < num; ++tt, ++pi) {
if (i == *pi) {
// mask our entry in the table. Finally all entries should be masked
*pi = 0xffffffff;
@@ -198,18 +186,15 @@ void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
}
// now check whether there are invalid faces
const unsigned int* pi = adj.mAdjacencyTable;
for (unsigned int i = 0; i < maxOfs;++i,++pi)
{
const unsigned int *pi = adj.mAdjacencyTable;
for (unsigned int i = 0; i < maxOfs; ++i, ++pi) {
EXPECT_EQ(0xffffffff, *pi);
}
// check the numTrianglesPerVertex table
for (unsigned int i = 0; i < mesh.mNumFaces;++i)
{
aiFace& face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3 ;++qq)
{
for (unsigned int i = 0; i < mesh.mNumFaces; ++i) {
aiFace &face = mesh.mFaces[i];
for (unsigned int qq = 0; qq < 3; ++qq) {
const unsigned int idx = face.mIndices[qq];
// we should not reach 0 here ...
@@ -219,8 +204,7 @@ void VTAdjacencyTest::checkMesh(const aiMesh& mesh)
}
// check whether we reached 0 in all entries
for (unsigned int i = 0; i < mesh.mNumVertices;++i)
{
for (unsigned int i = 0; i < mesh.mNumVertices; ++i) {
EXPECT_FALSE(piNum[i]);
}
}