new stuff

This commit is contained in:
Tarion 2026-07-03 03:41:25 +02:00
parent 8998bc3936
commit 64c8492e5c
No known key found for this signature in database
6907 changed files with 3401899 additions and 0 deletions

View file

@ -0,0 +1,47 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
AbstractImportExportBase::~AbstractImportExportBase() = default;

View file

@ -0,0 +1,75 @@
/*
---------------------------------------------------------------------------
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,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#ifndef AI_ABSTRACTIMPORTEXPORTBASE_H_INC
#define AI_ABSTRACTIMPORTEXPORTBASE_H_INC
#include "UnitTestPCH.h"
// ---------------------------------------------------------------------------
/** Abstract base class to test import and export
*/
// ---------------------------------------------------------------------------
class AbstractImportExportBase : public ::testing::Test {
public:
/// @brief The class destructor.
virtual ~AbstractImportExportBase();
/// @brief The importer-test, will return true for successful import.
/// @return true for success, false for failure.
virtual bool importerTest();
/// @brief The exporter-test, will return true for successful import.
/// @return true for success, false for failure.
virtual bool exporterTest();
};
inline
bool AbstractImportExportBase::importerTest() {
return true;
}
inline
bool AbstractImportExportBase::exporterTest() {
return true;
}
#endif // AI_ABSTRACTIMPORTEXPORTBASE_H_INC

View file

@ -0,0 +1,71 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/importerdesc.h>
using namespace Assimp;
class AssimpAPITest : public ::testing::Test {
// empty
};
TEST_F( AssimpAPITest, aiGetImporterDescTest ) {
const aiImporterDesc *desc( nullptr );
desc = aiGetImporterDesc(nullptr);
EXPECT_EQ(nullptr, desc);
desc = aiGetImporterDesc( "obj" );
EXPECT_TRUE(nullptr != desc);
}
TEST_F( AssimpAPITest, aiGetLastErrorTest ) {
const char *error = aiGetErrorString();
EXPECT_NE(nullptr, error);
}
TEST_F(AssimpAPITest, aiImportFileFromMemoryTest) {
const aiScene *scene_null_buffer = aiImportFileFromMemory(nullptr, 0u, 0u, nullptr);
EXPECT_EQ(nullptr, scene_null_buffer);
char buffer[1024] = {'\0'};
const aiScene *scene_null_size = aiImportFileFromMemory(buffer, 0u, 0u, nullptr);
EXPECT_EQ(nullptr, scene_null_size);
}

View file

@ -0,0 +1,174 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "MathTest.h"
#include <array>
using namespace Assimp;
class AssimpAPITest_aiMatrix3x3 : public AssimpMathTest {
protected:
void SetUp() override {
result_c = result_cpp = aiMatrix3x3();
}
aiMatrix3x3 result_c, result_cpp;
};
TEST_F(AssimpAPITest_aiMatrix3x3, aiIdentityMatrix3Test) {
// Force a non-identity matrix.
result_c = aiMatrix3x3(0,0,0,0,0,0,0,0,0);
aiIdentityMatrix3(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromMatrix4Test) {
const auto m = random_mat4();
result_cpp = aiMatrix3x3(m);
aiMatrix3FromMatrix4(&result_c, &m);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromQuaternionTest) {
const auto q = random_quat();
result_cpp = q.GetMatrix();
aiMatrix3FromQuaternion(&result_c, &q);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualTest) {
result_c = result_cpp = random_mat3();
EXPECT_EQ(result_cpp == result_c,
(bool)aiMatrix3AreEqual(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3AreEqualEpsilonTest) {
result_c = result_cpp = random_mat3();
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
(bool)aiMatrix3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMultiplyMatrix3Test) {
const auto m = random_mat3();
result_c = result_cpp = random_mat3();
result_cpp *= m;
aiMultiplyMatrix3(&result_c, &m);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiTransposeMatrix3Test) {
result_c = result_cpp = random_mat3();
result_cpp.Transpose();
aiTransposeMatrix3(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3InverseTest) {
// Use a predetermined matrix to prevent arbitrary
// cases where it could have a null determinant.
result_c = result_cpp = aiMatrix3x3(
5, 2, 7,
4, 6, 9,
1, 8, 3);
result_cpp.Inverse();
aiMatrix3Inverse(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
inline void AI_EXPECT_REAL_EQ(ai_real val1, ai_real val2) {
#ifdef ASSIMP_DOUBLE_PRECISION
EXPECT_DOUBLE_EQ((val1), (val2));
#else
EXPECT_FLOAT_EQ((val1), (val2));
#endif
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3DeterminantTest) {
result_c = result_cpp = random_mat3();
const ai_real det_1 = result_cpp.Determinant();
const ai_real det_2 = aiMatrix3Determinant(&result_c);
AI_EXPECT_REAL_EQ(det_1, det_2);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3RotationZTest) {
const float angle(RandPI.next());
aiMatrix3x3::RotationZ(angle, result_cpp);
aiMatrix3RotationZ(&result_c, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromRotationAroundAxisTest) {
const float angle(RandPI.next());
const auto axis = random_unit_vec3();
aiMatrix3x3::Rotation(angle, axis, result_cpp);
aiMatrix3FromRotationAroundAxis(&result_c, &axis, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3TranslationTest) {
const auto axis = random_vec2();
aiMatrix3x3::Translation(axis, result_cpp);
aiMatrix3Translation(&result_c, &axis);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix3x3, aiMatrix3FromToTest) {
// Use predetermined vectors to prevent running into division by zero.
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
aiMatrix3x3::FromToMatrix(from, to, result_cpp);
aiMatrix3FromTo(&result_c, &from, &to);
EXPECT_TRUE(result_cpp.Equal(result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiMatrix3x3, operatorTest) {
std::array<ai_real, 9> value = { 1, 2, 3, 4, 5, 6, 7, 8,9};
result_cpp = aiMatrix3x3( value[0], value[1], value[2], value[3],
value[4], value[5], value[6], value[7],
value[8]);
size_t idx=0;
for (unsigned int i = 0; i < 3; ++i) {
for (unsigned int j = 0; j < 3; ++j) {
ai_real curValue = result_cpp[i][j];
EXPECT_EQ(curValue, value[idx]);
idx++;
}
}
}

View file

@ -0,0 +1,282 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "MathTest.h"
#include <assimp/MathFunctions.h>
#include <array>
using namespace Assimp;
class AssimpAPITest_aiMatrix4x4 : public AssimpMathTest {
protected:
void SetUp() override {
result_c = result_cpp = aiMatrix4x4();
}
/* Generates a predetermined transformation matrix to use
for the aiDecompose functions to prevent running into
division by zero. */
aiMatrix4x4 get_predetermined_transformation_matrix_for_decomposition() const {
aiMatrix4x4 t, r;
aiMatrix4x4::Translation(aiVector3D(14,-25,-8), t);
aiMatrix4x4::Rotation(Math::aiPi<float>() / 4.0f, aiVector3D(1).Normalize(), r);
return t * r;
}
aiMatrix4x4 result_c, result_cpp;
};
TEST_F(AssimpAPITest_aiMatrix4x4, isIdendityTest) {
aiMatrix4x4 m = aiMatrix4x4(1 + Math::getEpsilon<ai_real>(), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
const bool result = m.IsIdentity(Math::getEpsilon<ai_real>());
EXPECT_TRUE(result);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiIdentityMatrix4Test) {
// Force a non-identity matrix.
result_c = aiMatrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
aiIdentityMatrix4(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromMatrix3Test) {
aiMatrix3x3 m = random_mat3();
result_cpp = aiMatrix4x4(m);
aiMatrix4FromMatrix3(&result_c, &m);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromScalingQuaternionPositionTest) {
const aiVector3D s = random_vec3();
const aiQuaternion q = random_quat();
const aiVector3D t = random_vec3();
result_cpp = aiMatrix4x4(s, q, t);
aiMatrix4FromScalingQuaternionPosition(&result_c, &s, &q, &t);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AddTest) {
const aiMatrix4x4 temp = random_mat4();
result_c = result_cpp = random_mat4();
result_cpp = result_cpp + temp;
aiMatrix4Add(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualTest) {
result_c = result_cpp = random_mat4();
EXPECT_EQ(result_cpp == result_c,
(bool)aiMatrix4AreEqual(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4AreEqualEpsilonTest) {
result_c = result_cpp = random_mat4();
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
(bool)aiMatrix4AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMultiplyMatrix4Test) {
const auto m = random_mat4();
result_c = result_cpp = random_mat4();
result_cpp *= m;
aiMultiplyMatrix4(&result_c, &m);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiTransposeMatrix4Test) {
result_c = result_cpp = random_mat4();
result_cpp.Transpose();
aiTransposeMatrix4(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4InverseTest) {
// Use a predetermined matrix to prevent arbitrary
// cases where it could have a null determinant.
result_c = result_cpp = aiMatrix4x4(
6, 10, 15, 3,
14, 2, 12, 8,
9, 13, 5, 16,
4, 7, 11, 1);
result_cpp.Inverse();
aiMatrix4Inverse(&result_c);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DeterminantTest) {
result_c = result_cpp = random_mat4();
EXPECT_EQ(result_cpp.Determinant(),
aiMatrix4Determinant(&result_c));
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4IsIdentityTest) {
EXPECT_EQ(result_cpp.IsIdentity(),
(bool)aiMatrix4IsIdentity(&result_c));
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiDecomposeMatrixTest) {
aiVector3D scaling_c, scaling_cpp,
position_c, position_cpp;
aiQuaternion rotation_c, rotation_cpp;
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
aiDecomposeMatrix(&result_c, &scaling_c, &rotation_c, &position_c);
EXPECT_EQ(scaling_cpp, scaling_c);
EXPECT_EQ(position_cpp, position_c);
EXPECT_EQ(rotation_cpp, rotation_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingEulerAnglesPositionTest) {
aiVector3D scaling_c, scaling_cpp,
rotation_c, rotation_cpp,
position_c, position_cpp;
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
result_cpp.Decompose(scaling_cpp, rotation_cpp, position_cpp);
aiMatrix4DecomposeIntoScalingEulerAnglesPosition(&result_c, &scaling_c, &rotation_c, &position_c);
EXPECT_EQ(scaling_cpp, scaling_c);
EXPECT_EQ(position_cpp, position_c);
EXPECT_EQ(rotation_cpp, rotation_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeIntoScalingAxisAnglePositionTest) {
aiVector3D scaling_c, scaling_cpp,
axis_c, axis_cpp,
position_c, position_cpp;
ai_real angle_c, angle_cpp;
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
result_cpp.Decompose(scaling_cpp, axis_cpp, angle_cpp, position_cpp);
aiMatrix4DecomposeIntoScalingAxisAnglePosition(&result_c, &scaling_c, &axis_c, &angle_c, &position_c);
EXPECT_EQ(scaling_cpp, scaling_c);
EXPECT_EQ(axis_cpp, axis_c);
EXPECT_EQ(angle_cpp, angle_c);
EXPECT_EQ(position_cpp, position_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4DecomposeNoScalingTest) {
aiVector3D position_c, position_cpp;
aiQuaternion rotation_c, rotation_cpp;
result_c = result_cpp = get_predetermined_transformation_matrix_for_decomposition();
result_cpp.DecomposeNoScaling(rotation_cpp, position_cpp);
aiMatrix4DecomposeNoScaling(&result_c, &rotation_c, &position_c);
EXPECT_EQ(position_cpp, position_c);
EXPECT_EQ(rotation_cpp, rotation_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromEulerAnglesTest) {
const float x(RandPI.next()),
y(RandPI.next()),
z(RandPI.next());
result_cpp.FromEulerAnglesXYZ(x, y, z);
aiMatrix4FromEulerAngles(&result_c, x, y, z);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationXTest) {
const float angle(RandPI.next());
aiMatrix4x4::RotationX(angle, result_cpp);
aiMatrix4RotationX(&result_c, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationYTest) {
const float angle(RandPI.next());
aiMatrix4x4::RotationY(angle, result_cpp);
aiMatrix4RotationY(&result_c, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4RotationZTest) {
const float angle(RandPI.next());
aiMatrix4x4::RotationZ(angle, result_cpp);
aiMatrix4RotationZ(&result_c, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromRotationAroundAxisTest) {
const float angle(RandPI.next());
const auto axis = random_unit_vec3();
aiMatrix4x4::Rotation(angle, axis, result_cpp);
aiMatrix4FromRotationAroundAxis(&result_c, &axis, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4TranslationTest) {
const auto axis = random_vec3();
aiMatrix4x4::Translation(axis, result_cpp);
aiMatrix4Translation(&result_c, &axis);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4ScalingTest) {
const auto scaling = random_vec3();
aiMatrix4x4::Scaling(scaling, result_cpp);
aiMatrix4Scaling(&result_c, &scaling);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiMatrix4x4, aiMatrix4FromToTest) {
// Use predetermined vectors to prevent running into division by zero.
const auto from = aiVector3D(1,2,1).Normalize(), to = aiVector3D(-1,1,1).Normalize();
aiMatrix4x4::FromToMatrix(from, to, result_cpp);
aiMatrix4FromTo(&result_c, &from, &to);
EXPECT_TRUE(result_cpp.Equal(result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiMatrix4x4, operatorTest) {
std::array<ai_real, 16> value = { 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16 };
result_cpp = aiMatrix4x4( value[0], value[1], value[2], value[3],
value[4], value[5], value[6], value[7],
value[8], value[9], value[10], value[11],
value[12], value[13], value[14], value[15] );
size_t idx=0;
for (unsigned int i = 0; i < 4; ++i) {
for (unsigned int j = 0; j < 4; ++j) {
ai_real curValue = result_cpp[i][j];
EXPECT_EQ(curValue, value[idx]);
idx++;
}
}
}

View file

@ -0,0 +1,146 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "MathTest.h"
using namespace Assimp;
class AssimpAPITest_aiQuaternion : public AssimpMathTest {
protected:
virtual void SetUp() {
result_c = result_cpp = aiQuaternion();
}
aiQuaternion result_c, result_cpp;
};
TEST_F(AssimpAPITest_aiQuaternion, aiCreateQuaternionFromMatrixTest) {
// Use a predetermined transformation matrix
// to prevent running into division by zero.
aiMatrix3x3 m, r;
aiMatrix3x3::Translation(aiVector2D(14,-25), m);
aiMatrix3x3::RotationZ(Math::aiPi<float>() / 4.0f, r);
m = m * r;
result_cpp = aiQuaternion(m);
aiCreateQuaternionFromMatrix(&result_c, &m);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromEulerAnglesTest) {
const float x(RandPI.next()),
y(RandPI.next()),
z(RandPI.next());
result_cpp = aiQuaternion(x, y, z);
aiQuaternionFromEulerAngles(&result_c, x, y, z);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromAxisAngleTest) {
const float angle(RandPI.next());
const aiVector3D axis(random_unit_vec3());
result_cpp = aiQuaternion(axis, angle);
aiQuaternionFromAxisAngle(&result_c, &axis, angle);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionFromNormalizedQuaternionTest) {
const auto qvec3 = random_unit_vec3();
result_cpp = aiQuaternion(qvec3);
aiQuaternionFromNormalizedQuaternion(&result_c, &qvec3);
// Use a larger tolerance because FMA contraction differences in
// 1.0 - x*x - y*y - z*z can flip the sign of a near-zero residual,
// causing w = 0 vs w = sqrt(tiny) ≈ 1e-4.
EXPECT_TRUE(result_cpp.Equal(result_c, 1e-4f));
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualTest) {
result_c = result_cpp = random_quat();
EXPECT_EQ(result_cpp == result_c,
(bool)aiQuaternionAreEqual(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionAreEqualEpsilonTest) {
result_c = result_cpp = random_quat();
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
(bool)aiQuaternionAreEqualEpsilon(&result_cpp, &result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionNormalizeTest) {
result_c = result_cpp = random_quat();
aiQuaternionNormalize(&result_c);
EXPECT_EQ(result_cpp.Normalize(), result_c);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionConjugateTest) {
result_c = result_cpp = random_quat();
aiQuaternionConjugate(&result_c);
EXPECT_EQ(result_cpp.Conjugate(), result_c);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionMultiplyTest) {
const aiQuaternion temp = random_quat();
result_c = result_cpp = random_quat();
result_cpp = result_cpp * temp;
aiQuaternionMultiply(&result_c, &temp);
EXPECT_FLOAT_EQ(result_cpp.x, result_c.x);
EXPECT_FLOAT_EQ(result_cpp.y, result_c.y);
EXPECT_FLOAT_EQ(result_cpp.z, result_c.z);
EXPECT_FLOAT_EQ(result_cpp.w, result_c.w);
}
TEST_F(AssimpAPITest_aiQuaternion, aiQuaternionInterpolateTest) {
// Use predetermined quaternions to prevent division by zero
// during slerp calculations.
const float INTERPOLATION(0.5f);
const auto q1 = aiQuaternion(aiVector3D(-1,1,1).Normalize(), Math::aiPi<float>() / 4.0f);
const auto q2 = aiQuaternion(aiVector3D(1,2,1).Normalize(), Math::aiPi<float>() / 2.0f);
aiQuaternion::Interpolate(result_cpp, q1, q2, INTERPOLATION);
aiQuaternionInterpolate(&result_c, &q1, &q2, INTERPOLATION);
EXPECT_FLOAT_EQ(result_cpp.x, result_c.x);
EXPECT_FLOAT_EQ(result_cpp.y, result_c.y);
EXPECT_FLOAT_EQ(result_cpp.z, result_c.z);
EXPECT_FLOAT_EQ(result_cpp.w, result_c.w);
}

View file

@ -0,0 +1,140 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "MathTest.h"
using namespace Assimp;
class AssimpAPITest_aiVector2D : public AssimpMathTest {
protected:
virtual void SetUp() {
result_c = result_cpp = aiVector2D();
temp = random_vec2(); // Generates a random 2D vector != null vector.
}
aiVector2D result_c, result_cpp, temp;
};
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualTest) {
result_c = result_cpp = random_vec2();
EXPECT_EQ(result_cpp == result_c,
(bool)aiVector2AreEqual(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2AreEqualEpsilonTest) {
result_c = result_cpp = random_vec2();
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
(bool)aiVector2AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2AddTest) {
result_c = result_cpp = random_vec2();
result_cpp += temp;
aiVector2Add(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2SubtractTest) {
result_c = result_cpp = random_vec2();
result_cpp -= temp;
aiVector2Subtract(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2ScaleTest) {
const float FACTOR = RandNonZero.next();
result_c = result_cpp = random_vec2();
result_cpp *= FACTOR;
aiVector2Scale(&result_c, FACTOR);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2SymMulTest) {
result_c = result_cpp = random_vec2();
result_cpp = result_cpp.SymMul(temp);
aiVector2SymMul(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByScalarTest) {
const float DIVISOR = RandNonZero.next();
result_c = result_cpp = random_vec2();
result_cpp /= DIVISOR;
aiVector2DivideByScalar(&result_c, DIVISOR);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2DivideByVectorTest) {
result_c = result_cpp = random_vec2();
result_cpp = result_cpp / temp;
aiVector2DivideByVector(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2LengthTest) {
result_c = result_cpp = random_vec2();
EXPECT_EQ(result_cpp.Length(), aiVector2Length(&result_c));
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2SquareLengthTest) {
result_c = result_cpp = random_vec2();
EXPECT_EQ(result_cpp.SquareLength(), aiVector2SquareLength(&result_c));
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2NegateTest) {
result_c = result_cpp = random_vec2();
aiVector2Negate(&result_c);
EXPECT_EQ(-result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2DotProductTest) {
result_c = result_cpp = random_vec2();
EXPECT_EQ(result_cpp * result_c,
aiVector2DotProduct(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiVector2D, aiVector2NormalizeTest) {
result_c = result_cpp = random_vec2();
aiVector2Normalize(&result_c);
EXPECT_EQ(result_cpp.Normalize(), result_c);
}

View file

@ -0,0 +1,185 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "MathTest.h"
using namespace Assimp;
class AssimpAPITest_aiVector3D : public AssimpMathTest {
protected:
virtual void SetUp() {
result_c = result_cpp = aiVector3D();
temp = random_vec3(); // Generates a random 3D vector != null vector.
}
aiVector3D result_c, result_cpp, temp;
};
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp == result_c,
(bool)aiVector3AreEqual(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3AreEqualEpsilonTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp.Equal(result_c, Epsilon),
(bool)aiVector3AreEqualEpsilon(&result_cpp, &result_c, Epsilon));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3LessThanTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp < temp,
(bool)aiVector3LessThan(&result_c, &temp));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3AddTest) {
result_c = result_cpp = random_vec3();
result_cpp += temp;
aiVector3Add(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3SubtractTest) {
result_c = result_cpp = random_vec3();
result_cpp -= temp;
aiVector3Subtract(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3ScaleTest) {
const float FACTOR = RandNonZero.next();
result_c = result_cpp = random_vec3();
result_cpp *= FACTOR;
aiVector3Scale(&result_c, FACTOR);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3SymMulTest) {
result_c = result_cpp = random_vec3();
result_cpp = result_cpp.SymMul(temp);
aiVector3SymMul(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByScalarTest) {
const float DIVISOR = RandNonZero.next();
result_c = result_cpp = random_vec3();
result_cpp /= DIVISOR;
aiVector3DivideByScalar(&result_c, DIVISOR);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3DivideByVectorTest) {
result_c = result_cpp = random_vec3();
result_cpp = result_cpp / temp;
aiVector3DivideByVector(&result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3LengthTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp.Length(), aiVector3Length(&result_c));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3SquareLengthTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp.SquareLength(), aiVector3SquareLength(&result_c));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3NegateTest) {
result_c = result_cpp = random_vec3();
aiVector3Negate(&result_c);
EXPECT_EQ(-result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3DotProductTest) {
result_c = result_cpp = random_vec3();
EXPECT_EQ(result_cpp * result_c,
aiVector3DotProduct(&result_cpp, &result_c));
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3CrossProductTest) {
result_c = result_cpp = random_vec3();
result_cpp = result_cpp ^ temp;
aiVector3CrossProduct(&result_c, &result_c, &temp);
EXPECT_EQ(result_cpp, result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeTest) {
result_c = result_cpp = random_vec3();
aiVector3Normalize(&result_c);
EXPECT_EQ(result_cpp.Normalize(), result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3NormalizeSafeTest) {
result_c = result_cpp = random_vec3();
aiVector3NormalizeSafe(&result_c);
EXPECT_EQ(result_cpp.NormalizeSafe(), result_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiVector3RotateByQuaternionTest) {
aiVector3D v_c, v_cpp;
v_c = v_cpp = random_vec3();
const auto q = random_quat();
aiVector3RotateByQuaternion(&v_c, &q);
EXPECT_EQ(q.Rotate(v_cpp), v_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix3Test) {
const auto m = random_mat3();
aiVector3D v_c, v_cpp;
v_c = v_cpp = random_vec3();
v_cpp *= m;
aiTransformVecByMatrix3(&v_c, &m);
EXPECT_EQ(v_cpp, v_c);
}
TEST_F(AssimpAPITest_aiVector3D, aiTransformVecByMatrix4Test) {
const auto m = random_mat4();
aiVector3D v_c, v_cpp;
v_c = v_cpp = random_vec3();
v_cpp *= m;
aiTransformVecByMatrix4(&v_c, &m);
EXPECT_EQ(v_cpp, v_c);
}

View file

@ -0,0 +1,9 @@
/* This is just a small test to check whether Assimp's API compiles from C */
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/version.h>
#include <assimp/config.h>
#include <assimp/cimport.h>
#include <assimp/cexport.h>

View file

@ -0,0 +1,109 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/SceneCombiner.h>
using namespace Assimp;
class utScene : public ::testing::Test {
protected:
aiScene *scene;
void SetUp() override {
scene = new aiScene;
}
void TearDown() override {
delete scene;
scene = nullptr;
}
};
TEST_F(utScene, findNodeTest) {
scene->mRootNode = new aiNode();
scene->mRootNode->mName.Set("test");
aiNode *child = new aiNode;
child->mName.Set("child");
scene->mRootNode->addChildren(1, &child);
aiNode *found = scene->mRootNode->FindNode("child");
EXPECT_EQ(child, found);
}
TEST_F(utScene, sceneHasContentTest) {
EXPECT_FALSE(scene->HasAnimations());
EXPECT_FALSE(scene->HasMaterials());
EXPECT_FALSE(scene->HasMeshes());
EXPECT_FALSE(scene->HasCameras());
EXPECT_FALSE(scene->HasLights());
EXPECT_FALSE(scene->HasTextures());
}
TEST_F(utScene, getShortFilenameTest) {
std::string long_filename1 = "foo_bar/name";
const char *name1 = scene->GetShortFilename(long_filename1.c_str());
EXPECT_NE(nullptr, name1);
std::string long_filename2 = "foo_bar\\name";
const char *name2 = scene->GetShortFilename(long_filename2.c_str());
EXPECT_NE(nullptr, name2);
}
TEST_F(utScene, deepCopyTest) {
scene->mRootNode = new aiNode();
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh *[scene->mNumMeshes] ();
scene->mMeshes[0] = new aiMesh ();
scene->mMeshes[0]->SetTextureCoordsName (0, aiString ("test"));
{
aiScene* copied = nullptr;
SceneCombiner::CopyScene(&copied,scene);
delete copied;
}
}
TEST_F(utScene, getEmbeddedTextureTest) {
}

View file

@ -0,0 +1,110 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
/// Ensure this test has asserts on, even if the build type doesn't have asserts by default.
#if !defined(ASSIMP_BUILD_DEBUG)
#define ASSIMP_BUILD_DEBUG
#endif
#include <assimp/ai_assert.h>
#include <assimp/AssertHandler.h>
namespace
{
/// An exception which is thrown by the testAssertHandler
struct TestAssertException
{
TestAssertException(const char* failedExpression, const char* file, int line)
: m_failedExpression(failedExpression)
, m_file(file)
, m_line(line)
{
}
std::string m_failedExpression;
std::string m_file;
int m_line;
};
/// Swap the default handler, which aborts, by one which throws.
void testAssertHandler(const char* failedExpression, const char* file, int line)
{
throw TestAssertException(failedExpression, file, line);
}
/// Ensure that the default assert handler is restored after the test is finished.
struct ReplaceHandlerScope
{
ReplaceHandlerScope()
{
Assimp::setAiAssertHandler(testAssertHandler);
}
~ReplaceHandlerScope()
{
Assimp::setAiAssertHandler(Assimp::defaultAiAssertHandler);
}
};
}
TEST(utAssertHandler, replaceWithThrow)
{
ReplaceHandlerScope scope;
try
{
ai_assert((2 + 2 == 5) && "Sometimes people put messages here");
EXPECT_TRUE(false);
}
catch(const TestAssertException& e)
{
EXPECT_STREQ(e.m_failedExpression.c_str(), "(2 + 2 == 5) && \"Sometimes people put messages here\"");
EXPECT_STREQ(e.m_file.c_str(), __FILE__);
EXPECT_GT(e.m_line, 0);
EXPECT_LT(e.m_line, __LINE__);
}
catch(...)
{
EXPECT_TRUE(false);
}
}

View file

@ -0,0 +1,81 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "TestIOSystem.h"
#include <assimp/Base64.hpp>
using namespace std;
using namespace Assimp;
class Base64Test : public ::testing::Test {};
static const std::vector<uint8_t> assimpStringBinary = { 97, 115, 115, 105, 109, 112 };
static const std::string assimpStringEncoded = "YXNzaW1w";
TEST_F( Base64Test, encodeTest) {
EXPECT_EQ( "", Base64::Encode(std::vector<uint8_t>{}) );
EXPECT_EQ( "Vg==", Base64::Encode(std::vector<uint8_t>{ 86 }) );
EXPECT_EQ( assimpStringEncoded, Base64::Encode(assimpStringBinary) );
}
TEST_F( Base64Test, encodeTestWithNullptr ) {
std::string out;
Base64::Encode(nullptr, 100u, out);
EXPECT_TRUE(out.empty());
Base64::Encode(&assimpStringBinary[0], 0u, out);
EXPECT_TRUE(out.empty());
}
TEST_F( Base64Test, decodeTest) {
EXPECT_EQ( std::vector<uint8_t> {}, Base64::Decode("") );
EXPECT_EQ( std::vector<uint8_t> { 86 }, Base64::Decode("Vg==") );
EXPECT_EQ( assimpStringBinary, Base64::Decode(assimpStringEncoded) );
}
TEST_F(Base64Test, decodeTestWithNullptr) {
uint8_t *out = nullptr;
size_t size = Base64::Decode(nullptr, 100u, out);
EXPECT_EQ(nullptr, out);
EXPECT_EQ(0u, size);
}

View file

@ -0,0 +1,110 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "TestIOSystem.h"
#include "UnitTestPCH.h"
#include "Common/BaseProcess.h"
#include <assimp/AssertHandler.h>
using namespace Assimp;
class BaseProcessTest : public ::testing::Test {
public:
static void test_handler( const char*, const char*, int ) {
HandlerWasCalled = true;
}
void SetUp() override {
HandlerWasCalled = false;
setAiAssertHandler(test_handler);
}
void TearDown() override {
setAiAssertHandler(nullptr);
}
static bool handlerWasCalled() {
return HandlerWasCalled;
}
private:
static bool HandlerWasCalled;
};
bool BaseProcessTest::HandlerWasCalled = false;
class TestingBaseProcess : public BaseProcess {
public:
TestingBaseProcess() : BaseProcess() {
// empty
}
~TestingBaseProcess() override = default;
bool IsActive( unsigned int ) const override {
return true;
}
void Execute(aiScene*) override {
}
};
TEST_F( BaseProcessTest, constructTest ) {
bool ok = true;
try {
TestingBaseProcess process;
} catch (...) {
ok = false;
}
EXPECT_TRUE(ok);
}
TEST_F( BaseProcessTest, executeOnSceneTest ) {
TestingBaseProcess process;
process.ExecuteOnScene(nullptr);
#ifdef ASSIMP_BUILD_DEBUG
EXPECT_TRUE(BaseProcessTest::handlerWasCalled());
#else
EXPECT_FALSE(BaseProcessTest::handlerWasCalled());
#endif
}

View file

@ -0,0 +1,56 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/Hash.h>
using namespace Assimp;
class utHash : public ::testing::Test {
// empty
};
TEST_F( utHash, SuperFastHashTest ) {
const char *Data = "-21416115v";
auto result = SuperFastHash(Data, 10);
EXPECT_NE(0u, result);
}

View file

@ -0,0 +1,67 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/LineSplitter.h>
#include <assimp/DefaultIOSystem.h>
#include <string>
using namespace Assimp;
class utLineSplitter : public ::testing::Test {};
TEST_F(utLineSplitter, tokenizetest) {
DefaultIOSystem fs;
IOStream* file = fs.Open(ASSIMP_TEST_MODELS_DIR"/ParsingFiles/linesplitter_tokenizetest.txt", "rb");
StreamReaderLE stream(file);
LineSplitter myLineSplitter(stream);
}
TEST_F( utLineSplitter, issue212Test) {
DefaultIOSystem fs;
IOStream* file = fs.Open(ASSIMP_TEST_MODELS_DIR"/ParsingFiles/linesplitter_emptyline_test.txt", "rb");
StreamReaderLE stream(file);
LineSplitter myLineSplitter(stream);
myLineSplitter++;
EXPECT_THROW( myLineSplitter++, std::logic_error );
}

View file

@ -0,0 +1,52 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/Importer.hpp>
using namespace Assimp;
class utLogger : public ::testing::Test {};
TEST_F(utLogger, aiGetPredefinedLogStream_leak_test) {
aiLogStream stream1 = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, nullptr);
aiLogStream stream2 = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT, nullptr);
ASSERT_EQ(stream1.callback, stream2.callback);
}

View file

@ -0,0 +1,54 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "Common/Maybe.h"
using namespace Assimp;
class utMaybe : public ::testing::Test {
// empty
};
TEST_F(utMaybe, creationTest) {
Maybe<int> first(1);
EXPECT_EQ(first.Get(), 1);
}

View file

@ -0,0 +1,97 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/mesh.h>
using namespace Assimp;
class utMesh : public ::testing::Test {
protected:
aiMesh* mesh = nullptr;
void SetUp() override {
mesh = new aiMesh;
}
void TearDown() override {
delete mesh;
mesh = nullptr;
}
};
TEST_F(utMesh, emptyMeshHasNoContentTest) {
EXPECT_EQ(0u, mesh->mName.length);
EXPECT_FALSE(mesh->HasPositions());
EXPECT_FALSE(mesh->HasFaces());
EXPECT_FALSE(mesh->HasNormals());
EXPECT_FALSE(mesh->HasTangentsAndBitangents());
EXPECT_FALSE(mesh->HasVertexColors(0));
EXPECT_FALSE(mesh->HasVertexColors(AI_MAX_NUMBER_OF_COLOR_SETS));
EXPECT_FALSE(mesh->HasTextureCoords(0));
EXPECT_FALSE(mesh->HasTextureCoords(AI_MAX_NUMBER_OF_TEXTURECOORDS));
EXPECT_EQ(0u, mesh->GetNumUVChannels());
EXPECT_EQ(0u, mesh->GetNumColorChannels());
EXPECT_FALSE(mesh->HasBones());
EXPECT_FALSE(mesh->HasTextureCoordsName(0));
EXPECT_FALSE(mesh->HasTextureCoordsName(AI_MAX_NUMBER_OF_TEXTURECOORDS));
}
TEST_F(utMesh, setTextureCoordsName) {
EXPECT_FALSE(mesh->HasTextureCoordsName(0));
const aiString texcoords_name("texcoord_name");
mesh->SetTextureCoordsName(0, texcoords_name);
EXPECT_TRUE(mesh->HasTextureCoordsName(0u));
EXPECT_FALSE(mesh->HasTextureCoordsName(1u));
ASSERT_NE(nullptr, mesh->mTextureCoordsNames);
ASSERT_NE(nullptr, mesh->mTextureCoordsNames[0]);
EXPECT_STREQ(texcoords_name.C_Str(), mesh->mTextureCoordsNames[0]->C_Str());
EXPECT_STREQ(texcoords_name.C_Str(), mesh->GetTextureCoordsName(0)->C_Str());
// Now clear the name
mesh->SetTextureCoordsName(0, aiString());
EXPECT_FALSE(mesh->HasTextureCoordsName(0));
ASSERT_NE(nullptr, mesh->mTextureCoordsNames);
EXPECT_EQ(nullptr, mesh->mTextureCoordsNames[0]);
EXPECT_EQ(nullptr, mesh->GetTextureCoordsName(0));
}

View file

@ -0,0 +1,66 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/ParsingUtils.h>
#include <assimp/fast_atof.h>
#include <array>
using namespace Assimp;
class utParsingUtils : public ::testing::Test {};
TEST_F(utParsingUtils, parseFloatsStringTest) {
const std::array<float, 16> floatArray = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 7.54979e-8f, -1.0f, 0.0f,
0.0f, 1.0f, 7.54979e-8f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
const std::string floatArrayAsStr = "1 0 0 0 0 7.54979e-8 -1 0 0 1 7.54979e-8 0 0 0 0 1";
const char *content = floatArrayAsStr.c_str();
const char *end = content + floatArrayAsStr.size();
for (float i : floatArray) {
float value = 0.0f;
SkipSpacesAndLineEnd(&content, end);
content = fast_atoreal_move(content, value);
EXPECT_FLOAT_EQ(value, i);
}
}

View file

@ -0,0 +1,120 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/SpatialSort.h>
using namespace Assimp;
class utSpatialSort : public ::testing::Test {
public
:
aiVector3D *vecs;
protected:
void SetUp() override {
::srand(static_cast<unsigned>(time(nullptr)));
vecs = new aiVector3D[100];
for (size_t i = 0; i < 100; ++i) {
vecs[i].x = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
vecs[i].y = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
vecs[i].z = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
}
}
void TearDown() override {
delete[] vecs;
}
};
TEST_F( utSpatialSort, findIdenticalsTest ) {
SpatialSort sSort;
sSort.Fill(vecs, 100, sizeof(aiVector3D));
std::vector<unsigned int> indices;
sSort.FindIdenticalPositions(vecs[0], indices);
EXPECT_EQ(1u, indices.size());
}
TEST_F(utSpatialSort, findPositionsTest) {
SpatialSort sSort;
sSort.Fill(vecs, 100, sizeof(aiVector3D));
std::vector<unsigned int> indices;
sSort.FindPositions(vecs[0], 0.01f, indices);
EXPECT_EQ(1u, indices.size());
}
TEST_F(utSpatialSort, highlyDisplacedPositionsTest) {
// Make a cube of positions, and then query it using the SpatialSort object.
constexpr unsigned int verticesPerAxis = 10;
constexpr ai_real step = 0.001f;
// Note the large constant offset here.
constexpr ai_real offset = 5000.0f - (0.5f * verticesPerAxis * step);
constexpr unsigned int totalNumPositions = verticesPerAxis * verticesPerAxis * verticesPerAxis;
aiVector3D* positions = new aiVector3D[totalNumPositions];
for (unsigned int x = 0; x < verticesPerAxis; ++x) {
for (unsigned int y = 0; y < verticesPerAxis; ++y) {
for (unsigned int z = 0; z < verticesPerAxis; ++z) {
const unsigned int index = (x * verticesPerAxis * verticesPerAxis) + (y * verticesPerAxis) + z;
positions[index] = aiVector3D(offset + (x * step), offset + (y * step), offset + (z * step));
}
}
}
SpatialSort sSort;
sSort.Fill(positions, totalNumPositions, sizeof(aiVector3D));
// Enough to find a point and its 6 immediate neighbors, but not any other point.
const ai_real epsilon = 1.1f * step;
std::vector<unsigned int> indices;
// Iterate through the _interior_ points of the cube.
for (unsigned int x = 1; x < verticesPerAxis - 1; ++x) {
for (unsigned int y = 1; y < verticesPerAxis - 1; ++y) {
for (unsigned int z = 1; z < verticesPerAxis - 1; ++z) {
const unsigned int index = (x * verticesPerAxis * verticesPerAxis) + (y * verticesPerAxis) + z;
sSort.FindPositions(positions[index], epsilon, indices);
ASSERT_EQ(7u, indices.size());
}
}
}
delete[] positions;
}

View file

@ -0,0 +1,57 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/mesh.h>
#include <assimp/StandardShapes.h>
using namespace Assimp;
class utStandardShapes : public ::testing::Test {
// empty
};
TEST_F( utStandardShapes, testMakeMesh ) {
// Make sphere positions
std::vector<aiVector3D> positions;
Assimp::StandardShapes::MakeSphere(1, positions);
// Make mesh
const auto numIndicesPerPrimitive = 3u;
aiMesh *aiMeshPtr = Assimp::StandardShapes::MakeMesh(positions, numIndicesPerPrimitive);
// The mNumIndices member of the second face is now incorrect
const auto& face = aiMeshPtr->mFaces[0];
EXPECT_EQ(face.mNumIndices, numIndicesPerPrimitive);
delete aiMeshPtr;
}

View file

@ -0,0 +1,86 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------*/
#include "UnitTestPCH.h"
#include <assimp/XmlParser.h>
#include <assimp/DefaultIOStream.h>
#include <assimp/DefaultIOSystem.h>
using namespace Assimp;
class utXmlParser : public ::testing::Test {
public:
utXmlParser() :
Test(),
mIoSystem() {
// empty
}
protected:
DefaultIOSystem mIoSystem;
};
TEST_F(utXmlParser, parse_xml_test) {
XmlParser parser;
std::string filename = ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d";
std::unique_ptr<IOStream> stream(mIoSystem.Open(filename.c_str(), "rb"));
EXPECT_NE(stream.get(), nullptr);
bool result = parser.parse(stream.get());
EXPECT_TRUE(result);
}
TEST_F(utXmlParser, parse_xml_and_traverse_test) {
XmlParser parser;
std::string filename = ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d";
std::unique_ptr<IOStream> stream(mIoSystem.Open(filename.c_str(), "rb"));
EXPECT_NE(stream.get(), nullptr);
bool result = parser.parse(stream.get());
EXPECT_TRUE(result);
XmlNode root = parser.getRootNode();
XmlNodeIterator nodeIt(root, XmlNodeIterator::PreOrderMode);
const size_t numNodes = nodeIt.size();
bool empty = nodeIt.isEmpty();
EXPECT_FALSE(empty);
EXPECT_NE(numNodes, 0U);
XmlNode node;
while (nodeIt.getNext(node)) {
const std::string nodeName = node.name();
EXPECT_FALSE(nodeName.empty());
}
}

View file

@ -0,0 +1,68 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "Geometry/GeometryUtils.h"
using namespace Assimp;
class utGeometryUtils : public ::testing::Test {
protected:
void SetUp() override {
}
void TearDown() override {
}
};
static constexpr size_t NumVectors = 100;
TEST_F(utGeometryUtils, normalizeVectorArrayTest) {
aiVector3D *inNormals = new aiVector3D[NumVectors];
for (uint32_t i=0; i<NumVectors; ++i){
inNormals[i].x = static_cast<ai_real>(i);
inNormals[i].y = static_cast<ai_real>(i);
inNormals[i].z = static_cast<ai_real>(i);
}
aiVector3D *outNormals = new aiVector3D[NumVectors];
GeometryUtils::normalizeVectorArray(inNormals, outNormals, NumVectors);
delete[] outNormals;
delete[] inNormals;
}

View file

@ -0,0 +1,76 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "SceneDiffer.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
using namespace Assimp;
class utAssxmlImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
return true;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
bool exporterTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
EXPECT_NE(scene, nullptr );
::Assimp::Exporter exporter;
return AI_SUCCESS == exporter.Export(scene, "assxml", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assxml");
}
#endif
};
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utAssxmlImportExport, exportAssxmlTest) {
EXPECT_TRUE(exporterTest());
}
#endif

View file

@ -0,0 +1,70 @@
/*
---------------------------------------------------------------------------
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,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utIrrImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/box.irr", aiProcess_ValidateDataStructure);
// Only one box thus only one mesh
return nullptr != scene && scene->mNumMeshes == 1;
}
};
TEST_F(utIrrImportExport, importSimpleIrrTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utIrrImportExport, importSGIrrTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IRR/dawfInCellar_SameHierarchy.irr", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 2);
EXPECT_EQ(scene->mNumMaterials, 2);
EXPECT_GT(scene->mMeshes[0]->mNumVertices, 0);
}

View file

@ -0,0 +1,57 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file MDLHL1TestFiles.h
* @brief Definitions for Half-Life 1 MDL loader tests.
*/
#ifndef AI_MDLHL1TESTFILES_INCLUDED
#define AI_MDLHL1TESTFILES_INCLUDED
#ifndef ASSIMP_TEST_MDL_HL1_MODELS_DIR
#define ASSIMP_TEST_MDL_HL1_MODELS_DIR ASSIMP_TEST_MODELS_DIR"/MDL/MDL (HL1)/"
#endif
#ifndef MDL_HL1_FILE_MAN
#define MDL_HL1_FILE_MAN ASSIMP_TEST_MDL_HL1_MODELS_DIR "man.mdl"
#endif
#endif // AI_MDLHL1TESTFILES_INCLUDED

View file

@ -0,0 +1,228 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file utMDLImporter_HL1_ImportSettings.cpp
* @brief Half-Life 1 MDL loader import settings tests.
*/
#include "AbstractImportExportBase.h"
#include "AssetLib/MDL/HalfLife/HL1ImportDefinitions.h"
#include "MDLHL1TestFiles.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <functional>
#include <initializer_list>
using namespace Assimp;
class utMDLImporter_HL1_ImportSettings : public ::testing::Test {
public:
// Test various import settings scenarios.
void importSettings() {
/* Verify that animations are *NOT* imported when
'Read animations' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_EQ(0u, scene->mNumAnimations);
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS));
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS));
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
expect_global_info_eq<int>(scene, { { 0, "NumSequences" },
{ 0, "NumTransitionNodes" } });
});
/* Verify that blend controllers info is *NOT* imported when
'Read blend controllers' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_NE(0u, scene->mNumAnimations);
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
EXPECT_NE(nullptr, sequence_infos);
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_BLEND_CONTROLLERS));
expect_global_info_eq(scene, 0, "NumBlendControllers");
});
/* Verify that animation events are *NOT* imported when
'Read animation events' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_NE(0u, scene->mNumAnimations);
const aiNode *sequence_infos = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS);
EXPECT_NE(nullptr, sequence_infos);
for (unsigned int i = 0; i < sequence_infos->mNumChildren; ++i)
EXPECT_EQ(nullptr, sequence_infos->mChildren[i]->FindNode(AI_MDL_HL1_NODE_ANIMATION_EVENTS));
});
/* Verify that sequence transitions info is read when
'Read sequence transitions' is enabled. */
load_with_import_setting_bool(
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
true, // Set config value to true.
[&](const aiScene *scene) {
EXPECT_NE(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
expect_global_info_eq(scene, 4, "NumTransitionNodes");
});
/* Verify that sequence transitions info is *NOT* read when
'Read sequence transitions' is disabled. */
load_with_import_setting_bool(
ASSIMP_TEST_MDL_HL1_MODELS_DIR "sequence_transitions.mdl",
AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_TRANSITION_GRAPH));
expect_global_info_eq(scene, 0, "NumTransitionNodes");
});
/* Verify that bone controllers info is *NOT* read when
'Read bone controllers' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONE_CONTROLLERS));
expect_global_info_eq(scene, 0, "NumBoneControllers");
});
/* Verify that attachments info is *NOT* read when
'Read attachments' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_ATTACHMENTS));
expect_global_info_eq(scene, 0, "NumAttachments");
});
/* Verify that hitboxes info is *NOT* read when
'Read hitboxes' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES,
false, // Set config value to false.
[&](const aiScene *scene) {
EXPECT_EQ(nullptr, scene->mRootNode->FindNode(AI_MDL_HL1_NODE_HITBOXES));
expect_global_info_eq(scene, 0, "NumHitboxes");
});
/* Verify that misc global info is *NOT* read when
'Read misc global info' is disabled. */
load_with_import_setting_bool(
MDL_HL1_FILE_MAN,
AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO,
false, // Set config value to false.
[&](const aiScene *scene) {
aiNode *global_info = get_global_info(scene);
EXPECT_NE(nullptr, global_info);
aiVector3D temp;
EXPECT_FALSE(global_info->mMetaData->Get("EyePosition", temp));
});
}
private:
void load_with_import_setting_bool(
const char *file_path,
const char *setting_key,
bool setting_value,
std::function<void(const aiScene *)> &&func) {
Assimp::Importer importer;
importer.SetPropertyBool(setting_key, setting_value);
const aiScene *scene = importer.ReadFile(file_path, aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
func(scene);
}
inline static aiNode *get_global_info(const aiScene *scene) {
return scene->mRootNode->FindNode(AI_MDL_HL1_NODE_GLOBAL_INFO);
}
template <typename T>
static void expect_global_info_eq(
const aiScene *scene,
T expected_value,
const char *key_name) {
aiNode *global_info = get_global_info(scene);
EXPECT_NE(nullptr, global_info);
T temp = 0;
EXPECT_TRUE(global_info->mMetaData->Get(key_name, temp));
EXPECT_EQ(expected_value, temp);
}
template <typename T>
static void expect_global_info_eq(const aiScene *scene,
std::initializer_list<std::pair<T, const char *>> p_kv) {
aiNode *global_info = get_global_info(scene);
EXPECT_NE(nullptr, global_info);
for (auto it = p_kv.begin(); it != p_kv.end(); ++it) {
T temp = 0;
EXPECT_TRUE(global_info->mMetaData->Get(it->second, temp));
EXPECT_EQ(it->first, temp);
}
}
};
TEST_F(utMDLImporter_HL1_ImportSettings, importSettings) {
importSettings();
}

View file

@ -0,0 +1,134 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file utMDLImporter_HL1_Materials.cpp
* @brief Half-Life 1 MDL loader materials tests.
*/
#include "AbstractImportExportBase.h"
#include "AssetLib/MDL/HalfLife/HL1ImportDefinitions.h"
#include "MDLHL1TestFiles.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utMDLImporter_HL1_Materials : public ::testing::Test {
public:
/* Given an MDL model with a texture flagged as flatshade,
verify that the imported model has a flat shading model. */
void flatShadeTexture() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "chrome_sphere.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mMaterials);
aiShadingMode shading_mode = aiShadingMode_Flat;
scene->mMaterials[0]->Get(AI_MATKEY_SHADING_MODEL, shading_mode);
EXPECT_EQ(aiShadingMode_Flat, shading_mode);
}
/* Given an MDL model with a chrome texture, verify that
the imported model has a chrome material. */
void chromeTexture() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "chrome_sphere.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mMaterials);
int chrome;
scene->mMaterials[0]->Get(AI_MDL_HL1_MATKEY_CHROME(aiTextureType_DIFFUSE, 0), chrome);
EXPECT_EQ(1, chrome);
}
/* Given an MDL model with an additive texture, verify that
the imported model has an additive material. */
void additiveBlendTexture() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "blend_additive.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mMaterials);
aiBlendMode blend_mode = aiBlendMode_Default;
scene->mMaterials[0]->Get(AI_MATKEY_BLEND_FUNC, blend_mode);
EXPECT_EQ(aiBlendMode_Additive, blend_mode);
}
/* Given an MDL model with a color masked texture, verify that
the imported model has a color masked material. Ensure too
that the transparency color is the correct one. */
void textureWithColorMask() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "alpha_test.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mMaterials);
int texture_flags = 0;
scene->mMaterials[0]->Get(AI_MATKEY_TEXFLAGS_DIFFUSE(0), texture_flags);
EXPECT_EQ(aiTextureFlags_UseAlpha, texture_flags);
// The model has only one texture, a 256 color bitmap with
// a palette. Pure blue is the last color in the palette,
// and should be the transparency color.
aiColor3D transparency_color = {};
scene->mMaterials[0]->Get(AI_MATKEY_COLOR_TRANSPARENT, transparency_color);
EXPECT_EQ(aiColor3D(0, 0, 255), transparency_color);
}
};
TEST_F(utMDLImporter_HL1_Materials, flatShadeTexture) {
flatShadeTexture();
}
TEST_F(utMDLImporter_HL1_Materials, chromeTexture) {
chromeTexture();
}
TEST_F(utMDLImporter_HL1_Materials, additiveBlendTexture) {
additiveBlendTexture();
}
TEST_F(utMDLImporter_HL1_Materials, textureWithColorMask) {
textureWithColorMask();
}

View file

@ -0,0 +1,563 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file utMDLImporter_HL1_Nodes.cpp
* @brief Half-Life 1 MDL loader nodes tests.
*/
#include "AbstractImportExportBase.h"
#include "AssetLib/MDL/HalfLife/HL1ImportDefinitions.h"
#include "MDLHL1TestFiles.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utMDLImporter_HL1_Nodes : public ::testing::Test {
/**
* @note Represents a flattened node hierarchy where each item is a pair
* containing the node level and it's name.
*/
using Hierarchy = std::vector<std::pair<unsigned int, std::string>>;
/**
* @note A vector of strings. Used for symplifying syntax.
*/
using StringVector = std::vector<std::string>;
public:
/**
* @note The following tests require a basic understanding
* of the SMD format. For more information about SMD format,
* please refer to the SMD importer or go to VDC
* (Valve Developer Community).
*/
// Given a model, verify that the bones nodes hierarchy is correctly formed.
void checkBoneHierarchy() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "multiple_roots.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mRootNode);
// First, check that "<MDL_root>" and "<MDL_bones>" are linked.
const aiNode* node_MDL_root = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_ROOT);
ASSERT_NE(nullptr, node_MDL_root);
const aiNode *node_MDL_bones = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONES);
ASSERT_NE(nullptr, node_MDL_bones);
ASSERT_NE(nullptr, node_MDL_bones->mParent);
ASSERT_EQ(node_MDL_root, node_MDL_bones->mParent);
// Second, verify "<MDL_bones>" hierarchy.
const Hierarchy expected_hierarchy = {
{ 0, AI_MDL_HL1_NODE_BONES },
{ 1, "root1_bone1" },
{ 2, "root1_bone2" },
{ 3, "root1_bone4" },
{ 3, "root1_bone5" },
{ 2, "root1_bone3" },
{ 3, "root1_bone6" },
{ 1, "root2_bone1" },
{ 2, "root2_bone2" },
{ 2, "root2_bone3" },
{ 3, "root2_bone5" },
{ 2, "root2_bone4" },
{ 3, "root2_bone6" },
{ 1, "root3_bone1" },
{ 2, "root3_bone2" },
{ 2, "root3_bone3" },
{ 2, "root3_bone4" },
{ 3, "root3_bone5" },
{ 4, "root3_bone6" },
{ 4, "root3_bone7" },
};
Hierarchy actual_hierarchy;
flatten_hierarchy(node_MDL_bones, actual_hierarchy);
ASSERT_EQ(expected_hierarchy, actual_hierarchy);
}
/* Given a model with bones that have empty names,
verify that all the bones of the imported model
have unique and no empty names.
"" <----+---- empty names
"" <----+
"" <----+
"Bone_3" |
"" <----+
"Bone_2" |
"Bone_5" |
"" <----+
"" <----+
*/
void emptyBonesNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bones.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_bones_names = {
"Bone",
"Bone_0",
"Bone_1",
"Bone_3",
"Bone_4",
"Bone_2",
"Bone_5",
"Bone_6",
"Bone_7"
};
StringVector actual_bones_names;
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONES), actual_bones_names);
ASSERT_EQ(expected_bones_names, actual_bones_names);
}
/* Given a model with bodyparts that have empty names,
verify that the imported model contains bodyparts with
unique and no empty names.
$body "" <----+---- empty names
$body "Bodypart_1" |
$body "Bodypart_5" |
$body "Bodypart_6" |
$body "" <----+
$body "Bodypart_2" |
$body "" <----+
$body "Bodypart_3" |
$body "" <----+
*/
void emptyBodypartsNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_bodyparts.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_bodyparts_names = {
"Bodypart",
"Bodypart_1",
"Bodypart_5",
"Bodypart_6",
"Bodypart_0",
"Bodypart_2",
"Bodypart_4",
"Bodypart_3",
"Bodypart_7"
};
StringVector actual_bodyparts_names;
// Get the bodyparts names "without" the submodels.
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BODYPARTS), actual_bodyparts_names, 0);
ASSERT_EQ(expected_bodyparts_names, actual_bodyparts_names);
}
/* Given a model with bodyparts that have duplicate names,
verify that the imported model contains bodyparts with
unique and no duplicate names.
$body "Bodypart" <-----+
$body "Bodypart_1" <--+ |
$body "Bodypart_2" | |
$body "Bodypart1" | |
$body "Bodypart" ---|--+
$body "Bodypart_1" ---+ |
$body "Bodypart2" |
$body "Bodypart" ------+
$body "Bodypart_4"
*/
void duplicateBodypartsNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_bodyparts.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_bodyparts_names = {
"Bodypart",
"Bodypart_1",
"Bodypart_2",
"Bodypart1",
"Bodypart_0",
"Bodypart_1_0",
"Bodypart2",
"Bodypart_3",
"Bodypart_4"
};
StringVector actual_bodyparts_names;
// Get the bodyparts names "without" the submodels.
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BODYPARTS), actual_bodyparts_names, 0);
ASSERT_EQ(expected_bodyparts_names, actual_bodyparts_names);
}
/* Given a model with several bodyparts that contains multiple
sub models with the same file name, verify for each bodypart
sub model of the imported model that they have a unique name.
$bodygroup "first_bodypart"
{
studio "triangle" <------+ duplicate file names.
studio "triangle" -------+
} |
|
$bodygroup "second_bodypart" |
{ |
studio "triangle" -------+ same as first bodypart, but with same file.
studio "triangle" -------+
}
$bodygroup "last_bodypart"
{
studio "triangle2" <------+ duplicate names.
studio "triangle2" -------+
}
*/
void duplicateSubModelsNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_submodels.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const std::vector<StringVector> expected_bodypart_sub_models_names = {
{
"triangle",
"triangle_0",
},
{
"triangle_1",
"triangle_2",
},
{
"triangle2",
"triangle2_0",
}
};
const aiNode *bodyparts_node = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BODYPARTS);
ASSERT_NE(nullptr, bodyparts_node);
EXPECT_EQ(3u, bodyparts_node->mNumChildren);
StringVector actual_submodels_names;
for (unsigned int i = 0; i < bodyparts_node->mNumChildren; ++i)
{
actual_submodels_names.clear();
get_node_children_names(bodyparts_node->mChildren[i], actual_submodels_names);
ASSERT_EQ(expected_bodypart_sub_models_names[i], actual_submodels_names);
}
}
/* Given a model with sequences that have duplicate names, verify
that each sequence from the imported model has a unique
name.
$sequence "idle_1" <-------+
$sequence "idle" <----+ |
$sequence "idle_2" | |
$sequence "idle" -----+ |
$sequence "idle_0" | |
$sequence "idle_1" -----|--+
$sequence "idle_3" |
$sequence "idle" -----+
$sequence "idle_7"
*/
void duplicateSequenceNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_sequences.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_sequence_names = {
"idle_1",
"idle",
"idle_2",
"idle_4",
"idle_0",
"idle_1_0",
"idle_3",
"idle_5",
"idle_7"
};
StringVector actual_sequence_names;
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS), actual_sequence_names);
ASSERT_EQ(expected_sequence_names, actual_sequence_names);
}
/* Given a model with sequences that have empty names, verify
that each sequence from the imported model has a unique
name.
$sequence "" <----+---- empty names
$sequence "Sequence_1" |
$sequence "" <----+
$sequence "Sequence_4" |
$sequence "" <----+
$sequence "Sequence_8" |
$sequence "" <----+
$sequence "Sequence_2" |
$sequence "" <----+
*/
void emptySequenceNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_sequences.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_sequence_names = {
"Sequence",
"Sequence_1",
"Sequence_0",
"Sequence_4",
"Sequence_3",
"Sequence_8",
"Sequence_5",
"Sequence_2",
"Sequence_6"
};
StringVector actual_sequence_names;
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_INFOS), actual_sequence_names);
ASSERT_EQ(expected_sequence_names, actual_sequence_names);
}
/* Given a model with sequence groups that have duplicate names,
verify that each sequence group from the imported model has
a unique name.
"default"
$sequencegroup "SequenceGroup" <----+
$sequencegroup "SequenceGroup_1" |
$sequencegroup "SequenceGroup_5" <----|--+
$sequencegroup "SequenceGroup" -----+ |
$sequencegroup "SequenceGroup_0" | |
$sequencegroup "SequenceGroup" -----+ |
$sequencegroup "SequenceGroup_5" --------+
$sequencegroup "SequenceGroup_6"
$sequencegroup "SequenceGroup_2"
*/
void duplicateSequenceGroupNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "duplicate_sequence_groups/duplicate_sequence_groups.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_sequence_names = {
"default",
"SequenceGroup",
"SequenceGroup_1",
"SequenceGroup_5",
"SequenceGroup_3",
"SequenceGroup_0",
"SequenceGroup_4",
"SequenceGroup_5_0",
"SequenceGroup_6",
"SequenceGroup_2"
};
StringVector actual_sequence_names;
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS), actual_sequence_names);
ASSERT_EQ(expected_sequence_names, actual_sequence_names);
}
/* Given a model with sequence groups that have empty names,
verify that each sequence group from the imported model has
a unique name.
"default"
$sequencegroup "" <----+---- empty names
$sequencegroup "SequenceGroup_2" |
$sequencegroup "SequenceGroup_6" |
$sequencegroup "" <----+
$sequencegroup "" <----+
$sequencegroup "SequenceGroup_1" |
$sequencegroup "SequenceGroup_5" |
$sequencegroup "" <----+
$sequencegroup "SequenceGroup_4"
*/
void emptySequenceGroupNames() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "unnamed_sequence_groups/unnamed_sequence_groups.mdl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
const StringVector expected_sequence_names = {
"default",
"SequenceGroup",
"SequenceGroup_2",
"SequenceGroup_6",
"SequenceGroup_0",
"SequenceGroup_3",
"SequenceGroup_1",
"SequenceGroup_5",
"SequenceGroup_7",
"SequenceGroup_4"
};
StringVector actual_sequence_names;
get_node_children_names(scene->mRootNode->FindNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS), actual_sequence_names);
ASSERT_EQ(expected_sequence_names, actual_sequence_names);
}
/* Verify that mOffsetMatrix applies the correct
inverse bind pose transform. */
void offsetMatrixUnappliesTransformations() {
const float TOLERANCE = 0.01f;
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(MDL_HL1_FILE_MAN, aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
aiNode *scene_bones_node = scene->mRootNode->FindNode(AI_MDL_HL1_NODE_BONES);
const aiMatrix4x4 identity_matrix;
for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
aiMesh *scene_mesh = scene->mMeshes[i];
for (unsigned int j = 0; j < scene_mesh->mNumBones; ++j) {
aiBone *scene_mesh_bone = scene_mesh->mBones[j];
// Store local node transforms.
aiNode *n = scene_bones_node->FindNode(scene_mesh_bone->mName);
std::vector<aiMatrix4x4> bone_matrices = { n->mTransformation };
while (n->mParent != scene->mRootNode) {
n = n->mParent;
bone_matrices.push_back(n->mTransformation);
}
// Compute absolute node transform.
aiMatrix4x4 transform;
for (auto it = bone_matrices.rbegin(); it != bone_matrices.rend(); ++it)
transform *= *it;
// Unapply the transformation using the offset matrix.
aiMatrix4x4 unapplied_transform = scene_mesh_bone->mOffsetMatrix * transform;
// Ensure that we have, approximately, the identity matrix.
expect_equal_matrices(identity_matrix, unapplied_transform, TOLERANCE);
}
}
}
private:
void expect_equal_matrices(const aiMatrix4x4 &expected, const aiMatrix4x4 &actual, float abs_error) {
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j)
EXPECT_NEAR(expected[i][j], actual[i][j], abs_error);
}
}
/** Get a flattened representation of a node's hierarchy.
* \param[in] node The node.
* \param[out] hierarchy The flattened node's hierarchy.
*/
void flatten_hierarchy(const aiNode *node, Hierarchy &hierarchy)
{
flatten_hierarchy_impl(node, hierarchy, 0);
}
void flatten_hierarchy_impl(const aiNode *node, Hierarchy &hierarchy, unsigned int level)
{
hierarchy.push_back({ level, node->mName.C_Str() });
for (size_t i = 0; i < node->mNumChildren; ++i)
{
flatten_hierarchy_impl(node->mChildren[i], hierarchy, level + 1);
}
}
/** Get all node's children names beneath max_level.
* \param[in] node The parent node from which to get all children names.
* \param[out] names The list of children names.
* \param[in] max_level If set to -1, all children names will be collected.
*/
void get_node_children_names(const aiNode *node, StringVector &names, const int max_level = -1)
{
get_node_children_names_impl(node, names, 0, max_level);
}
void get_node_children_names_impl(const aiNode *node, StringVector &names, int level, const int max_level = -1)
{
for (size_t i = 0; i < node->mNumChildren; ++i)
{
names.push_back(node->mChildren[i]->mName.C_Str());
if (max_level == -1 || level < max_level)
{
get_node_children_names_impl(node->mChildren[i], names, level + 1, max_level);
}
}
}
};
TEST_F(utMDLImporter_HL1_Nodes, checkBoneHierarchy) {
checkBoneHierarchy();
}
TEST_F(utMDLImporter_HL1_Nodes, emptyBonesNames) {
emptyBonesNames();
}
TEST_F(utMDLImporter_HL1_Nodes, emptyBodypartsNames) {
emptyBodypartsNames();
}
TEST_F(utMDLImporter_HL1_Nodes, duplicateBodypartsNames) {
duplicateBodypartsNames();
}
TEST_F(utMDLImporter_HL1_Nodes, duplicateSubModelsNames) {
duplicateSubModelsNames();
}
TEST_F(utMDLImporter_HL1_Nodes, emptySequenceNames) {
emptySequenceNames();
}
TEST_F(utMDLImporter_HL1_Nodes, duplicateSequenceNames) {
duplicateSequenceNames();
}
TEST_F(utMDLImporter_HL1_Nodes, emptySequenceGroupNames) {
emptySequenceGroupNames();
}
TEST_F(utMDLImporter_HL1_Nodes, duplicateSequenceGroupNames) {
duplicateSequenceGroupNames();
}
TEST_F(utMDLImporter_HL1_Nodes, offsetMatrixUnappliesTransformations) {
offsetMatrixUnappliesTransformations();
}

View file

@ -0,0 +1,70 @@
/*
---------------------------------------------------------------------------
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,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
using namespace Assimp;
class utPbrtImportExport : public AbstractImportExportBase {
public:
#ifndef ASSIMP_BUILD_NO_EXPORT
bool exporterTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
EXPECT_NE(scene, nullptr );
::Assimp::Exporter exporter;
return AI_SUCCESS == exporter.Export(scene, "pbrt", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.pbrt");
}
#endif
};
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utPbrtImportExport, exportTest_Success) {
EXPECT_TRUE(exporterTest());
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,64 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utRAWImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/RAW/Wuson.raw", aiProcess_ValidateDataStructure);
#ifndef ASSIMP_BUILD_NO_RAW_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif
}
};
TEST_F(utRAWImportExport, importSimpleRAWTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,59 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
class utTerragenImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/TER/RealisticTerrain.ter", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utTerragenImportExport, importFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,91 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
using namespace Assimp;
#ifndef ASSIMP_BUILD_NO_EXPORT
class utAssjsonImportExport : public AbstractImportExportBase {
public:
bool exporterTest() override {
Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
Exporter exporter;
const char *testFileName = "./spider_test.json";
aiReturn res = exporter.Export(scene, "assjson", testFileName);
if (aiReturn_SUCCESS != res) {
return false;
}
Assimp::ExportProperties exportProperties;
exportProperties.SetPropertyBool("JSON_SKIP_WHITESPACES", true);
const char *testNoWhitespaceFileName = "./spider_test_nowhitespace.json";
aiReturn resNoWhitespace = exporter.Export(scene, "assjson", testNoWhitespaceFileName, 0u, &exportProperties);
if (aiReturn_SUCCESS != resNoWhitespace) {
return false;
}
// Cleanup, remove generated json
if (0 != std::remove(testFileName)) {
return false;
}
if (0 != std::remove(testNoWhitespaceFileName)) {
return false;
}
return true;
}
};
TEST_F(utAssjsonImportExport, exportTest) {
EXPECT_TRUE(exporterTest());
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,104 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
TEST(utCOBImporter, importDwarfASCII) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf_ascii.cob", aiProcess_ValidateDataStructure);
// FIXME: this is wrong, it should succeed
// change to ASSERT_NE after it's been fixed
ASSERT_EQ(nullptr, scene);
}
TEST(utCOBImporter, importDwarf) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/dwarf.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importMoleculeASCII) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule_ascii.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importMolecule) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/molecule.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importSpider43ASCII) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3_ascii.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importSpider43) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_4_3.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importSpider66ASCII) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6_ascii.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importSpider66) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/COB/spider_6_6.cob", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utCOBImporter, importInvalidHeader) {
Assimp::Importer importer;
constexpr char Header[] = "Caligari ??LZSCALEb";
const aiScene *scene = importer.ReadFileFromMemory(Header, sizeof(Header), aiProcess_ValidateDataStructure);
ASSERT_EQ(nullptr, scene);
}

View file

@ -0,0 +1,105 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/Exporter.hpp>
#include <assimp/ProgressHandler.hpp>
using namespace Assimp;
#ifndef ASSIMP_BUILD_NO_EXPORT
class TestProgressHandler : public ProgressHandler {
public:
TestProgressHandler() :
ProgressHandler(),
mPercentage(0.f) {
// empty
}
virtual ~TestProgressHandler() = default;
bool Update(float percentage = -1.f) override {
mPercentage = percentage;
return true;
}
float mPercentage;
};
class ExporterTest : public ::testing::Test {
// empty
};
TEST_F(ExporterTest, ProgressHandlerTest) {
Exporter exporter;
TestProgressHandler *ph(new TestProgressHandler);
exporter.SetProgressHandler(ph);
}
// Make sure all the registered exporters have useful descriptions
TEST_F(ExporterTest, ExporterIdTest) {
Exporter exporter;
size_t exportFormatCount = exporter.GetExportFormatCount();
EXPECT_NE(0u, exportFormatCount) << "No registered exporters";
typedef std::map<std::string, const aiExportFormatDesc *> ExportIdMap;
ExportIdMap exporterMap;
for (size_t i = 0; i < exportFormatCount; ++i) {
// Check that the exporter description exists and makes sense
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(i);
ASSERT_NE(nullptr, desc) << "Missing aiExportFormatDesc at index " << i;
EXPECT_NE(nullptr, desc->id) << "Null exporter ID at index " << i;
EXPECT_STRNE("", desc->id) << "Empty exporter ID at index " << i;
EXPECT_NE(nullptr, desc->description) << "Null exporter description at index " << i;
EXPECT_STRNE("", desc->description) << "Empty exporter description at index " << i;
EXPECT_NE(nullptr, desc->fileExtension) << "Null exporter file extension at index " << i;
EXPECT_STRNE("", desc->fileExtension) << "Empty exporter file extension at index " << i;
// Check the ID is unique
std::string key(desc->id);
std::pair<ExportIdMap::iterator, bool> result = exporterMap.emplace(key, desc);
EXPECT_TRUE(result.second) << "Duplicate exported id: '" << key << "' " << desc->description << " *." << desc->fileExtension << " at index " << i;
}
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription(exportFormatCount);
EXPECT_EQ(nullptr, desc) << "More exporters than claimed";
}
#endif

View file

@ -0,0 +1,78 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
TEST(utMD2Importer, importFaerie) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/faerie.md2", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD2Importer, importSydney) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD2/sydney.md2", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD2Importer, importDolphin) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/dolphin.md2", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD2Importer, importFlag) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/flag.md2", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD2Importer, importHorse) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD2/horse.md2", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,67 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2021, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
TEST(utMD3Importer, importWatercan) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan.md3", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD3Importer, importWatercan_dmg) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/watercan_dmg.md3", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD3Importer, importEuropean_fnt_v2) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD3/q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,72 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
TEST(utMD5Importer, importEmpty) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/invalid/empty.md5mesh", aiProcess_ValidateDataStructure);
ASSERT_EQ(nullptr, scene);
}
TEST(utMD5Importer, importSimpleCube) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MD5/SimpleCube.md5mesh", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD5Importer, importBoarMan) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/BoarMan.md5mesh", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utMD5Importer, importBob) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/MD5/Bob.md5mesh", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,80 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "AbstractImportExportBase.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include "MDL/MDLHL1TestFiles.h"
using namespace Assimp;
class utMDLImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
importerTest_HL1(&importer);
// Add further MDL tests...
return true;
}
private:
void importerTest_HL1(Assimp::Importer *const importer) {
const aiScene *scene = importer->ReadFile(MDL_HL1_FILE_MAN, 0);
EXPECT_NE(nullptr, scene);
// Test that the importer can directly load an HL1 MDL external texture file.
scene = importer->ReadFile(ASSIMP_TEST_MDL_HL1_MODELS_DIR "manT.mdl", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(0u, scene->mNumTextures);
EXPECT_NE(0u, scene->mNumMaterials);
}
};
TEST_F(utMDLImporter, importMDLFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,60 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utNFFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/NFF/ManyEarthsNotJustOne.nff", 0);
return nullptr != scene;
}
};
TEST_F(utNFFImportExport, importNFFFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,60 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
class utOFFImportExport : public AbstractImportExportBase {
protected:
virtual bool importerTest() {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OFF/Cube.off", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utOFFImportExport, importOFFFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,61 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utOgreImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Ogre/TheThing/Mesh.mesh.xml", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utOgreImportExport, importerTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,61 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utQ3BSPImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/PK3/SGDTT3.pk3", 0);
return nullptr != scene;
}
};
TEST_F(utQ3BSPImportExport, importerTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,94 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
TEST(utXGLImporter, importBCN_Epileptic) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/BCN_Epileptic.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importCubesWithAlpha) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/cubes_with_alpha.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importSample_official) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importSample_official_asxml) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official_asxml.xml", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importSphereWithMatGloss) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sphere_with_mat_gloss_10pc.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importSpiderASCII) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Spider_ascii.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importWuson) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/Wuson.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXGLImporter, importWusonDXF) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/wuson_dxf.zgl", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

31
vendor/assimp/test/unit/Main.cpp vendored Normal file
View file

@ -0,0 +1,31 @@
#include "../../include/assimp/DefaultLogger.hpp"
#include "UnitTestPCH.h"
#include <ctime>
int main(int argc, char *argv[]) {
::testing::InitGoogleTest(&argc, argv);
// seed the randomizer with the current system time
time_t t;
time(&t);
srand((unsigned int)t);
// ............................................................................
// create a logger from both CPP
Assimp::DefaultLogger::create("AssimpLog_Cpp.log", Assimp::Logger::VERBOSE,
aiDefaultLogStream_STDOUT | aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
// .. and C. They should smoothly work together
aiEnableVerboseLogging(AI_TRUE);
aiLogStream logstream = aiGetPredefinedLogStream(aiDefaultLogStream_FILE, "AssimpLog_C.log");
aiAttachLogStream(&logstream);
int result = RUN_ALL_TESTS();
// ............................................................................
// but shutdown must be done from C to ensure proper deallocation
aiDetachAllLogStreams();
return result;
}

54
vendor/assimp/test/unit/MathTest.cpp vendored Normal file
View file

@ -0,0 +1,54 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "MathTest.h"
namespace Assimp {
// Initialize epsilon value.
const float AssimpMathTest::Epsilon = Math::getEpsilon<float>();
// Initialize with an interval of [1,100].
RandomUniformFloatGenerator AssimpMathTest::RandNonZero(1.0f, 100.0f);
// Initialize with an interval of [-PI,PI] inclusively.
RandomUniformFloatGenerator AssimpMathTest::RandPI(-Math::aiPi<float>(), Math::aiPi<float>());
}

103
vendor/assimp/test/unit/MathTest.h vendored Normal file
View file

@ -0,0 +1,103 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#ifndef ASSIMP_MATH_TEST_H
#define ASSIMP_MATH_TEST_H
#include "UnitTestPCH.h"
#include <assimp/types.h>
#include "RandomNumberGeneration.h"
namespace Assimp {
/** Custom test class providing several math related utilities. */
class AssimpMathTest : public ::testing::Test {
public:
/** Return a random non-null 2D vector. */
inline static aiVector2D random_vec2() {
return aiVector2D(RandNonZero.next(), RandNonZero.next());
}
/** Return a random non-null 3D vector. */
inline static aiVector3D random_vec3() {
return aiVector3D(RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
}
/** Return a random unit 3D vector. */
inline static aiVector3D random_unit_vec3() {
return random_vec3().NormalizeSafe();
}
/** Return a quaternion with random orientation and
* rotation angle around axis. */
inline static aiQuaternion random_quat() {
return aiQuaternion(random_unit_vec3(), RandPI.next());
}
/** Return a random non-null 3x3 matrix. */
inline static aiMatrix3x3 random_mat3() {
return aiMatrix3x3(
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(),
RandNonZero.next(), RandNonZero.next(),RandNonZero.next());
}
/** Return a random non-null 4x4 matrix. */
inline static aiMatrix4x4 random_mat4() {
return aiMatrix4x4(
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next(),
RandNonZero.next(), RandNonZero.next(),RandNonZero.next(), RandNonZero.next());
}
/** Epsilon value to use in tests. */
static const float Epsilon;
/** Random number generators. */
static RandomUniformFloatGenerator RandNonZero, RandPI;
};
}
#endif // ASSIMP_MATH_TEST_H

View file

@ -0,0 +1,82 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#ifndef ASSIMP_RANDOM_NUMBER_GENERATION_H
#define ASSIMP_RANDOM_NUMBER_GENERATION_H
#include <random>
namespace Assimp {
/** Helper class to use for generating pseudo-random
* real numbers, with a uniform distribution. */
template<typename T>
class RandomUniformRealGenerator {
public:
RandomUniformRealGenerator() :
dist_(),
rd_(),
re_(rd_()) {
// empty
}
RandomUniformRealGenerator(T min, T max) :
dist_(min, max),
rd_(),
re_(rd_()) {
// empty
}
inline T next() {
return dist_(re_);
}
private:
std::uniform_real_distribution<T> dist_;
std::random_device rd_;
std::default_random_engine re_;
};
using RandomUniformFloatGenerator = RandomUniformRealGenerator<float>;
}
#endif // ASSIMP_RANDOM_NUMBER_GENERATION_H

372
vendor/assimp/test/unit/SceneDiffer.cpp vendored Normal file
View file

@ -0,0 +1,372 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "SceneDiffer.h"
#include <assimp/scene.h>
#include <assimp/mesh.h>
#include <assimp/material.h>
#include <sstream>
namespace Assimp {
SceneDiffer::SceneDiffer()
: m_diffs() {
// empty
}
SceneDiffer::~SceneDiffer() = default;
bool SceneDiffer::isEqual( const aiScene *expected, const aiScene *toCompare ) {
if ( expected == toCompare ) {
return true;
}
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// meshes
if ( expected->mNumMeshes != toCompare->mNumMeshes ) {
std::stringstream stream;
stream << "Number of meshes not equal ( expected: " << expected->mNumMeshes << ", found : " << toCompare->mNumMeshes << " )\n";
addDiff( stream.str() );
return false;
}
for ( unsigned int i = 0; i < expected->mNumMeshes; i++ ) {
aiMesh *expMesh( expected->mMeshes[ i ] );
aiMesh *toCompMesh( toCompare->mMeshes[ i ] );
if ( !compareMesh( expMesh, toCompMesh ) ) {
std::stringstream stream;
stream << "Meshes are not equal, index : " << i << "\n";
addDiff( stream.str() );
}
}
// materials
/*if ( expected->mNumMaterials != toCompare->mNumMaterials ) {
std::stringstream stream;
stream << "Number of materials not equal ( expected: " << expected->mNumMaterials << ", found : " << toCompare->mNumMaterials << " )\n";
addDiff( stream.str() );
return false;
}
if ( expected->mNumMaterials > 0 ) {
if ( nullptr == expected->mMaterials || nullptr == toCompare->mMaterials ) {
addDiff( "Number of materials > 0 and mat pointer is nullptr" );
return false;
}
}
for ( unsigned int i = 0; i < expected->mNumMaterials; i++ ) {
aiMaterial *expectedMat( expected->mMaterials[ i ] );
aiMaterial *toCompareMat( expected->mMaterials[ i ] );
if ( !compareMaterial( expectedMat, toCompareMat ) ) {
std::stringstream stream;
stream << "Materials are not equal, index : " << i << "\n";
addDiff( stream.str() );
return false;
}
}*/
return true;
}
void SceneDiffer::showReport() {
if ( m_diffs.empty() ) {
return;
}
for ( std::vector<std::string>::iterator it = m_diffs.begin(); it != m_diffs.end(); ++it ) {
std::cout << *it << "\n";
}
std::cout << std::endl;
}
void SceneDiffer::reset() {
m_diffs.resize( 0 );
}
void SceneDiffer::addDiff( const std::string &diff ) {
if ( diff.empty() ) {
return;
}
m_diffs.push_back( diff );
}
static std::string dumpVector3( const aiVector3D &toDump ) {
std::stringstream stream;
stream << "( " << toDump.x << ", " << toDump.y << ", " << toDump.z << ")";
return stream.str();
}
/*static std::string dumpColor4D( const aiColor4D &toDump ) {
std::stringstream stream;
stream << "( " << toDump.r << ", " << toDump.g << ", " << toDump.b << ", " << toDump.a << ")";
return stream.str();
}*/
static std::string dumpFace( const aiFace &face ) {
std::stringstream stream;
for ( unsigned int i = 0; i < face.mNumIndices; i++ ) {
stream << face.mIndices[ i ];
if ( i < face.mNumIndices - 1 ) {
stream << ", ";
}
else {
stream << "\n";
}
}
return stream.str();
}
bool SceneDiffer::compareMesh( aiMesh *expected, aiMesh *toCompare ) {
if ( expected == toCompare ) {
return true;
}
if ( nullptr == expected || nullptr == toCompare ) {
return false;
}
if ( expected->mName != toCompare->mName ) {
std::stringstream stream;
stream << "Mesh name not equal ( expected: " << expected->mName.C_Str() << ", found : " << toCompare->mName.C_Str() << " )\n";
addDiff( stream.str() );
}
if ( expected->mNumVertices != toCompare->mNumVertices ) {
std::stringstream stream;
stream << "Number of vertices not equal ( expected: " << expected->mNumVertices << ", found : " << toCompare->mNumVertices << " )\n";
addDiff( stream.str() );
return false;
}
// positions
if ( expected->HasPositions() != toCompare->HasPositions() ) {
addDiff( "Expected are vertices, toCompare does not have any." );
return false;
}
bool vertEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expVert( expected->mVertices[ i ] );
aiVector3D &toCompVert( toCompare->mVertices[ i ] );
if ( !expVert.Equal( toCompVert ) ) {
std::cout << "index = " << i << dumpVector3( toCompVert ) << "\n";
std::stringstream stream;
stream << "Vertex not equal ( expected: " << dumpVector3( toCompVert ) << ", found: " << dumpVector3( toCompVert ) << "\n";
addDiff( stream.str() );
vertEqual = false;
}
}
if ( !vertEqual ) {
return false;
}
// normals
if ( expected->HasNormals() != toCompare->HasNormals() ) {
addDiff( "Expected are normals, toCompare does not have any." );
return false;
}
// return true;
//ToDo!
/*bool normalEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expNormal( expected->mNormals[ i ] );
aiVector3D &toCompNormal( toCompare->mNormals[ i ] );
if ( expNormal.Equal( toCompNormal ) ) {
std::stringstream stream;
stream << "Normal not equal ( expected: " << dumpVector3( expNormal ) << ", found: " << dumpVector3( toCompNormal ) << "\n";
addDiff( stream.str() );
normalEqual = false;
}
}
if ( !normalEqual ) {
return false;
}
// vertex colors
bool vertColEqual( true );
for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++ ) {
if ( expected->HasVertexColors(a) != toCompare->HasVertexColors(a) ) {
addDiff( "Expected are normals, toCompare does not have any." );
return false;
}
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiColor4D &expColor4D( expected->mColors[ a ][ i ] );
aiColor4D &toCompColor4D( toCompare->mColors[ a ][ i ] );
if ( expColor4D != toCompColor4D ) {
std::stringstream stream;
stream << "Color4D not equal ( expected: " << dumpColor4D( expColor4D ) << ", found: " << dumpColor4D( toCompColor4D ) << "\n";
addDiff( stream.str() );
vertColEqual = false;
}
}
if ( !vertColEqual ) {
return false;
}
}
// texture coords
bool texCoordsEqual( true );
for ( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++ ) {
if ( expected->HasTextureCoords( a ) != toCompare->HasTextureCoords( a ) ) {
addDiff( "Expected are texture coords, toCompare does not have any." );
return false;
}
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTexCoord( expected->mTextureCoords[ a ][ i ] );
aiVector3D &toCompTexCoord( toCompare->mTextureCoords[ a ][ i ] );
if ( expTexCoord.Equal( toCompTexCoord ) ) {
std::stringstream stream;
stream << "Texture coords not equal ( expected: " << dumpVector3( expTexCoord ) << ", found: " << dumpVector3( toCompTexCoord ) << "\n";
addDiff( stream.str() );
vertColEqual = false;
}
}
if ( !vertColEqual ) {
return false;
}
}
// tangents and bi-tangents
if ( expected->HasTangentsAndBitangents() != toCompare->HasTangentsAndBitangents() ) {
addDiff( "Expected are tangents and bi-tangents, toCompare does not have any." );
return false;
}
bool tangentsEqual( true );
for ( unsigned int i = 0; i < expected->mNumVertices; i++ ) {
aiVector3D &expTangents( expected->mTangents[ i ] );
aiVector3D &toCompTangents( toCompare->mTangents[ i ] );
if ( expTangents.Equal( toCompTangents ) ) {
std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expTangents ) << ", found: " << dumpVector3( toCompTangents ) << "\n";
addDiff( stream.str() );
tangentsEqual = false;
}
aiVector3D &expBiTangents( expected->mBitangents[ i ] );
aiVector3D &toCompBiTangents( toCompare->mBitangents[ i ] );
if ( expBiTangents.Equal( toCompBiTangents ) ) {
std::stringstream stream;
stream << "Tangents not equal ( expected: " << dumpVector3( expBiTangents ) << ", found: " << dumpVector3( toCompBiTangents ) << " )\n";
addDiff( stream.str() );
tangentsEqual = false;
}
}
if ( !tangentsEqual ) {
return false;
}*/
// faces
if ( expected->mNumFaces != toCompare->mNumFaces ) {
std::stringstream stream;
stream << "Number of faces are not equal, ( expected: " << expected->mNumFaces << ", found: " << toCompare->mNumFaces << ")\n";
addDiff( stream.str() );
return false;
}
bool facesEqual( true );
for ( unsigned int i = 0; i < expected->mNumFaces; i++ ) {
aiFace &expFace( expected->mFaces[ i ] );
aiFace &toCompareFace( toCompare->mFaces[ i ] );
if ( !compareFace( &expFace, &toCompareFace ) ) {
addDiff( "Faces are not equal\n" );
addDiff( dumpFace( expFace ) );
addDiff( dumpFace( toCompareFace ) );
facesEqual = false;
}
}
if ( !facesEqual ) {
return false;
}
return true;
}
bool SceneDiffer::compareFace( aiFace *expected, aiFace *toCompare ) {
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// same instance
if ( expected == toCompare ) {
return true;
}
// using compare operator
if ( *expected == *toCompare ) {
return true;
}
return false;
}
bool SceneDiffer::compareMaterial( aiMaterial *expected, aiMaterial *toCompare ) {
if ( nullptr == expected ) {
return false;
}
if ( nullptr == toCompare ) {
return false;
}
// same instance
if ( expected == toCompare ) {
return true;
}
// todo!
return true;
}
}

75
vendor/assimp/test/unit/SceneDiffer.h vendored Normal file
View file

@ -0,0 +1,75 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/fast_atof.h>
#include <vector>
#include <string>
struct aiScene;
struct aiMesh;
struct aiMaterial;
struct aiFace;
namespace Assimp {
class SceneDiffer {
public:
SceneDiffer();
~SceneDiffer();
bool isEqual( const aiScene *expected, const aiScene *toCompare );
void showReport();
void reset();
protected:
void addDiff( const std::string &diff );
bool compareMesh( aiMesh *expected, aiMesh *toCompare );
bool compareFace( aiFace *expected, aiFace *toCompare );
bool compareMaterial( aiMaterial *expected, aiMaterial *toCompare );
private:
std::vector<std::string> m_diffs;
};
}

51
vendor/assimp/test/unit/TestIOStream.h vendored Normal file
View file

@ -0,0 +1,51 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
#pragma once
#include <assimp/DefaultIOStream.h>
using namespace ::Assimp;
class TestDefaultIOStream final : public DefaultIOStream {
public:
TestDefaultIOStream() = default;
TestDefaultIOStream(FILE* pFile, const std::string &strFilename) : DefaultIOStream(pFile, strFilename) {}
~TestDefaultIOStream() override = default;
};

83
vendor/assimp/test/unit/TestIOSystem.h vendored Normal file
View file

@ -0,0 +1,83 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/IOSystem.hpp>
using namespace std;
namespace Assimp {
static const string Sep = "/";
class TestIOSystem : public IOSystem {
public:
TestIOSystem()
: IOSystem() {
// empty
}
virtual ~TestIOSystem() {
// empty
}
virtual bool Exists( const char* ) const {
return true;
}
virtual char getOsSeparator() const {
return Sep[ 0 ];
}
virtual IOStream* Open( const char* pFile, const char* pMode = "rb" ) {
EXPECT_NE( nullptr, pFile );
EXPECT_NE( nullptr, pMode );
return nullptr;
}
virtual void Close( IOStream* pFile ) {
EXPECT_NE( nullptr, pFile );
}
};
} // Namespace Assimp

View file

@ -0,0 +1,99 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/mesh.h>
#include <assimp/material.h>
namespace Assimp {
class TestModelFactory {
public:
TestModelFactory() = default;
~TestModelFactory() = default;
static aiScene *createDefaultTestModel( float &opacity ) {
auto *scene = new aiScene;
scene->mNumMaterials = 1;
scene->mMaterials = new aiMaterial*[scene->mNumMaterials];
scene->mMaterials[ 0 ] = new aiMaterial;
aiColor3D color( 1, 0, 0 );
EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &color, 1, AI_MATKEY_COLOR_DIFFUSE ) );
::srand(static_cast<unsigned int>(::time(nullptr)));
opacity = float( rand() ) / float( RAND_MAX );
EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &opacity, 1, AI_MATKEY_OPACITY ) );
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh*[scene->mNumMeshes];
scene->mMeshes[ 0 ] = new aiMesh;
scene->mMeshes[ 0 ]->mMaterialIndex = 0;
scene->mMeshes[ 0 ]->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
scene->mMeshes[ 0 ]->mNumVertices = 3;
scene->mMeshes[ 0 ]->mVertices = new aiVector3D[ 3 ];
scene->mMeshes[ 0 ]->mVertices[ 0 ] = aiVector3D( 1, 0, 0 );
scene->mMeshes[ 0 ]->mVertices[ 1 ] = aiVector3D( 0, 1, 0 );
scene->mMeshes[ 0 ]->mVertices[ 2 ] = aiVector3D( 0, 0, 1 );
scene->mMeshes[ 0 ]->mNumFaces = 1;
scene->mMeshes[ 0 ]->mFaces = new aiFace[scene->mMeshes[ 0 ]->mNumFaces];
scene->mMeshes[ 0 ]->mFaces[ 0 ].mNumIndices = 3;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices = new unsigned int[ 3 ];
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 0 ] = 0;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 1 ] = 1;
scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 2 ] = 2;
scene->mRootNode = new aiNode;
scene->mRootNode->mNumMeshes = 1;
scene->mRootNode->mMeshes = new unsigned int[1]{ 0 };
return scene;
}
static void releaseDefaultTestModel( aiScene **scene ) {
delete *scene;
*scene = nullptr;
}
};
}

View file

@ -0,0 +1,27 @@
#pragma once
#include <gtest/gtest.h>
#include <cstdio>
#include <string>
namespace Assimp::Unittest {
class TestTools final {
public:
TestTools() = default;
~TestTools() = default;
static bool openFilestream(FILE **pFile, const char *filename, const char *mode);
};
inline bool TestTools::openFilestream(FILE **fs, const char *filename, const char *mode) {
#if defined(_WIN32)
errno_t err{ 0 };
err = fopen_s(fs, filename, mode);
EXPECT_EQ(err, 0);
#else
*fs = fopen(filename, mode);
#endif
return fs != nullptr;
}
} // namespace Assimp::Unittest

63
vendor/assimp/test/unit/UTLogStream.h vendored Normal file
View file

@ -0,0 +1,63 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#include <assimp/LogStream.hpp>
class UTLogStream : public Assimp::LogStream {
public:
UTLogStream()
: LogStream() {
// empty
}
virtual ~UTLogStream() {
// empty
}
virtual void write(const char* message) {
if ( nullptr != message ) {
m_messages.emplace_back(message);
}
}
std::vector<std::string> m_messages;
};

View file

@ -0,0 +1,98 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
#ifdef _WIN32
# ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
# endif // _CRT_NONSTDC_NO_DEPRECATE
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
#endif
#include <cstdio>
#include <cstdlib>
#include <gtest/gtest.h>
#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
# define TMP_PATH "./"
#elif defined(__GNUC__) || defined(__clang__)
# define TMP_PATH "/var/tmp/"
#endif
#if defined(_MSC_VER)
#include <io.h>
inline FILE* MakeTmpFile(char* tmplate, size_t len, std::string &tmpName) {
size_t tmpLen = len + 1;
char *pathtemplate = new char[tmpLen];
strcpy_s(pathtemplate, tmpLen, tmplate);
int err_code = _mktemp_s(pathtemplate, tmpLen);
EXPECT_EQ(err_code, 0);
EXPECT_NE(pathtemplate, nullptr);
if(pathtemplate == nullptr) {
delete[] pathtemplate;
return nullptr;
}
errno_t err;
FILE *fs{nullptr};
err = fopen_s(&fs, pathtemplate, "w+");
EXPECT_EQ(0, err);
tmpName = pathtemplate;
EXPECT_NE(fs, nullptr);
delete[] pathtemplate;
return fs;
}
#elif defined(__GNUC__) || defined(__clang__)
inline FILE *MakeTmpFile(char *tmplate, size_t len, std::string &tmpName) {
auto fd = mkstemp(tmplate);
EXPECT_NE(-1, fd);
if(fd == -1) {
return nullptr;
}
auto fs = fdopen(fd, "w+");
EXPECT_NE(nullptr, fs);
tmpName += tmplate;
return fs;
}
#endif

59
vendor/assimp/test/unit/UnitTestPCH.h vendored Normal file
View file

@ -0,0 +1,59 @@
/*
---------------------------------------------------------------------------
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,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#pragma once
// We need to be sure to have the same STL settings as Assimp
#include <assimp/cimport.h>
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4389)
#endif
#include <gtest/gtest.h>
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#include <memory>
#include <math.h>
#include "UTLogStream.h"
#undef min
#undef max

View file

@ -0,0 +1,88 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
TEST(ut3DImportExport, importBoxA) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(ut3DImportExport, importBoxD) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box_d.3d", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(ut3DImportExport, importBoxUC) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3D/box.uc", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(ut3DImportExport, importMarRifle) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3D/mar_rifle.uc", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(ut3DImportExport, importMarRifleA) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3D/mar_rifle_a.3d", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(ut3DImportExport, importMarRifleD) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3D/mar_rifle_d.3d", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,184 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class ut3DSImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", aiProcess_ValidateDataStructure);
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
}
};
TEST_F(ut3DSImportExport, import3DSFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(ut3DSImportExport, import3DSformatdetection) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/testFormatDetection", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCameraRollAnim) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/CameraRollAnim.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCameraRollAnimWithChildObject) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/CameraRollAnimWithChildObject.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCubesWithAlpha) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/cubes_with_alpha.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCubeWithDiffuseTexture) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/cube_with_diffuse_texture.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCubeWithSpecularTexture) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/cube_with_specular_texture.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importRotatingCube) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/RotatingCube.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importTargetCameraAnim) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/TargetCameraAnim.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importTest1) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3DS/test1.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importCartWheel) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/cart_wheel.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importGranate) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/Granate.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importJeep1) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/jeep1.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importMarRifle) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/mar_rifle.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importMp5Sil) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/mp5_sil.3ds", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(ut3DSImportExport, importPyramob) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/3DS/pyramob.3DS", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,154 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
using namespace Assimp;
TEST(utACImportExport, importClosedLine) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/closedLine.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importNoSurfaces) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/nosurfaces.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importOpenLine) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/openLine.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importSampleSubdiv) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/sample_subdiv.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
// check approximate shape by averaging together all vertices
ASSERT_EQ(scene->mNumMeshes, 1u);
aiVector3D vertexAvg(0.0, 0.0, 0.0);
for (unsigned int i = 0; i < scene->mNumMeshes; i++) {
const aiMesh *mesh = scene->mMeshes[i];
ASSERT_NE(mesh, nullptr);
ai_real invVertexCount = 1.0 / mesh->mNumVertices;
for (unsigned int j = 0; j < mesh->mNumVertices; j++) {
vertexAvg += mesh->mVertices[j] * invVertexCount;
}
}
// must not be inf or nan
ASSERT_TRUE(std::isfinite(vertexAvg.x));
ASSERT_TRUE(std::isfinite(vertexAvg.y));
ASSERT_TRUE(std::isfinite(vertexAvg.z));
EXPECT_NEAR(vertexAvg.x, 0.079997420310974121, 0.0001);
EXPECT_NEAR(vertexAvg.y, 0.099498569965362549, 0.0001);
EXPECT_NEAR(vertexAvg.z, -0.10344827175140381, 0.0001);
}
TEST(utACImportExport, importSphereWithLight) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importSphereWithLightACC) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight.acc", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importSphereWithLightUTF16) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF16LE.ac", aiProcess_ValidateDataStructure);
// FIXME: this is probably wrong, loading the file should succeed
ASSERT_EQ(nullptr, scene);
}
TEST(utACImportExport, importSphereWithLightUTF8BOM) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLight_UTF8BOM.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importSphereWithLightUvScaling4X) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/SphereWithLightUvScaling4X.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importWuson) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importWusonACC) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/Wuson.acc", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, testFormatDetection) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/TestFormatDetection", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utACImportExport, importDobuleSidedFaces) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AC/doubleSidedFace.ac", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
// The scene contains one double-sided, rectangular AC surface. It should resolve to two quads (front + back) with eight
// vertices (one per side to guarantee proper normal vectors).
ASSERT_EQ(scene->mNumMeshes, 1u);
ASSERT_EQ(scene->mMeshes[0]->mNumFaces, 2u);
ASSERT_EQ(scene->mMeshes[0]->mNumVertices, 8u);
}

View file

@ -0,0 +1,142 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utAMFImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utAMFImportExport, importAMFFromFileTest) {
EXPECT_TRUE(importerTest());
}
// TODO: test models-nonbsd/AMF/3_bananas.amf.7z
// requires uncompressing it in memory and we don't currently have 7z decompressor
TEST_F(utAMFImportExport, importTest2) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test2.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest3) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test3.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest4) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test4.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest5) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test5.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest5a) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test5a.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest6) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test6.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest7) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test7.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
#if 0
// FIXME: these tests are disabled because they leak memory in AMFImporter_Postprocess.cpp
TEST_F(utAMFImportExport, importTest8) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test8.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utAMFImportExport, importTest9) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test9.amf", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
#endif // 0
TEST_F(utAMFImportExport, importAMFWithMatFromFileTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/AMF/test_with_mat.amf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,175 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
using namespace Assimp;
class utASEImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure);
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER
}
};
TEST_F(utASEImportExport, importACFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utASEImportExport, importAnim1) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/anim.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importAnim2) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/anim2.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importCameraRollAnim) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/CameraRollAnim.ase", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importMotionCaptureROM) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/MotionCaptureROM.ase", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importRotatingCube) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/RotatingCube.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importTargetCameraAnim) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TargetCameraAnim.ase", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importTestFormatDetection) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestFormatDetection", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importThreeCubesGreen) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
::Assimp::Importer importerLE;
const aiScene *sceneLE = importerLE.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen_UTF16LE.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, sceneLE);
::Assimp::Importer importerBE;
const aiScene *sceneBE = importerBE.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen_UTF16BE.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, sceneBE);
// TODO: these scenes should probably be identical
// verify that is the case and then add tests to check it
}
TEST_F(utASEImportExport, importUVTransform_Normal) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_Normal.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importUVTransform_ScaleUV1_2_OffsetUV0_0_9_Rotate_72_mirrorU) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV1-2_OffsetUV0-0.9_Rotate-72_mirrorU.ase", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importUVTransform_ScaleUV2x) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV2x.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utASEImportExport, importUVTransform_ScaleUV2x_Rotate45) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/ASE/TestUVTransform/UVTransform_ScaleUV2x_Rotate45.ASE", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

107
vendor/assimp/test/unit/utAnim.cpp vendored Normal file
View file

@ -0,0 +1,107 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/anim.h>
using namespace Assimp;
class utAnim : public ::testing::Test {
// empty
};
TEST_F( utAnim, aiVectorKeyCreationTest ) {
aiVectorKey defaultConstTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstTest.mTime );
aiVector3D v( 1, 2, 3 );
aiVectorKey constrWithValuesTest( 1, v );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( v, constrWithValuesTest.mValue );
EXPECT_NE( defaultConstTest, constrWithValuesTest );
EXPECT_TRUE( defaultConstTest != constrWithValuesTest );
defaultConstTest.mTime = 1;
constrWithValuesTest.mTime = 2;
EXPECT_TRUE( defaultConstTest < constrWithValuesTest );
}
TEST_F( utAnim, aiQuatKeyTest ) {
aiQuatKey defaultConstrTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstrTest.mTime );
aiQuaternion q;
aiQuatKey constrWithValuesTest( 1.0, q );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( q, constrWithValuesTest.mValue );
}
TEST_F( utAnim, aiNodeAnimTest ) {
bool ok( true );
try {
aiNodeAnim myAnim;
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPreState );
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPostState );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiMeshAnimTest ) {
bool ok( true );
try {
aiMeshAnim myMeshAnim;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiAnimationTest ) {
bool ok( true );
try {
aiAnimation myAnimation;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}

View file

@ -0,0 +1,79 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "TestModelFactory.h"
#include "UnitTestPCH.h"
#include "AbstractImportExportBase.h"
#include <assimp/material.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/types.h>
#include <assimp/Importer.hpp>
#include "PostProcessing/ArmaturePopulate.h"
namespace Assimp {
namespace UnitTest {
class utArmaturePopulate : public ::testing::Test {
// empty
};
TEST_F(utArmaturePopulate, importCheckForArmatureTest) {
Assimp::Importer importer;
unsigned int mask = aiProcess_PopulateArmatureData | aiProcess_ValidateDataStructure;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/huesitos.fbx", mask);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1u);
aiMesh *mesh = scene->mMeshes[0];
EXPECT_EQ(mesh->mNumFaces, 68u);
EXPECT_EQ(mesh->mNumVertices, 256u);
EXPECT_GT(mesh->mNumBones, 0u);
aiBone *exampleBone = mesh->mBones[0];
EXPECT_NE(exampleBone, nullptr);
EXPECT_NE(exampleBone->mArmature, nullptr);
EXPECT_NE(exampleBone->mNode, nullptr);
}
} // Namespace UnitTest
} // Namespace Assimp

View file

@ -0,0 +1,69 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
using namespace Assimp;
#ifndef ASSIMP_BUILD_NO_EXPORT
class utAssbinImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure);
Exporter exporter;
EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "assbin", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assbin"));
const aiScene *newScene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/spider_out.assbin", aiProcess_ValidateDataStructure);
return newScene != nullptr;
}
};
TEST_F(utAssbinImportExport, import3ExportAssbinDFromFileTest) {
EXPECT_TRUE(importerTest());
}
#endif // #ifndef ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,61 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utB3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utB3DImportExport, importB3DFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,74 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utBVHImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utBVHImportExport, import01_01) {
EXPECT_TRUE(importerTest());
}
TEST_F(utBVHImportExport, import01_03) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BVH/01_03.bvh", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST_F(utBVHImportExport, importBoxingToes) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BVH/Boxing_Toes.bvh", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}

View file

@ -0,0 +1,81 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "Common/Importer.h"
#include "TestIOSystem.h"
using namespace ::Assimp;
class BatchLoaderTest : public ::testing::Test {
public:
virtual void SetUp() {
m_io = new TestIOSystem();
}
virtual void TearDown() {
delete m_io;
}
protected:
TestIOSystem* m_io;
};
TEST_F( BatchLoaderTest, createTest ) {
bool ok( true );
try {
BatchLoader loader( m_io );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( BatchLoaderTest, validateAccessTest ) {
BatchLoader loader1( m_io );
EXPECT_FALSE( loader1.getValidation() );
loader1.setValidation( true );
EXPECT_TRUE( loader1.getValidation() );
BatchLoader loader2( m_io, true );
EXPECT_TRUE( loader2.getValidation() );
}

View file

@ -0,0 +1,112 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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>
class BlendImportAreaLight : public ::testing::Test {
public:
BlendImportAreaLight() :
im(nullptr) {}
~BlendImportAreaLight() override = default;
void SetUp() override {
im = new Assimp::Importer();
}
void TearDown() override {
delete im;
}
protected:
Assimp::Importer *im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportAreaLight, testImportLight) {
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != nullptr);
ASSERT_TRUE(pTest->HasLights());
std::vector<std::pair<std::string, size_t>> lightNames;
for (size_t i = 0; i < pTest->mNumLights; i++) {
lightNames.emplace_back(pTest->mLights[i]->mName.C_Str(), i);
}
std::sort(lightNames.begin(), lightNames.end());
std::vector<aiLight> lights;
for (size_t i = 0; i < pTest->mNumLights; ++i) {
lights.push_back(*pTest->mLights[lightNames[i].second]);
}
ASSERT_STREQ(lights[0].mName.C_Str(), "Bar");
ASSERT_STREQ(lights[1].mName.C_Str(), "Baz");
ASSERT_STREQ(lights[2].mName.C_Str(), "Foo");
ASSERT_EQ(lights[0].mType, aiLightSource_AREA);
ASSERT_EQ(lights[1].mType, aiLightSource_POINT);
ASSERT_EQ(lights[2].mType, aiLightSource_AREA);
EXPECT_FLOAT_EQ(lights[0].mSize.x, 0.5f);
EXPECT_FLOAT_EQ(lights[0].mSize.y, 2.0f);
EXPECT_FLOAT_EQ(lights[2].mSize.x, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mSize.y, 1.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.r, 42.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.g, 42.0f);
EXPECT_FLOAT_EQ(lights[0].mColorDiffuse.b, 42.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.r, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.g, 1.0f);
EXPECT_FLOAT_EQ(lights[2].mColorDiffuse.b, 1.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.x, 0.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.y, 0.0f);
EXPECT_FLOAT_EQ(lights[0].mDirection.z, -1.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.x, 0.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.y, 0.0f);
EXPECT_FLOAT_EQ(lights[2].mDirection.z, -1.0f);
}

View file

@ -0,0 +1,146 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/Importer.hpp>
class BlendImportMaterials : public ::testing::Test {
public:
void SetUp() override {
im = new Assimp::Importer();
}
void TearDown() override {
delete im;
}
protected:
Assimp::Importer *im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportMaterials, testImportMaterial) {
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != nullptr);
ASSERT_TRUE(pTest->HasMaterials());
ASSERT_EQ(1U, pTest->mNumMaterials);
auto alpha = pTest->mMaterials[0];
#define ASSERT_PROPERTY_EQ(expected, key, var) \
auto var = expected; \
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
ASSERT_EQ(expected, var);
#define ASSERT_PROPERTY_FLOAT_EQ(expected, key, var) \
auto var = expected; \
ASSERT_EQ(aiReturn_SUCCESS, alpha->Get("$mat.blend." key, 0, 0, var)); \
ASSERT_FLOAT_EQ(expected, var);
ASSERT_PROPERTY_EQ(aiColor3D(0.1f, 0.2f, 0.3f), "diffuse.color", diffuseColor);
ASSERT_PROPERTY_EQ(0.4f, "diffuse.intensity", diffuseIntensity);
ASSERT_PROPERTY_EQ(1, "diffuse.shader", diffuseShader);
ASSERT_PROPERTY_EQ(0, "diffuse.ramp", diffuseRamp);
ASSERT_PROPERTY_EQ(aiColor3D(0.5f, 0.6f, 0.7f), "specular.color", specularColor);
ASSERT_PROPERTY_EQ(0.8f, "specular.intensity", specularIntensity);
ASSERT_PROPERTY_EQ(1, "specular.shader", specularShader);
ASSERT_PROPERTY_EQ(0, "specular.ramp", specularRamp);
ASSERT_PROPERTY_EQ(9, "specular.hardness", specularHardness);
ASSERT_PROPERTY_EQ(1, "transparency.use", transparencyUse);
ASSERT_PROPERTY_EQ(2, "transparency.method", transparencyMethod);
ASSERT_PROPERTY_EQ(0.01f, "transparency.alpha", transparencyAlpha);
ASSERT_PROPERTY_EQ(0.02f, "transparency.specular", transparencySpecular);
ASSERT_PROPERTY_EQ(0.03f, "transparency.fresnel", transparencyFresnel);
ASSERT_PROPERTY_EQ(3.14f, "transparency.blend", transparencyBlend);
ASSERT_PROPERTY_EQ(0.85f, "transparency.ior", transparencyIor);
ASSERT_PROPERTY_FLOAT_EQ(0.128f, "transparency.filter", transparencyFilter);
ASSERT_PROPERTY_FLOAT_EQ(1.298f, "transparency.falloff", transparencyFalloff);
ASSERT_PROPERTY_FLOAT_EQ(0.2376f, "transparency.limit", transparencyLimit);
ASSERT_PROPERTY_EQ(7, "transparency.depth", transparencyDepth);
ASSERT_PROPERTY_FLOAT_EQ(0.678f, "transparency.glossAmount", transparencyGlossAmount);
ASSERT_PROPERTY_FLOAT_EQ(0.208f, "transparency.glossThreshold", transparencyGlossThreshold);
ASSERT_PROPERTY_EQ(17, "transparency.glossSamples", transparencyGlossSamples);
ASSERT_PROPERTY_EQ(1, "mirror.use", mirrorUse);
ASSERT_PROPERTY_FLOAT_EQ(0.28f, "mirror.reflectivity", mirrorReflectivity);
ASSERT_PROPERTY_EQ(aiColor3D(0.25f, 0.5f, 0.128f), "mirror.color", mirrorColor);
ASSERT_PROPERTY_FLOAT_EQ(0.256f, "mirror.fresnel", mirrorFresnel);
ASSERT_PROPERTY_FLOAT_EQ(1.61f, "mirror.blend", mirrorBlend);
ASSERT_PROPERTY_EQ(12, "mirror.depth", mirrorDepth);
ASSERT_PROPERTY_FLOAT_EQ(0.4f, "mirror.maxDist", mirrorMaxDist);
ASSERT_PROPERTY_EQ(1, "mirror.fadeTo", mirrorFadeTo);
ASSERT_PROPERTY_FLOAT_EQ(0.512f, "mirror.glossAmount", mirrorGlossAmount);
ASSERT_PROPERTY_FLOAT_EQ(0.18f, "mirror.glossThreshold", mirrorGlossThreshold);
ASSERT_PROPERTY_EQ(61, "mirror.glossSamples", mirrorGlossSamples);
ASSERT_PROPERTY_FLOAT_EQ(0.87f, "mirror.glossAnisotropic", mirrorGlossAnisotropic);
}
TEST_F(BlendImportMaterials, testImportMaterialwith2texturesAnd2TexCoordMappings) {
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/plane_2_textures_2_texcoords_279.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != nullptr);
// material has 2 diffuse textures
ASSERT_TRUE(pTest->HasMaterials());
EXPECT_EQ(1u, pTest->mNumMaterials);
const aiMaterial *pMat = pTest->mMaterials[0];
ASSERT_TRUE(nullptr != pMat);
ASSERT_EQ(2u, pMat->GetTextureCount(aiTextureType_DIFFUSE));
aiString aPath;
aiTextureMapping tm = aiTextureMapping::aiTextureMapping_OTHER;
aiReturn result = pMat->GetTexture(aiTextureType_DIFFUSE, 0, &aPath, &tm);
ASSERT_EQ(aiReturn_SUCCESS, result);
result = pMat->GetTexture(aiTextureType_DIFFUSE, 1, &aPath, &tm);
ASSERT_EQ(aiReturn_SUCCESS, result);
// mesh has 2 texturecoord sets
ASSERT_TRUE(pTest->HasMeshes());
EXPECT_EQ(1u, pTest->mNumMeshes);
const aiMesh *pMesh = pTest->mMeshes[0];
ASSERT_TRUE(nullptr != pMesh);
ASSERT_TRUE(pMesh->HasTextureCoords(0));
ASSERT_TRUE(pMesh->HasTextureCoords(1));
}

View file

@ -0,0 +1,244 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/SpatialSort.h>
using namespace Assimp;
class utBlenderImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utBlenderImporterExporter, importBlenFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST(utBlenderImporter, import4cubes) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/4Cubes4Mats_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, import269_regress1) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/blender_269_regress1.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault250) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault250Compressed) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_250_Compressed.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault262) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_262.blend", aiProcess_ValidateDataStructure);
// FIXME: this is probably not right, loading this should succeed
ASSERT_EQ(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault269) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_269.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault271) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_271.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBlenderDefault293) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderDefault_276.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importCubeHierarchy_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/CubeHierarchy_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importHuman) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/HUMAN.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importMirroredCube_252) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/MirroredCube_252.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importNoisyTexturedCube_VoronoiGlob_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/NoisyTexturedCube_VoronoiGlob_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importSmoothVsSolidCube_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SmoothVsSolidCube_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importSuzanne_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/Suzanne_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importSuzanneSubdiv_252) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/SuzanneSubdiv_252.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
// check approximate shape by averaging together all vertices
ASSERT_EQ(scene->mNumMeshes, 1u);
aiVector3D vertexAvg(0.0, 0.0, 0.0);
for (unsigned int i = 0; i < scene->mNumMeshes; i++) {
const aiMesh *mesh = scene->mMeshes[i];
ASSERT_NE(mesh, nullptr);
ai_real invVertexCount = 1.0 / mesh->mNumVertices;
for (unsigned int j = 0; j < mesh->mNumVertices; j++) {
vertexAvg += mesh->mVertices[j] * invVertexCount;
}
}
// must not be inf or nan
ASSERT_TRUE(std::isfinite(vertexAvg.x));
ASSERT_TRUE(std::isfinite(vertexAvg.y));
ASSERT_TRUE(std::isfinite(vertexAvg.z));
EXPECT_NEAR(vertexAvg.x, 6.4022515289252624e-08, 0.0001);
EXPECT_NEAR(vertexAvg.y, 0.060569953173398972, 0.0001);
EXPECT_NEAR(vertexAvg.z, 0.31429031491279602, 0.0001);
}
TEST(utBlenderImporter, importTexturedCube_ImageGlob_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedCube_ImageGlob_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importTexturedPlane_ImageUv_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUv_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importTexturedPlane_ImageUvPacked_248) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TexturedPlane_ImageUvPacked_248.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importTorusLightsCams_250_compressed) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/TorusLightsCams_250_compressed.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, import_yxa_1) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/yxa_1.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importBob) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/Bob.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utBlenderImporter, importFleurOptonl) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/fleurOptonl.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
/// This test contains a default cube with subdivision surface modifier and a default cube with subdivision surface applied.
/// Vertices should be identical.
TEST_F(utBlenderImporterExporter, importBlendWithSubdivisionSurface) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/subdivision_test_277.blend", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 2u);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, scene->mMeshes[1]->mNumVertices);
SpatialSort spatialSortVertices0;
spatialSortVertices0.Fill(scene->mMeshes[0]->mVertices, scene->mMeshes[0]->mNumVertices, sizeof(aiVector3D), true);
for (unsigned int i = 0; i < scene->mMeshes[1]->mNumVertices; ++i)
{
auto positionMesh1 = scene->mMeshes[1]->mVertices[i];
std::vector<unsigned int> spatialSortResult;
spatialSortVertices0.FindPositions(positionMesh1, 1.0e-6f, spatialSortResult);
EXPECT_TRUE(scene->mMeshes[0]->mVertices[spatialSortResult[0]].Equal(positionMesh1));
}
}

View file

@ -0,0 +1,78 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "AssetLib/Blender/BlenderIntermediate.h"
#include <assimp/camera.h>
#include <assimp/light.h>
#include <assimp/mesh.h>
#include <assimp/texture.h>
using namespace ::Assimp;
using namespace ::Assimp::Blender;
class BlenderIntermediateTest : public ::testing::Test {
// empty
};
#define NAME_1 "name1"
#define NAME_2 "name2"
// Updated this test after fixing #1776:
// A comparator in C++ is used for ordering and must implement strict weak ordering,
// which means it must return false for equal values.
// The C++ standard defines and expects this behavior: true if lhs < rhs, false otherwise.
TEST_F(BlenderIntermediateTest, ConversionData_ObjectCompareTest) {
Object obj1, obj2;
strncpy(obj1.id.name, NAME_1, sizeof(obj1.id.name));
strncpy(obj2.id.name, NAME_2, sizeof(obj2.id.name));
Blender::ObjectCompare cmp_true_because_first_is_smaller_than_second;
bool res(cmp_true_because_first_is_smaller_than_second(&obj1, &obj2));
EXPECT_TRUE(res);
Blender::ObjectCompare cmp_false_because_equal;
res = cmp_false_because_equal(&obj1, &obj1);
EXPECT_FALSE(res);
Blender::ObjectCompare cmp_false_because_first_is_greater_than_second;
res = cmp_false_because_first_is_greater_than_second(&obj2, &obj1);
EXPECT_FALSE(res);
}

View file

@ -0,0 +1,76 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/Importer.hpp>
using namespace ::Assimp;
class BlenderWorkTest : public ::testing::Test {
public:
BlenderWorkTest() : im(nullptr) {}
~BlenderWorkTest() override = default;
void SetUp() override {
im = new Assimp::Importer();
}
void TearDown() override {
delete im;
}
protected:
Assimp::Importer *im;
};
TEST_F(BlenderWorkTest, work_279) {
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/test_279.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != nullptr);
// material has 2 diffuse textures
ASSERT_TRUE(pTest->HasMaterials());
ASSERT_TRUE(pTest->HasMeshes());
ASSERT_TRUE(pTest->mMeshes[0]->mNumVertices > 0);
ASSERT_EQ(44u, pTest->mMeshes[0]->mNumFaces);
EXPECT_EQ(1u, pTest->mNumMaterials);
}

View file

@ -0,0 +1,60 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utCSMImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utCSMImportExport, importBlenFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,231 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/cexport.h>
#include <assimp/commonMetaData.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <array>
#ifndef ASSIMP_BUILD_NO_EXPORT
class utColladaExport : public ::testing::Test {
public:
void SetUp() override {
ex = new Assimp::Exporter();
im = new Assimp::Importer();
}
void TearDown() override {
delete ex;
ex = nullptr;
delete im;
im = nullptr;
}
protected:
Assimp::Exporter *ex;
Assimp::Importer *im;
};
TEST_F(utColladaExport, testExportCamera) {
const char *file = "cameraExp.dae";
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]);
for (size_t i = 0; i < origNumCams; i++) {
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;
}
const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, imported);
EXPECT_TRUE(imported->HasCameras());
EXPECT_EQ(origNumCams, imported->mNumCameras);
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_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);
}
// Cleanup, delete the exported file
EXPECT_EQ(0, std::remove(file));
}
// ------------------------------------------------------------------------------------------------
TEST_F(utColladaExport, testExportLight) {
const char *file = "lightsExp.dae";
const aiScene *pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure);
ASSERT_NE(pTest, nullptr);
ASSERT_TRUE(pTest->HasLights());
const unsigned int origNumLights = pTest->mNumLights;
// There are FIVE!!! LIGHTS!!!
EXPECT_EQ(5u, origNumLights) << "lights.dae should contain five lights";
std::vector<aiLight> origLights(5);
for (size_t i = 0; i < origNumLights; i++) {
origLights[i] = *(pTest->mLights[i]);
}
// Check loaded first light properly
EXPECT_STREQ("Lamp", origLights[0].mName.C_Str());
EXPECT_EQ(aiLightSource_POINT, origLights[0].mType);
EXPECT_FLOAT_EQ(1.0f, origLights[0].mAttenuationConstant);
EXPECT_FLOAT_EQ(0.0f, origLights[0].mAttenuationLinear);
EXPECT_FLOAT_EQ(0.00111109f, origLights[0].mAttenuationQuadratic);
// Common metadata
// Confirm was loaded by the Collada importer
aiString origImporter;
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, origImporter)) << "No importer format metadata";
EXPECT_STREQ("Collada Importer", origImporter.C_Str());
aiString origGenerator;
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, origGenerator)) << "No generator metadata";
EXPECT_EQ(strncmp(origGenerator.C_Str(), "Blender", 7), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << origGenerator.C_Str();
aiString origCopyright;
EXPECT_TRUE(pTest->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, origCopyright)) << "No copyright metadata";
EXPECT_STREQ("BSD", origCopyright.C_Str());
aiString origCreated;
EXPECT_TRUE(pTest->mMetaData->Get("Created", origCreated)) << "No created metadata";
EXPECT_STREQ("2015-05-17T21:55:44", origCreated.C_Str());
aiString origModified;
EXPECT_TRUE(pTest->mMetaData->Get("Modified", origModified)) << "No modified metadata";
EXPECT_STREQ("2015-05-17T21:55:44", origModified.C_Str());
EXPECT_EQ(AI_SUCCESS, ex->Export(pTest, "collada", file));
// Drop the pointer as about to become invalid
pTest = nullptr;
const aiScene *imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported != nullptr);
// Check common metadata survived roundtrip
aiString readImporter;
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, readImporter)) << "No importer format metadata after export";
EXPECT_STREQ(origImporter.C_Str(), readImporter.C_Str()) << "Assimp Importer Format changed";
aiString readGenerator;
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, readGenerator)) << "No generator metadata";
EXPECT_STREQ(origGenerator.C_Str(), readGenerator.C_Str()) << "Generator changed";
aiString readCopyright;
EXPECT_TRUE(imported->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, readCopyright)) << "No copyright metadata";
EXPECT_STREQ(origCopyright.C_Str(), readCopyright.C_Str()) << "Copyright changed";
aiString readCreated;
EXPECT_TRUE(imported->mMetaData->Get("Created", readCreated)) << "No created metadata";
EXPECT_STREQ(origCreated.C_Str(), readCreated.C_Str()) << "Created date changed";
aiString readModified;
EXPECT_TRUE(imported->mMetaData->Get("Modified", readModified)) << "No modified metadata";
EXPECT_STRNE(origModified.C_Str(), readModified.C_Str()) << "Modified date did not change";
EXPECT_GT(readModified.length, ai_uint32(18)) << "Modified date too short";
// Lights
EXPECT_TRUE(imported->HasLights());
EXPECT_EQ(origNumLights, imported->mNumLights);
for (size_t i = 0; i < origNumLights; i++) {
const aiLight *orig = &origLights[i];
const aiLight *read = imported->mLights[i];
EXPECT_EQ(0, strcmp(orig->mName.C_Str(), read->mName.C_Str()));
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);
EXPECT_FLOAT_EQ(orig->mColorAmbient.r, read->mColorAmbient.r);
EXPECT_FLOAT_EQ(orig->mColorAmbient.g, read->mColorAmbient.g);
EXPECT_FLOAT_EQ(orig->mColorAmbient.b, read->mColorAmbient.b);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.r, read->mColorDiffuse.r);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.g, read->mColorDiffuse.g);
EXPECT_FLOAT_EQ(orig->mColorDiffuse.b, read->mColorDiffuse.b);
EXPECT_FLOAT_EQ(orig->mColorSpecular.r, read->mColorSpecular.r);
EXPECT_FLOAT_EQ(orig->mColorSpecular.g, read->mColorSpecular.g);
EXPECT_FLOAT_EQ(orig->mColorSpecular.b, read->mColorSpecular.b);
EXPECT_NEAR(orig->mAngleInnerCone, read->mAngleInnerCone, 0.001);
EXPECT_NEAR(orig->mAngleOuterCone, read->mAngleOuterCone, 0.001);
}
// Cleanup, delete the exported file
EXPECT_EQ(0, std::remove(file));
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,452 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/ColladaMetaData.h>
#include <assimp/SceneCombiner.h>
#include <assimp/commonMetaData.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utColladaImportExport : public AbstractImportExportBase {
public:
// Clones the scene in an exception-safe way
struct SceneCloner {
SceneCloner(const aiScene *scene) {
sceneCopy = nullptr;
SceneCombiner::CopyScene(&sceneCopy, scene);
}
~SceneCloner() {
delete sceneCopy;
sceneCopy = nullptr;
}
aiScene *sceneCopy;
};
bool importerTest() final {
Importer importer;
{
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure);
if (scene == nullptr) {
return false;
}
// Expected number of items
EXPECT_EQ(scene->mNumMeshes, 1u);
EXPECT_EQ(scene->mNumMaterials, 1u);
EXPECT_EQ(scene->mNumAnimations, 0u);
EXPECT_EQ(scene->mNumTextures, 0u);
EXPECT_EQ(scene->mNumLights, 1u);
EXPECT_EQ(scene->mNumCameras, 1u);
// Expected common metadata
aiString value;
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, value)) << "No importer format metadata";
EXPECT_STREQ("Collada Importer", value.C_Str());
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, value)) << "No format version metadata";
EXPECT_STREQ("1.4.1", value.C_Str());
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, value)) << "No generator metadata";
EXPECT_EQ(strncmp(value.C_Str(), "Maya 8.0", 8), 0) << "AI_METADATA_SOURCE_GENERATOR was: " << value.C_Str();
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, value)) << "No copyright metadata";
EXPECT_EQ(strncmp(value.C_Str(), "Copyright 2006", 14), 0) << "AI_METADATA_SOURCE_COPYRIGHT was: " << value.C_Str();
}
{
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/box_nested_animation.dae", aiProcess_ValidateDataStructure);
if (scene == nullptr) {
return false;
}
// Expect only one animation with the correct name
EXPECT_EQ(scene->mNumAnimations, 1u);
EXPECT_EQ(std::string(scene->mAnimations[0]->mName.C_Str()), std::string("Armature"));
}
return true;
}
using IdNameString = std::pair<std::string, std::string>;
using IdNameMap = std::map<std::string, std::string>;
template <typename T>
static IdNameString GetColladaIdName(const T *item, size_t index) {
std::ostringstream stream;
stream << typeid(T).name() << "@" << index;
if (item->mMetaData) {
if (aiString aiStr; item->mMetaData->Get(AI_METADATA_COLLADA_ID, aiStr)) {
return std::make_pair(std::string(aiStr.C_Str()), stream.str());
}
}
return std::make_pair(std::string(), stream.str());
}
template <typename T>
static IdNameString GetItemIdName(const T *item, size_t index) {
std::ostringstream stream;
stream << typeid(T).name() << "@" << index;
return std::make_pair(std::string(item->mName.C_Str()), stream.str());
}
// Specialisations
static IdNameString GetItemIdName(aiMaterial *item, size_t index) {
std::ostringstream stream;
stream << typeid(aiMaterial).name() << "@" << index;
return std::make_pair(std::string(item->GetName().C_Str()), stream.str());
}
static IdNameString GetItemIdName(const aiTexture *item, size_t index) {
std::ostringstream stream;
stream << typeid(aiTexture).name() << "@" << index;
return std::make_pair(std::string(item->mFilename.C_Str()), stream.str());
}
static void ReportDuplicate(IdNameMap &itemIdMap, const IdNameString &namePair, const char *typeNameStr) {
const auto result = itemIdMap.insert(namePair);
EXPECT_TRUE(result.second) << "Duplicate '" << typeNameStr << "' name: '" << namePair.first << "'. " << namePair.second << " == " << result.first->second;
}
template <typename T>
static void CheckUniqueIds(IdNameMap &itemIdMap, unsigned int itemCount, T **itemArray) {
for (size_t idx = 0; idx < itemCount; ++idx) {
IdNameString namePair = GetItemIdName(itemArray[idx], idx);
ReportDuplicate(itemIdMap, namePair, typeid(T).name());
}
}
static void CheckUniqueIds(IdNameMap &itemIdMap, const aiNode *parent, size_t index) {
IdNameString namePair = GetItemIdName(parent, index);
ReportDuplicate(itemIdMap, namePair, typeid(aiNode).name());
for (size_t idx = 0; idx < parent->mNumChildren; ++idx) {
CheckUniqueIds(itemIdMap, parent->mChildren[idx], idx);
}
}
static void CheckNodeIdNames(IdNameMap &nodeIdMap, IdNameMap &nodeNameMap, const aiNode *parent, size_t index) {
IdNameString namePair = GetItemIdName(parent, index);
IdNameString idPair = GetColladaIdName(parent, index);
ReportDuplicate(nodeIdMap, idPair, typeid(aiNode).name());
for (size_t idx = 0; idx < parent->mNumChildren; ++idx) {
CheckNodeIdNames(nodeIdMap, nodeNameMap, parent->mChildren[idx], idx);
}
}
static void SetAllNodeNames(const aiString &newName, aiNode *node) {
node->mName = newName;
for (size_t idx = 0; idx < node->mNumChildren; ++idx) {
SetAllNodeNames(newName, node->mChildren[idx]);
}
}
void ImportAndCheckIds(const char *file, const aiScene *origScene) {
// Import the Collada using the 'default' where aiNode and aiMesh names are the Collada ids
Importer importer;
const aiScene *scene = importer.ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene != nullptr) << "Fatal: could not re-import " << file;
EXPECT_EQ(origScene->mNumMeshes, scene->mNumMeshes) << "in " << file;
// Check the ids are unique
IdNameMap itemIdMap;
// Recurse the Nodes
CheckUniqueIds(itemIdMap, scene->mRootNode, 0);
// Check the lists
CheckUniqueIds(itemIdMap, scene->mNumMeshes, scene->mMeshes);
// The remaining will come in using the name, which may not be unique
// Check we have the right number
EXPECT_EQ(origScene->mNumAnimations, scene->mNumAnimations);
EXPECT_EQ(origScene->mNumMaterials, scene->mNumMaterials);
EXPECT_EQ(origScene->mNumTextures, scene->mNumTextures);
EXPECT_EQ(origScene->mNumLights, scene->mNumLights);
EXPECT_EQ(origScene->mNumCameras, scene->mNumCameras);
}
void ImportAsNames(const char *file, const aiScene *origScene) {
// Import the Collada but using the user-visible names for aiNode and aiMesh
// Note that this mode may not support bones or animations
Importer importer;
importer.SetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES, 1);
const aiScene *scene = importer.ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene != nullptr) << "Fatal: could not re-import " << file;
EXPECT_EQ(origScene->mNumMeshes, scene->mNumMeshes) << "in " << file;
// Check the node ids are unique but the node names are not
IdNameMap nodeIdMap;
IdNameMap nodeNameMap;
// Recurse the Nodes
CheckNodeIdNames(nodeIdMap, nodeNameMap, scene->mRootNode, 0);
// nodeNameMap should have fewer than nodeIdMap
EXPECT_LT(nodeNameMap.size(), nodeIdMap.size()) << "Some nodes should have the same names";
// Check the counts haven't changed
EXPECT_EQ(origScene->mNumAnimations, scene->mNumAnimations);
EXPECT_EQ(origScene->mNumMaterials, scene->mNumMaterials);
EXPECT_EQ(origScene->mNumTextures, scene->mNumTextures);
EXPECT_EQ(origScene->mNumLights, scene->mNumLights);
EXPECT_EQ(origScene->mNumCameras, scene->mNumCameras);
}
};
TEST_F(utColladaImportExport, importDaeFromFileTest) {
EXPECT_TRUE(importerTest());
}
unsigned int GetMeshUseCount(const aiNode *rootNode) {
unsigned int result = rootNode->mNumMeshes;
for (unsigned int i = 0; i < rootNode->mNumChildren; ++i) {
result += GetMeshUseCount(rootNode->mChildren[i]);
}
return result;
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utColladaImportExport, exportRootNodeMeshTest) {
Importer importer;
Exporter exporter;
const char *outFile = "exportRootNodeMeshTest_out.dae";
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene != nullptr) << "Fatal: could not import duck.dae!";
ASSERT_EQ(0u, scene->mRootNode->mNumMeshes) << "Collada import should not give the root node a mesh";
{
SceneCloner clone(scene);
ASSERT_TRUE(clone.sceneCopy != nullptr) << "Fatal: could not copy scene!";
// Do this by moving the meshes from the first child that has some
aiNode *rootNode = clone.sceneCopy->mRootNode;
ASSERT_TRUE(rootNode->mNumChildren > 0) << "Fatal: root has no children";
aiNode *meshNode = rootNode->mChildren[0];
ASSERT_EQ(1u, meshNode->mNumMeshes) << "Fatal: First child node has no duck mesh";
// Move the meshes to the parent
rootNode->mNumMeshes = meshNode->mNumMeshes;
rootNode->mMeshes = new unsigned int[rootNode->mNumMeshes];
for (unsigned int i = 0; i < rootNode->mNumMeshes; ++i) {
rootNode->mMeshes[i] = meshNode->mMeshes[i];
}
// Remove the meshes from the original node
meshNode->mNumMeshes = 0;
delete[] meshNode->mMeshes;
meshNode->mMeshes = nullptr;
ASSERT_EQ(AI_SUCCESS, exporter.Export(clone.sceneCopy, "collada", outFile)) << "Fatal: Could not export file";
}
// Reimport and look for meshes
scene = importer.ReadFile(outFile, aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene != nullptr) << "Fatal: could not reimport!";
// A Collada root node is not allowed to have a mesh
ASSERT_EQ(0u, scene->mRootNode->mNumMeshes) << "Collada reimport should not give the root node a mesh";
// Walk nodes and counts used meshes
// Should be exactly one
EXPECT_EQ(1u, GetMeshUseCount(scene->mRootNode)) << "Nodes had unexpected number of meshes in use";
}
TEST_F(utColladaImportExport, exporterUniqueIdsTest) {
Importer importer;
Exporter exporter;
const char *outFileEmpty = "exportMeshIdTest_empty_out.dae";
const char *outFileNamed = "exportMeshIdTest_named_out.dae";
// Load a sample file containing multiple meshes
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/teapots.DAE", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene != nullptr) << "Fatal: could not import teapots.DAE!";
ASSERT_EQ(3u, scene->mNumMeshes) << "Fatal: teapots.DAE initial load failed";
// Clear all the names
for (size_t idx = 0; idx < scene->mNumMeshes; ++idx) {
scene->mMeshes[idx]->mName.Clear();
}
for (size_t idx = 0; idx < scene->mNumMaterials; ++idx) {
scene->mMaterials[idx]->RemoveProperty(AI_MATKEY_NAME);
}
for (size_t idx = 0; idx < scene->mNumAnimations; ++idx) {
scene->mAnimations[idx]->mName.Clear();
}
// Can't clear texture names
for (size_t idx = 0; idx < scene->mNumLights; ++idx) {
scene->mLights[idx]->mName.Clear();
}
for (size_t idx = 0; idx < scene->mNumCameras; ++idx) {
scene->mCameras[idx]->mName.Clear();
}
SetAllNodeNames(aiString(), scene->mRootNode);
ASSERT_EQ(AI_SUCCESS, exporter.Export(scene, "collada", outFileEmpty)) << "Fatal: Could not export un-named meshes file";
ImportAndCheckIds(outFileEmpty, scene);
// Force everything to have the same non-empty name
aiString testName("test_name");
for (size_t idx = 0; idx < scene->mNumMeshes; ++idx) {
scene->mMeshes[idx]->mName = testName;
}
for (size_t idx = 0; idx < scene->mNumMaterials; ++idx) {
scene->mMaterials[idx]->AddProperty(&testName, AI_MATKEY_NAME);
}
for (size_t idx = 0; idx < scene->mNumAnimations; ++idx) {
scene->mAnimations[idx]->mName = testName;
}
// Can't clear texture names
for (size_t idx = 0; idx < scene->mNumLights; ++idx) {
scene->mLights[idx]->mName = testName;
}
for (size_t idx = 0; idx < scene->mNumCameras; ++idx) {
scene->mCameras[idx]->mName = testName;
}
SetAllNodeNames(testName, scene->mRootNode);
ASSERT_EQ(AI_SUCCESS, exporter.Export(scene, "collada", outFileNamed)) << "Fatal: Could not export named meshes file";
ImportAndCheckIds(outFileNamed, scene);
ImportAsNames(outFileNamed, scene);
}
// This file is invalid, we just want to ensure that the importer is not crashing
// This was reported as GH#4286. The "count" parameter in "Cube-mesh-positions-array" is too small.
TEST_F(utColladaImportExport, parseInvalid4286) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/invalid/box_nested_animation_4286.dae", 0);
EXPECT_EQ(nullptr, scene);
}
#endif
class utColladaZaeImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() final {
{
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck.zae", aiProcess_ValidateDataStructure);
if (scene == nullptr)
return false;
// Expected number of items
EXPECT_EQ(scene->mNumMeshes, 1u);
EXPECT_EQ(scene->mNumMaterials, 1u);
EXPECT_EQ(scene->mNumAnimations, 0u);
//EXPECT_EQ(scene->mNumTextures, 1u);
EXPECT_EQ(scene->mNumLights, 1u);
EXPECT_EQ(scene->mNumCameras, 1u);
}
{
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/duck_nomanifest.zae", aiProcess_ValidateDataStructure);
if (scene == nullptr)
return false;
// Expected number of items
EXPECT_EQ(scene->mNumMeshes, 1u);
EXPECT_EQ(scene->mNumMaterials, 1u);
EXPECT_EQ(scene->mNumAnimations, 0u);
//EXPECT_EQ(scene->mNumTextures, 1u);
EXPECT_EQ(scene->mNumLights, 1u);
EXPECT_EQ(scene->mNumCameras, 1u);
}
return true;
}
};
TEST_F(utColladaZaeImportExport, importBlenFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utColladaZaeImportExport, importMakeHumanTest) {
Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/human.zae", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
// Expected number of items
EXPECT_EQ(scene->mNumMeshes, 2u);
EXPECT_EQ(scene->mNumMaterials, 2u);
EXPECT_EQ(scene->mNumAnimations, 0u);
EXPECT_EQ(scene->mNumTextures, 2u);
EXPECT_EQ(scene->mNumLights, 0u);
EXPECT_EQ(scene->mNumCameras, 0u);
// Expected common metadata
aiString value;
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, value)) << "No importer format metadata";
EXPECT_STREQ("Collada Importer", value.C_Str());
EXPECT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, value)) << "No format version metadata";
EXPECT_STREQ("1.4.1", value.C_Str());
}
static constexpr char kData[] = " \
<?xml version=\"1.0\" encoding=\"utf-8\"?> \
<COLLADA version=\"1.4.1\"> \
<library_geometries> \
<geometry id=\"fuzz2772-geo\" name=\"fuzz2772\"> \
<mesh> \
<triangles count=\"1\"><input semantic=\"VERTEXERTEX\" source=\"#fuzz2772-verts\" offset=\"0\"/><p>0 1 2</p></triangles> \
</mesh> \
</geometry> \
</library_geometries> \
</COLLADA> \
";
TEST_F(utColladaZaeImportExport, import_causes_heap_overflow_issue6373) {
Importer importer;
const aiScene *scene = importer.ReadFileFromMemory(kData, sizeof(kData), aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}

View file

@ -0,0 +1,99 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include "AssetLib/3MF/D3MFExporter.h"
class utD3MFImporterExporter : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", aiProcess_ValidateDataStructure);
if (nullptr == scene) {
return false;
}
EXPECT_EQ(1u, scene->mNumMeshes);
aiMesh *mesh = scene->mMeshes[0];
EXPECT_NE(nullptr, mesh);
EXPECT_EQ(12u, mesh->mNumFaces);
EXPECT_EQ(8u, mesh->mNumVertices);
return (nullptr != scene);
}
#ifndef ASSIMP_BUILD_NO_EXPORT
bool exporterTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0);
Assimp::Exporter exporter;
return AI_SUCCESS == exporter.Export(scene, "3mf", "test.3mf");
}
#endif // ASSIMP_BUILD_NO_EXPORT
};
TEST_F(utD3MFImporterExporter, import3MFFromFileTest) {
EXPECT_TRUE(importerTest());
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utD3MFImporterExporter, export3MFtoMemTest) {
//EXPECT_TRUE(exporterTest());
}
TEST_F(utD3MFImporterExporter, roundtrip3MFtoMemTest) {
/*EXPECT_TRUE(exporterTest());
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile("test.3mf", 0);
EXPECT_NE(nullptr, scene));*/
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,87 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utDXFImporterExporter : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utDXFImporterExporter, importDXFFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utDXFImporterExporter, importerWithoutExtensionTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/lineTest", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utDXFImporterExporter, issue2229) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/issue_2229.dxf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utDXFImporterExporter, importWuson) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/DXF/wuson.dxf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utDXFImporterExporter, importRifle) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/DXF/rifle.dxf", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,85 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------*/
#include <gtest/gtest.h>
#include "TestIOStream.h"
#include "UnitTestFileGenerator.h"
#include "Tools/TestTools.h"
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace ::Assimp;
class utDefaultIOStream : public ::testing::Test {
// empty
};
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
itor sapien ornare sagittis volutpat."};
TEST_F( utDefaultIOStream, FileSizeTest ) {
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fpath[] = { TMP_PATH"rndfp.XXXXXX\0" };
std::string tmpName;
auto *fs = MakeTmpFile(fpath, std::strlen(fpath), tmpName);
ASSERT_NE(nullptr, fs);
{
auto written = std::fwrite(data, sizeof(*data), dataCount, fs );
EXPECT_NE( 0U, written );
auto vflush = std::fflush( fs );
ASSERT_EQ(vflush, 0);
std::fclose(fs);
EXPECT_TRUE(Unittest::TestTools::openFilestream(&fs, tmpName.c_str(), "r"));
ASSERT_NE(nullptr, fs);
TestDefaultIOStream myStream( fs, fpath);
size_t size = myStream.FileSize();
EXPECT_EQ( size, dataSize);
}
remove(tmpName.c_str());
}

114
vendor/assimp/test/unit/utExport.cpp vendored Normal file
View file

@ -0,0 +1,114 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/cexport.h>
#include <assimp/Exporter.hpp>
#ifndef ASSIMP_BUILD_NO_EXPORT
class ExporterTest : public ::testing::Test {
public:
void SetUp() override {
ex = new Assimp::Exporter();
im = new Assimp::Importer();
pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure);
}
void TearDown() override {
delete ex;
delete im;
}
protected:
const aiScene* pTest;
Assimp::Exporter* ex;
Assimp::Importer* im;
};
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testExportToFile) {
const char* file = "unittest_output.dae";
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
// check if we can read it again
EXPECT_TRUE(im->ReadFile(file, aiProcess_ValidateDataStructure));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testExportToBlob) {
const aiExportDataBlob* blob = ex->ExportToBlob(pTest,"collada");
ASSERT_TRUE(blob);
EXPECT_TRUE(blob->data);
EXPECT_GT(blob->size, 0U);
EXPECT_EQ(0U, blob->name.length);
// XXX test chained blobs (i.e. obj file with accompanying mtl script)
// check if we can read it again
EXPECT_TRUE(im->ReadFileFromMemory(blob->data,blob->size,0,"dae"));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testCppExportInterface) {
EXPECT_TRUE(ex->GetExportFormatCount() > 0);
for(size_t i = 0; i < ex->GetExportFormatCount(); ++i) {
const aiExportFormatDesc* const desc = ex->GetExportFormatDescription(i);
ASSERT_TRUE(desc);
EXPECT_TRUE(desc->description && strlen(desc->description));
EXPECT_TRUE(desc->fileExtension && strlen(desc->fileExtension));
EXPECT_TRUE(desc->id && strlen(desc->id));
}
EXPECT_TRUE(ex->IsDefaultIOHandler());
}
// ------------------------------------------------------------------------------------------------
TEST_F(ExporterTest, testCExportInterface) {
EXPECT_TRUE(aiGetExportFormatCount() > 0);
for(size_t i = 0; i < aiGetExportFormatCount(); ++i) {
const aiExportFormatDesc* const desc = aiGetExportFormatDescription(i);
EXPECT_TRUE(desc);
}
}
#endif

View file

@ -0,0 +1,463 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/commonMetaData.h>
#include <assimp/material.h>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/types.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utFBXImporterExporter : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utFBXImporterExporter, importXFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utFBXImporterExporter, importBareBoxWithoutColorsAndTextureCoords) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/box.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 1u);
aiMesh *mesh = scene->mMeshes[0];
EXPECT_EQ(mesh->mNumFaces, 12u);
EXPECT_EQ(mesh->mNumVertices, 36u);
}
TEST_F(utFBXImporterExporter, importCubesWithNoNames) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_nonames.fbx", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene);
ASSERT_TRUE(scene->mRootNode);
const auto root = scene->mRootNode;
ASSERT_STREQ(root->mName.C_Str(), "RootNode");
ASSERT_TRUE(root->mChildren);
ASSERT_EQ(root->mNumChildren, 2u);
}
TEST_F(utFBXImporterExporter, importCubesWithUnicodeDuplicatedNames) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_with_names.fbx", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene);
ASSERT_TRUE(scene->mRootNode);
const auto root = scene->mRootNode;
ASSERT_STREQ(root->mName.C_Str(), "RootNode");
ASSERT_TRUE(root->mChildren);
ASSERT_EQ(root->mNumChildren, 2u);
const auto child0 = root->mChildren[0];
ASSERT_TRUE(child0);
ASSERT_STREQ(child0->mName.C_Str(), "Cube2");
ASSERT_TRUE(child0->mChildren);
ASSERT_EQ(child0->mNumChildren, 1u);
const auto child00 = child0->mChildren[0];
ASSERT_TRUE(child00);
ASSERT_STREQ(child00->mName.C_Str(), "\xd0\x9a\xd1\x83\xd0\xb1\x31");
const auto child1 = root->mChildren[1];
ASSERT_TRUE(child1);
ASSERT_STREQ(child1->mName.C_Str(), "Cube3");
ASSERT_TRUE(child1->mChildren);
ASSERT_EQ(child1->mNumChildren, 1u);
const auto child10 = child1->mChildren[0];
ASSERT_TRUE(child10);
ASSERT_STREQ(child10->mName.C_Str(), "\xd0\x9a\xd1\x83\xd0\xb1\x31");
}
TEST_F(utFBXImporterExporter, importCubesComplexTransform) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_with_mirroring_and_pivot.fbx", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene);
ASSERT_TRUE(scene->mRootNode);
const auto root = scene->mRootNode;
ASSERT_STREQ(root->mName.C_Str(), "RootNode");
ASSERT_TRUE(root->mChildren);
ASSERT_EQ(root->mNumChildren, 2u);
const auto child0 = root->mChildren[0];
ASSERT_TRUE(child0);
ASSERT_STREQ(child0->mName.C_Str(), "Cube2");
ASSERT_TRUE(child0->mChildren);
ASSERT_EQ(child0->mNumChildren, 1u);
const auto child00 = child0->mChildren[0];
ASSERT_TRUE(child00);
ASSERT_STREQ(child00->mName.C_Str(), "Cube1");
const auto child1 = root->mChildren[1];
ASSERT_TRUE(child1);
ASSERT_STREQ(child1->mName.C_Str(), "Cube3");
auto parent = child1;
const size_t chain_length = 8u;
const char *chainStr[chain_length] = {
"Cube1_$AssimpFbx$_Translation",
"Cube1_$AssimpFbx$_RotationPivot",
"Cube1_$AssimpFbx$_RotationPivotInverse",
"Cube1_$AssimpFbx$_ScalingOffset",
"Cube1_$AssimpFbx$_ScalingPivot",
"Cube1_$AssimpFbx$_Scaling",
"Cube1_$AssimpFbx$_ScalingPivotInverse",
"Cube1"
};
for (size_t i = 0; i < chain_length; ++i) {
ASSERT_TRUE(parent->mChildren);
ASSERT_EQ(parent->mNumChildren, 1u);
auto node = parent->mChildren[0];
ASSERT_TRUE(node);
ASSERT_STREQ(node->mName.C_Str(), chainStr[i]);
parent = node;
}
ASSERT_EQ(0u, parent->mNumChildren) << "Leaf node";
}
TEST_F(utFBXImporterExporter, importCloseToIdentityTransforms) {
Assimp::Importer importer;
// This was asserting in FBXConverter.cpp because the transforms appeared to be the identity by one test, but not by another.
// This asset should now load successfully.
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/close_to_identity_transforms.fbx", aiProcess_ValidateDataStructure);
ASSERT_TRUE(scene);
}
TEST_F(utFBXImporterExporter, importPhongMaterial) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/phong_cube.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1u, scene->mNumMaterials);
const aiMaterial *mat = scene->mMaterials[0];
EXPECT_NE(nullptr, mat);
float f;
aiColor3D c;
// phong_cube.fbx has all properties defined
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_DIFFUSE, c), aiReturn_SUCCESS);
EXPECT_EQ(c, aiColor3D(0.5, 0.25, 0.25));
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_SPECULAR, c), aiReturn_SUCCESS);
EXPECT_EQ(c, aiColor3D(0.25, 0.25, 0.5));
EXPECT_EQ(mat->Get(AI_MATKEY_SHININESS_STRENGTH, f), aiReturn_SUCCESS);
EXPECT_EQ(f, 0.5f);
EXPECT_EQ(mat->Get(AI_MATKEY_SHININESS, f), aiReturn_SUCCESS);
EXPECT_EQ(f, 10.0f);
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_AMBIENT, c), aiReturn_SUCCESS);
EXPECT_EQ(c, aiColor3D(0.125, 0.25, 0.25));
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_EMISSIVE, c), aiReturn_SUCCESS);
EXPECT_EQ(c, aiColor3D(0.25, 0.125, 0.25));
EXPECT_EQ(mat->Get(AI_MATKEY_COLOR_TRANSPARENT, c), aiReturn_SUCCESS);
EXPECT_EQ(c, aiColor3D(0.75, 0.5, 0.25));
EXPECT_EQ(mat->Get(AI_MATKEY_OPACITY, f), aiReturn_SUCCESS);
EXPECT_EQ(f, 0.5f);
}
TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_NE(nullptr, scene->mMetaData);
float factor(0.0f);
scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_EQ(500.0f, factor);
scene->mMetaData->Set("UnitScaleFactor", factor * 2.0f);
scene->mMetaData->Get("UnitScaleFactor", factor);
EXPECT_EQ(1000.0f, factor);
}
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
// see https://github.com/assimp/assimp/issues/1957
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/embedded_ascii/box.FBX", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1u, scene->mNumMaterials);
aiMaterial *mat = scene->mMaterials[0];
ASSERT_NE(nullptr, mat);
aiString path;
aiTextureMapMode modes[2];
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
ASSERT_STREQ(path.C_Str(), "..\\..\\..\\Desktop\\uv_test.png");
ASSERT_EQ(1u, scene->mNumTextures);
ASSERT_TRUE(scene->mTextures[0]->pcData);
ASSERT_EQ(439176u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression splits data by 512Kb, it should be two parts for this texture";
}
TEST_F(utFBXImporterExporter, importEmbeddedFragmentedAsciiTest) {
// see https://github.com/assimp/assimp/issues/1957
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/embedded_ascii/box_embedded_texture_fragmented.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1u, scene->mNumMaterials);
aiMaterial *mat = scene->mMaterials[0];
ASSERT_NE(nullptr, mat);
aiString path;
aiTextureMapMode modes[2];
ASSERT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
ASSERT_STREQ(path.C_Str(), "paper.png");
ASSERT_EQ(1u, scene->mNumTextures);
ASSERT_TRUE(scene->mTextures[0]->pcData);
ASSERT_EQ(968029u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression splits data by 512Kb, it should be two parts for this texture";
}
TEST_F(utFBXImporterExporter, fbxTokenizeTestTest) {
//Assimp::Importer importer;
//const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/transparentTest2.fbx", aiProcess_ValidateDataStructure);
//EXPECT_NE(nullptr, scene);
}
TEST_F(utFBXImporterExporter, importOrphantEmbeddedTextureTest) {
// see https://github.com/assimp/assimp/issues/1957
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/box_orphant_embedded_texture.fbx", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(1u, scene->mNumMaterials);
aiMaterial *mat = scene->mMaterials[0];
ASSERT_NE(nullptr, mat);
aiString path;
aiTextureMapMode modes[2];
ASSERT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
ASSERT_STREQ(path.C_Str(), "..\\Primitives\\GridGrey.tga");
ASSERT_EQ(1u, scene->mNumTextures);
ASSERT_TRUE(scene->mTextures[0]->pcData);
ASSERT_EQ(9026u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression used for a texture.";
}
TEST_F(utFBXImporterExporter, sceneMetadata) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/global_settings.fbx",
aiProcess_ValidateDataStructure);
ASSERT_NE(scene, nullptr);
ASSERT_NE(scene->mMetaData, nullptr);
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT));
aiString format;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT, format));
ASSERT_EQ(strcmp(format.C_Str(), "Autodesk FBX Importer"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT_VERSION));
aiString version;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_FORMAT_VERSION, version));
ASSERT_EQ(strcmp(version.C_Str(), "7400"), 0);
}
{
ASSERT_TRUE(scene->mMetaData->HasKey(AI_METADATA_SOURCE_GENERATOR));
aiString generator;
ASSERT_TRUE(scene->mMetaData->Get(AI_METADATA_SOURCE_GENERATOR, generator));
ASSERT_EQ(strncmp(generator.C_Str(), "Blender", 7), 0);
}
}
TEST_F(utFBXImporterExporter, importCustomAxes) {
// see https://github.com/assimp/assimp/issues/5494
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/embedded_ascii/box.FBX", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
// The ASCII box has customised the Up and Forward axes, verify that the RootNode transform has applied it
ASSERT_FALSE(scene->mRootNode->mTransformation.IsIdentity()) << "Did not apply the custom axis transform";
aiVector3D upVec{ 0, 0, 1 }; // Up is +Z
aiVector3D forwardVec{ 0, -1, 0 }; // Forward is -Y
aiVector3D rightVec{ 1, 0, 0 }; // Right is +X
aiMatrix4x4 mat(rightVec.x, rightVec.y, rightVec.z, 0.0f,
upVec.x, upVec.y, upVec.z, 0.0f,
forwardVec.x, forwardVec.y, forwardVec.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
EXPECT_EQ(mat, scene->mRootNode->mTransformation);
}
TEST_F(utFBXImporterExporter, importIgnoreCustomAxes) {
// see https://github.com/assimp/assimp/issues/5494
Assimp::Importer importer;
importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION, true);
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/embedded_ascii/box.FBX", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
// Verify that the RootNode transform has NOT applied the custom axes
EXPECT_TRUE(scene->mRootNode->mTransformation.IsIdentity());
}
TEST_F(utFBXImporterExporter, importCubesWithOutOfRangeFloat) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/cubes_with_outofrange_float.fbx", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_TRUE(scene->mRootNode);
}
TEST_F(utFBXImporterExporter, importMaxPbrMaterialsMetalRoughness) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/maxPbrMaterial_metalRough.fbx", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_TRUE(scene->mRootNode);
ASSERT_EQ(scene->mNumMaterials, 1u);
const aiMaterial* mat = scene->mMaterials[0];
aiString texture;
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_BASE_COLOR, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\albedo.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_METALNESS, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\metalness.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_EMISSION_COLOR, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\emission.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_NORMAL_CAMERA, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\normal.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE_ROUGHNESS, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\roughness.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_AMBIENT_OCCLUSION, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\occlusion.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_OPACITY, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\opacity.png"));
// The material contains values for standard properties (e.g. SpecularColor), where 3ds Max has presumably
// used formulas to map the Pbr values into the standard material model. However, the pbr values themselves
// are available in the material as untyped "raw" properties. We check that these are correctly parsed:
aiColor4D baseColor;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|basecolor", aiTextureType_NONE, 0, baseColor), aiReturn_SUCCESS);
EXPECT_EQ(baseColor, aiColor4D(0, 1, 1, 1));
float metalness;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|metalness", aiTextureType_NONE, 0, metalness), aiReturn_SUCCESS);
EXPECT_EQ(metalness, 0.25f);
float roughness;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|roughness", aiTextureType_NONE, 0, roughness), aiReturn_SUCCESS);
EXPECT_EQ(roughness, 0.5f);
int useGlossiness;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|useGlossiness", aiTextureType_NONE, 0, useGlossiness), aiReturn_SUCCESS);
EXPECT_EQ(useGlossiness, 2); // 1 = Roughness map is glossiness, 2 = Roughness map is roughness.
float bumpMapAmt; // Presumably amount.
ASSERT_EQ(mat->Get("$raw.3dsMax|main|bump_map_amt", aiTextureType_NONE, 0, bumpMapAmt), aiReturn_SUCCESS);
EXPECT_EQ(bumpMapAmt, 0.75f);
aiColor4D emitColor;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|emit_color", aiTextureType_NONE, 0, emitColor), aiReturn_SUCCESS);
EXPECT_EQ(emitColor, aiColor4D(1, 1, 0, 1));
}
TEST_F(utFBXImporterExporter, importMaxPbrMaterialsSpecularGloss) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/maxPbrMaterial_specGloss.fbx", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_TRUE(scene->mRootNode);
ASSERT_EQ(scene->mNumMaterials, 1u);
const aiMaterial* mat = scene->mMaterials[0];
aiString texture;
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_BASE_COLOR, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\albedo.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_SPECULAR, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\specular.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_EMISSION_COLOR, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\emission.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_NORMAL_CAMERA, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\normal.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_SHININESS, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\glossiness.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_AMBIENT_OCCLUSION, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\occlusion.png"));
ASSERT_EQ(mat->Get(AI_MATKEY_TEXTURE(aiTextureType_OPACITY, 0), texture), AI_SUCCESS);
EXPECT_EQ(texture, aiString("Textures\\opacity.png"));
// The material contains values for standard properties (e.g. SpecularColor), where 3ds Max has presumably
// used formulas to map the Pbr values into the standard material model. However, the pbr values themselves
// are available in the material as untyped "raw" properties. We check that these are correctly parsed:
aiColor4D baseColor;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|basecolor", aiTextureType_NONE, 0, baseColor), aiReturn_SUCCESS);
EXPECT_EQ(baseColor, aiColor4D(0, 1, 1, 1));
aiColor4D specular;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|Specular", aiTextureType_NONE, 0, specular), aiReturn_SUCCESS);
EXPECT_EQ(specular, aiColor4D(1, 1, 0, 1));
float glossiness;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|glossiness", aiTextureType_NONE, 0, glossiness), aiReturn_SUCCESS);
EXPECT_EQ(glossiness, 0.33f);
int useGlossiness;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|useGlossiness", aiTextureType_NONE, 0, useGlossiness), aiReturn_SUCCESS);
EXPECT_EQ(useGlossiness, 1); // 1 = Glossiness map is glossiness, 2 = Glossiness map is roughness.
float bumpMapAmt; // Presumably amount.
ASSERT_EQ(mat->Get("$raw.3dsMax|main|bump_map_amt", aiTextureType_NONE, 0, bumpMapAmt), aiReturn_SUCCESS);
EXPECT_EQ(bumpMapAmt, 0.66f);
aiColor4D emitColor;
ASSERT_EQ(mat->Get("$raw.3dsMax|main|emit_color", aiTextureType_NONE, 0, emitColor), aiReturn_SUCCESS);
EXPECT_EQ(emitColor, aiColor4D(1, 0, 1, 1));
}
TEST_F(utFBXImporterExporter, importSkeletonTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/animation_with_skeleton.fbx", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_TRUE(scene->mRootNode);
}

189
vendor/assimp/test/unit/utFastAtof.cpp vendored Normal file
View file

@ -0,0 +1,189 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/fast_atof.h>
namespace {
template <typename Real>
bool IsNan(Real x) {
return x != x;
}
template <typename Real>
bool IsInf(Real x) {
return std::abs(x) == std::numeric_limits<Real>::infinity();
}
} // Namespace
class FastAtofTest : public ::testing::Test
{
protected:
template <typename Real, typename AtofFunc>
static void RunTest(AtofFunc atof_func)
{
const Real kEps = 1e-5f;
#define TEST_CASE(NUM) EXPECT_NEAR(static_cast<Real>(NUM), atof_func(#NUM), kEps)
#define TEST_CASE_NAN(NUM) EXPECT_TRUE(IsNan(atof_func(#NUM)))
#define TEST_CASE_INF(NUM) EXPECT_TRUE(IsInf(atof_func(#NUM)))
TEST_CASE(0);
TEST_CASE(1.354);
TEST_CASE(1054E-3);
TEST_CASE(-1054E-3);
TEST_CASE(-10.54E30);
TEST_CASE(-345554.54e-5);
TEST_CASE(-34555.534954e-5);
TEST_CASE(-34555.534954e-5);
TEST_CASE(549067);
TEST_CASE(567);
TEST_CASE(446);
TEST_CASE(7);
TEST_CASE(73);
TEST_CASE(256);
TEST_CASE(5676);
TEST_CASE(3);
TEST_CASE(738);
TEST_CASE(684);
TEST_CASE(26);
TEST_CASE(673.678e-56);
TEST_CASE(53);
TEST_CASE(67);
TEST_CASE(684);
TEST_CASE(-5437E24);
TEST_CASE(8);
TEST_CASE(84);
TEST_CASE(3);
TEST_CASE(56733.68);
TEST_CASE(786);
TEST_CASE(6478);
TEST_CASE(34563.65683598734);
TEST_CASE(5673);
TEST_CASE(784e-3);
TEST_CASE(8678);
TEST_CASE(46784);
TEST_CASE(-54.0888e-6);
TEST_CASE(100000e10);
TEST_CASE(1e-307);
TEST_CASE(0.000001e-301);
TEST_CASE(0.0000001e-300);
TEST_CASE(0.00000001e-299);
TEST_CASE(1000000e-313);
TEST_CASE(10000000e-314);
TEST_CASE(100000000e-315);
TEST_CASE(12.345);
TEST_CASE(12.345e19);
TEST_CASE(-.1e+9);
TEST_CASE(.125);
TEST_CASE(1e20);
TEST_CASE(0e-19);
TEST_CASE(400012);
TEST_CASE(5.9e-76);
TEST_CASE(7.54979e-8);
TEST_CASE_INF(inf);
TEST_CASE_INF(inf);
TEST_CASE_INF(infinity);
TEST_CASE_INF(Inf);
TEST_CASE_INF(-Inf);
TEST_CASE_INF(+InFiNiTy);
TEST_CASE_NAN(NAN);
TEST_CASE_NAN(NaN);
TEST_CASE_NAN(nan);
EXPECT_EQ(static_cast<Real>(6), atof_func("006"));
EXPECT_EQ(static_cast<Real>(5.3), atof_func("5.300 "));
/* Failing Cases:
EXPECT_EQ(static_cast<Real>(6), atof_func(" 006"));
EXPECT_EQ(static_cast<Real>(5.3), atof_func(" 5.300 "));
TEST_CASE(-10.54E45);
TEST_CASE(0x0A);
TEST_CASE(0xA0);
TEST_CASE(0x1p1023);
TEST_CASE(0x1000p1011);
TEST_CASE(0x1p1020);
TEST_CASE(0x0.00001p1040);
TEST_CASE(0x1p-1021);
TEST_CASE(0x1000p-1033);
TEST_CASE(0x10000p-1037);
TEST_CASE(0x0.001p-1009);
TEST_CASE(0x0.0001p-1005);
TEST_CASE(0x1.4p+3);
TEST_CASE(0xAp0);
TEST_CASE(0x0Ap0);
TEST_CASE(0x0.A0p8);
TEST_CASE(0x0.50p9);
TEST_CASE(0x0.28p10);
TEST_CASE(0x0.14p11);
TEST_CASE(0x0.0A0p12);
TEST_CASE(0x0.050p13);
TEST_CASE(0x0.028p14);
TEST_CASE(0x0.014p15);
TEST_CASE(0x00.00A0p16);
TEST_CASE(0x00.0050p17);
TEST_CASE(0x00.0028p18);
TEST_CASE(0x00.0014p19);
TEST_CASE(0x1p-1023);
TEST_CASE(0x0.8p-1022);
TEST_CASE(0x80000Ap-23);
TEST_CASE(0x100000000000008p0);
TEST_CASE(0x100000000000008.p0);
TEST_CASE(0x100000000000008.00p0);
TEST_CASE(0x10000000000000800p0);
TEST_CASE(0x10000000000000801p0)
*/
#undef TEST_CASE
#undef TEST_CASE_NAN
#undef TEST_CASE_INF
}
};
struct FastAtofWrapper {
ai_real operator()(const char* str) { return Assimp::fast_atof(str); }
};
TEST_F(FastAtofTest, FastAtof)
{
RunTest<ai_real>(FastAtofWrapper());
}

View file

@ -0,0 +1,243 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "../../include/assimp/scene.h"
#include "PostProcessing/FindDegenerates.h"
#include <memory>
using namespace std;
using namespace Assimp;
class FindDegeneratesProcessTest : public ::testing::Test {
public:
FindDegeneratesProcessTest() :
Test(), mMesh(nullptr), mProcess(nullptr) {
// empty
}
protected:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh *mMesh;
FindDegeneratesProcess *mProcess;
};
void FindDegeneratesProcessTest::SetUp() {
mMesh = new aiMesh();
mProcess = new FindDegeneratesProcess();
mMesh->mNumFaces = 1000;
mMesh->mFaces = new aiFace[1000];
mMesh->mNumVertices = 5000 * 2;
mMesh->mVertices = new aiVector3D[5000 * 2];
for (unsigned int i = 0; i < 5000; ++i) {
mMesh->mVertices[i] = mMesh->mVertices[i + 5000] = aiVector3D((float)i);
}
mMesh->mPrimitiveTypes = aiPrimitiveType_LINE | aiPrimitiveType_POINT |
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE;
unsigned int numOut = 0, numFaces = 0;
for (unsigned int i = 0; i < 1000; ++i) {
aiFace &f = mMesh->mFaces[i];
f.mNumIndices = (i % 5) + 1; // between 1 and 5
f.mIndices = new unsigned int[f.mNumIndices];
bool had = false;
for (unsigned int n = 0; n < f.mNumIndices; ++n) {
// FIXME
#if 0
// some duplicate indices
if ( n && n == (i / 200)+1) {
f.mIndices[n] = f.mIndices[n-1];
had = true;
}
// and some duplicate vertices
#endif
if (n && i % 2 && 0 == n % 2) {
f.mIndices[n] = f.mIndices[n - 1] + 5000;
had = true;
} else {
f.mIndices[n] = numOut++;
}
}
if (!had)
++numFaces;
}
mMesh->mNumUVComponents[0] = numOut;
mMesh->mNumUVComponents[1] = numFaces;
}
void FindDegeneratesProcessTest::TearDown() {
delete mMesh;
delete mProcess;
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesDetection) {
mProcess->EnableInstantRemoval(false);
mProcess->ExecuteOnMesh(mMesh);
unsigned int out = 0;
for (unsigned int i = 0; i < 1000; ++i) {
aiFace &f = mMesh->mFaces[i];
out += f.mNumIndices;
}
EXPECT_EQ(1000U, mMesh->mNumFaces);
EXPECT_EQ(10000U, mMesh->mNumVertices);
EXPECT_EQ(out, mMesh->mNumUVComponents[0]);
EXPECT_EQ(static_cast<unsigned int>(
aiPrimitiveType_LINE | aiPrimitiveType_POINT |
aiPrimitiveType_POLYGON | aiPrimitiveType_TRIANGLE),
mMesh->mPrimitiveTypes);
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemoval) {
mProcess->EnableAreaCheck(false);
mProcess->EnableInstantRemoval(true);
mProcess->ExecuteOnMesh(mMesh);
EXPECT_EQ(mMesh->mNumUVComponents[1], mMesh->mNumFaces);
}
TEST_F(FindDegeneratesProcessTest, testDegeneratesRemovalWithAreaCheck) {
mProcess->EnableAreaCheck(true);
mProcess->EnableInstantRemoval(true);
mProcess->ExecuteOnMesh(mMesh);
EXPECT_EQ(mMesh->mNumUVComponents[1] - 100, mMesh->mNumFaces);
}
namespace
{
std::unique_ptr<aiMesh> getDegenerateMesh()
{
std::unique_ptr<aiMesh> mesh(new aiMesh);
mesh->mNumVertices = 2;
mesh->mVertices = new aiVector3D[2];
mesh->mVertices[0] = aiVector3D{ 0.0f, 0.0f, 0.0f };
mesh->mVertices[1] = aiVector3D{ 1.0f, 0.0f, 0.0f };
mesh->mNumFaces = 1;
mesh->mFaces = new aiFace[1];
mesh->mFaces[0].mNumIndices = 3;
mesh->mFaces[0].mIndices = new unsigned int[3];
mesh->mFaces[0].mIndices[0] = 0;
mesh->mFaces[0].mIndices[1] = 1;
mesh->mFaces[0].mIndices[2] = 0;
return mesh;
}
}
TEST_F(FindDegeneratesProcessTest, meshRemoval) {
mProcess->EnableAreaCheck(true);
mProcess->EnableInstantRemoval(true);
mProcess->ExecuteOnMesh(mMesh);
std::unique_ptr<aiScene> scene(new aiScene);
scene->mNumMeshes = 5;
scene->mMeshes = new aiMesh*[5];
/// Use the mesh which doesn't get completely stripped of faces from the main test.
aiMesh* meshWhichSurvives = mMesh;
mMesh = nullptr;
scene->mMeshes[0] = getDegenerateMesh().release();
scene->mMeshes[1] = getDegenerateMesh().release();
scene->mMeshes[2] = meshWhichSurvives;
scene->mMeshes[3] = getDegenerateMesh().release();
scene->mMeshes[4] = getDegenerateMesh().release();
scene->mRootNode = new aiNode;
scene->mRootNode->mNumMeshes = 5;
scene->mRootNode->mMeshes = new unsigned int[5];
scene->mRootNode->mMeshes[0] = 0;
scene->mRootNode->mMeshes[1] = 1;
scene->mRootNode->mMeshes[2] = 2;
scene->mRootNode->mMeshes[3] = 3;
scene->mRootNode->mMeshes[4] = 4;
mProcess->Execute(scene.get());
EXPECT_EQ(scene->mNumMeshes, 1u);
EXPECT_EQ(scene->mMeshes[0], meshWhichSurvives);
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
EXPECT_EQ(scene->mRootNode->mMeshes[0], 0u);
}
TEST_F(FindDegeneratesProcessTest, invalidVertexIndex) {
mProcess->EnableAreaCheck(true);
mProcess->EnableInstantRemoval(true);
mProcess->ExecuteOnMesh(mMesh);
std::unique_ptr<aiScene> scene(new aiScene);
scene->mNumMeshes = 1;
scene->mMeshes = new aiMesh *[1];
std::unique_ptr<aiMesh> mesh(new aiMesh);
mesh->mNumVertices = 1;
mesh->mVertices = new aiVector3D[1];
mesh->mVertices[0] = aiVector3D{ 0.0f, 0.0f, 0.0f };
mesh->mNumFaces = 1;
mesh->mFaces = new aiFace[1];
mesh->mFaces[0].mNumIndices = 3;
mesh->mFaces[0].mIndices = new unsigned int[3];
mesh->mFaces[0].mIndices[0] = 0;
mesh->mFaces[0].mIndices[1] = 1;
mesh->mFaces[0].mIndices[2] = 99999;
scene->mMeshes[0] = mesh.release();
scene->mRootNode = new aiNode;
scene->mRootNode->mNumMeshes = 1;
scene->mRootNode->mMeshes = new unsigned int[1];
scene->mRootNode->mMeshes[0] = 0;
mProcess->Execute(scene.get());
EXPECT_EQ(scene->mNumMeshes, 1u);
EXPECT_EQ(scene->mRootNode->mNumMeshes, 1u);
EXPECT_EQ(scene->mRootNode->mMeshes[0], 0u);
}

View file

@ -0,0 +1,145 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "PostProcessing/FindInvalidDataProcess.h"
#include <assimp/mesh.h>
using namespace std;
using namespace Assimp;
class utFindInvalidDataProcess : public ::testing::Test {
public:
utFindInvalidDataProcess() :
Test(), mMesh(nullptr), mProcess(nullptr) {
// empty
}
protected:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh *mMesh;
FindInvalidDataProcess *mProcess;
};
// ------------------------------------------------------------------------------------------------
void utFindInvalidDataProcess::SetUp() {
ASSERT_TRUE(AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
mProcess = new FindInvalidDataProcess();
mMesh = new aiMesh();
mMesh->mNumVertices = 1000;
mMesh->mVertices = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000; ++i) {
mMesh->mVertices[i] = aiVector3D((float)i);
}
mMesh->mNormals = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000; ++i) {
mMesh->mNormals[i] = aiVector3D((float)i + 1);
}
mMesh->mTangents = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000; ++i) {
mMesh->mTangents[i] = aiVector3D((float)i);
}
mMesh->mBitangents = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000; ++i) {
mMesh->mBitangents[i] = aiVector3D((float)i);
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
mMesh->mTextureCoords[a] = new aiVector3D[1000];
for (unsigned int i = 0; i < 1000; ++i) {
mMesh->mTextureCoords[a][i] = aiVector3D((float)i);
}
}
}
// ------------------------------------------------------------------------------------------------
void utFindInvalidDataProcess::TearDown() {
delete mProcess;
delete mMesh;
}
// ------------------------------------------------------------------------------------------------
TEST_F(utFindInvalidDataProcess, testStepNegativeResult) {
for ( size_t i=0; i<mMesh->mNumVertices; ++i ) {
mMesh->mNormals[i].x = mMesh->mNormals[i].y = mMesh->mNormals[i].z =0;
mMesh->mBitangents[i].x = mMesh->mBitangents[i].y = mMesh->mBitangents[i].z = 0;
}
mMesh->mTextureCoords[2][455] = aiVector3D(std::numeric_limits<float>::quiet_NaN());
mProcess->ProcessMesh(mMesh);
EXPECT_TRUE(nullptr != mMesh->mVertices);
EXPECT_EQ(nullptr, mMesh->mNormals);
EXPECT_EQ(nullptr, mMesh->mTangents);
EXPECT_EQ(nullptr, mMesh->mBitangents);
for (unsigned int i = 0; i < 2; ++i) {
EXPECT_TRUE(nullptr != mMesh->mTextureCoords[i]);
}
for (unsigned int i = 2; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
EXPECT_EQ(nullptr, mMesh->mTextureCoords[i]);
}
}
// ------------------------------------------------------------------------------------------------
TEST_F(utFindInvalidDataProcess, testStepPositiveResult) {
mProcess->ProcessMesh(mMesh);
EXPECT_NE(nullptr, mMesh->mVertices);
EXPECT_NE(nullptr, mMesh->mNormals);
EXPECT_NE(nullptr, mMesh->mTangents);
EXPECT_NE(nullptr, mMesh->mBitangents);
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
EXPECT_NE(nullptr, mMesh->mTextureCoords[i]);
}
}

View file

@ -0,0 +1,43 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"

View file

@ -0,0 +1,93 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "PostProcessing/GenBoundingBoxesProcess.h"
#include <assimp/mesh.h>
#include <assimp/scene.h>
using namespace Assimp;
class utGenBoundingBoxesProcess : public ::testing::Test {
public:
utGenBoundingBoxesProcess() :
Test(), mProcess(nullptr), mMesh(nullptr), mScene(nullptr) {
// empty
}
void SetUp() override {
mProcess = new GenBoundingBoxesProcess;
mMesh = new aiMesh();
mMesh->mNumVertices = 100;
mMesh->mVertices = new aiVector3D[100];
for (unsigned int i = 0; i < 100; ++i) {
mMesh->mVertices[i] = aiVector3D((ai_real)i, (ai_real)i, (ai_real)i);
}
mScene = new aiScene();
mScene->mNumMeshes = 1;
mScene->mMeshes = new aiMesh *[1];
mScene->mMeshes[0] = mMesh;
}
void TearDown() override {
delete mProcess;
delete mScene;
}
protected:
GenBoundingBoxesProcess *mProcess;
aiMesh *mMesh;
aiScene *mScene;
};
TEST_F(utGenBoundingBoxesProcess, executeTest) {
mProcess->Execute(mScene);
aiMesh *mesh = mScene->mMeshes[0];
EXPECT_NE(nullptr, mesh);
EXPECT_EQ(0, mesh->mAABB.mMin.x);
EXPECT_EQ(0, mesh->mAABB.mMin.y);
EXPECT_EQ(0, mesh->mAABB.mMin.z);
EXPECT_EQ(99, mesh->mAABB.mMax.x);
EXPECT_EQ(99, mesh->mAABB.mMax.y);
EXPECT_EQ(99, mesh->mAABB.mMax.z);
}

View file

@ -0,0 +1,86 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "PostProcessing/GenVertexNormalsProcess.h"
using namespace ::std;
using namespace ::Assimp;
class GenNormalsTest : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
protected:
aiMesh *pcMesh;
GenVertexNormalsProcess *piProcess;
};
// ------------------------------------------------------------------------------------------------
void GenNormalsTest::SetUp() {
piProcess = new GenVertexNormalsProcess();
pcMesh = new aiMesh();
pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
pcMesh->mNumFaces = 1;
pcMesh->mFaces = new aiFace[1];
pcMesh->mFaces[0].mIndices = new unsigned int[pcMesh->mFaces[0].mNumIndices = 3];
pcMesh->mFaces[0].mIndices[0] = 0;
pcMesh->mFaces[0].mIndices[1] = 1;
pcMesh->mFaces[0].mIndices[2] = 1;
pcMesh->mNumVertices = 3;
pcMesh->mVertices = new aiVector3D[3];
pcMesh->mVertices[0] = aiVector3D(0.0f, 1.0f, 6.0f);
pcMesh->mVertices[1] = aiVector3D(2.0f, 3.0f, 1.0f);
pcMesh->mVertices[2] = aiVector3D(3.0f, 2.0f, 4.0f);
}
// ------------------------------------------------------------------------------------------------
void GenNormalsTest::TearDown() {
delete this->pcMesh;
delete this->piProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(GenNormalsTest, testSimpleTriangle) {
piProcess->GenMeshVertexNormals(pcMesh, 0);
EXPECT_TRUE(pcMesh->mNormals != nullptr);
}

View file

@ -0,0 +1,60 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utHMPImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/HMP/terrain.hmp", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utHMPImportExport, importHMPFromFileTest) {
EXPECT_TRUE(importerTest());
}

View file

@ -0,0 +1,80 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utIFCImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/IFC/AC14-FZK-Haus.ifc", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utIFCImportExport, importIFCFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utIFCImportExport, importComplextypeAsColor) {
std::string asset =
"ISO-10303-21;\n"
"HEADER;\n"
"FILE_DESCRIPTION( ( 'ViewDefinition [CoordinationView, SpaceBoundary2ndLevelAddOnView]', 'Option [Filter: ]' ), '2;1' );\n"
"FILE_NAME( 'S:\\[IFC]\\[COMPLETE-BUILDINGS]\\FZK-MODELS\\FZK-Haus\\ArchiCAD-14\\AC14-FZK-Haus.ifc', '2010-10-07T13:40:52', ( 'Architect' ), ( 'Building Designer Office' ), 'PreProc - EDM 5.0', 'ArchiCAD 14.00 Release 1. Windows Build Number of the Ifc 2x3 interface: 3427', 'The authorising person' );\n"
"FILE_SCHEMA( ( 'IFC2X3' ) );\n"
"ENDSEC;\n"
"\n"
"DATA;\n"
"#1 = IFCORGANIZATION( 'GS', 'Graphisoft', 'Graphisoft', $, $ );\n"
"#2 = IFCPROPERTYSINGLEVALUE( 'Red', $, IFCINTEGER( 255 ), $ );\n"
"#3 = IFCPROPERTYSINGLEVALUE( 'Green', $, IFCINTEGER( 255 ), $ );\n"
"#4 = IFCPROPERTYSINGLEVALUE( 'Blue', $, IFCINTEGER( 255 ), $ );\n"
"#5 = IFCCOMPLEXPROPERTY( 'Color', $, 'Color', ( #19, #20, #21 ) );\n";
Assimp::Importer importer;
const aiScene *scene = importer.ReadFileFromMemory(asset.c_str(), asset.size(), 0);
EXPECT_EQ(nullptr, scene);
}

View file

@ -0,0 +1,151 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/IOStreamBuffer.h>
#include "TestIOStream.h"
#include "Tools/TestTools.h"
#include "UnitTestFileGenerator.h"
class IOStreamBufferTest : public ::testing::Test {
// empty
};
using namespace Assimp;
TEST_F( IOStreamBufferTest, creationTest ) {
bool ok( true );
try {
IOStreamBuffer<char> myBuffer;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( IOStreamBufferTest, accessCacheSizeTest ) {
IOStreamBuffer<char> myBuffer1;
EXPECT_NE( 0U, myBuffer1.cacheSize() );
IOStreamBuffer<char> myBuffer2( 100 );
EXPECT_EQ( 100U, myBuffer2.cacheSize() );
}
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
itor sapien ornare sagittis volutpat."};
TEST_F( IOStreamBufferTest, open_close_Test ) {
IOStreamBuffer<char> myBuffer;
EXPECT_FALSE( myBuffer.open( nullptr ) );
EXPECT_FALSE( myBuffer.close() );
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fname[]={ "octest.XXXXXX" };
std::string tmpName;
auto* fs = MakeTmpFile(fname, std::strlen(fname), tmpName);
ASSERT_NE(nullptr, fs);
auto written = std::fwrite(data, sizeof(*data), dataCount, fs);
EXPECT_NE( 0U, written );
auto flushResult = std::fflush( fs );
ASSERT_EQ(0, flushResult);
fclose(fs);
FILE *new_fs{ nullptr };
EXPECT_TRUE(Unittest::TestTools::openFilestream(&new_fs, tmpName.c_str(), "r"));
ASSERT_NE(nullptr, new_fs);
{
TestDefaultIOStream myStream(new_fs, fname);
EXPECT_TRUE( myBuffer.open( &myStream ) );
EXPECT_FALSE( myBuffer.open( &myStream ) );
EXPECT_TRUE( myBuffer.close() );
}
remove(fname);
}
TEST_F( IOStreamBufferTest, readlineTest ) {
const auto dataSize = sizeof(data);
const auto dataCount = dataSize / sizeof(*data);
char fname[]={ "readlinetest.XXXXXX\0" };
std::string tmpName;
auto* fs = MakeTmpFile(fname, std::strlen(fname), tmpName);
ASSERT_NE(nullptr, fs);
auto written = std::fwrite( data, sizeof(*data), dataCount, fs );
EXPECT_NE( 0U, written );
auto flushResult = std::fflush(fs);
ASSERT_EQ(0, flushResult);
std::fclose(fs);
FILE *new_fs{ nullptr };
EXPECT_TRUE(Unittest::TestTools::openFilestream(&new_fs, tmpName.c_str(), "r"));
ASSERT_NE(nullptr, new_fs);
const auto tCacheSize = 26u;
IOStreamBuffer<char> myBuffer(tCacheSize);
EXPECT_EQ(tCacheSize, myBuffer.cacheSize());
TestDefaultIOStream myStream(new_fs, fname);
auto size = myStream.FileSize();
auto numBlocks = size / myBuffer.cacheSize();
if ( size % myBuffer.cacheSize() > 0 ) {
numBlocks++;
}
EXPECT_TRUE(myBuffer.open(&myStream));
EXPECT_EQ(numBlocks, myBuffer.getNumBlocks() );
EXPECT_TRUE(myBuffer.close() );
}
TEST_F( IOStreamBufferTest, accessBlockIndexTest ) {
}

79
vendor/assimp/test/unit/utIOSystem.cpp vendored Normal file
View file

@ -0,0 +1,79 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "TestIOSystem.h"
#include <assimp/IOSystem.hpp>
using namespace std;
using namespace Assimp;
class IOSystemTest : public ::testing::Test {
public:
virtual void SetUp() {
pImp = new TestIOSystem();
}
virtual void TearDown() {
delete pImp;
}
protected:
TestIOSystem* pImp;
};
TEST_F( IOSystemTest, accessDirectoryStackTest ) {
EXPECT_FALSE( pImp->PopDirectory() );
EXPECT_EQ( 0U, pImp->StackSize() );
EXPECT_FALSE( pImp->PushDirectory( "" ) );
std::string path = "test/";
EXPECT_TRUE( pImp->PushDirectory( path ) );
EXPECT_EQ( 1U, pImp->StackSize() );
EXPECT_EQ( path, pImp->CurrentDirectory() );
EXPECT_TRUE( pImp->PopDirectory() );
EXPECT_EQ( 0U, pImp->StackSize() );
}
TEST_F( IOSystemTest, delFileTest ) {
EXPECT_FALSE( pImp->DeleteFile( "none" ) );
}

397
vendor/assimp/test/unit/utImporter.cpp vendored Normal file
View file

@ -0,0 +1,397 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "../../include/assimp/postprocess.h"
#include "../../include/assimp/scene.h"
#include "TestIOSystem.h"
#include <assimp/BaseImporter.h>
#include <assimp/DefaultIOSystem.h>
#include <assimp/Importer.hpp>
using namespace ::std;
using namespace ::Assimp;
class ImporterTest : public ::testing::Test {
protected:
void SetUp() override {
pImp = new Importer();
}
void TearDown() override {
delete pImp;
}
Importer *pImp;
};
#define InputData_BLOCK_SIZE 1310
// clang-format off
// test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds
static unsigned char InputData_abRawBlock[1310] = {
77, 77, 30, 5, 0, 0, 2, 0, 10, 0, 0, 0, 3, 0, 0, 0, 61, 61, 91, 3, 0, 0,
62, 61, 10, 0, 0, 0, 3, 0, 0, 0, 0, 1, 10, 0, 0, 0, 0, 0,128, 63, 0, 64,
254, 2, 0, 0, 66,111,120, 48, 49, 0, 0, 65,242, 2, 0, 0, 16, 65, 64, 1, 0, 0,
26, 0,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193,
0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,205,121, 55, 66,138,157,
184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66,
102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66,205,121,
55, 66,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,
205,121, 55, 66,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252,
26, 66,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,102, 74,198,193,
90, 252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,138,157,
184, 65, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66,
138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74,
198,193,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66,
205,121, 55, 66,138,157,184, 65, 90,252, 26, 66,205,121, 55, 66,138,157,184, 65, 0, 0,
0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193,
90,252, 26, 66,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157,
184, 65, 0, 0, 0, 0, 64, 65,216, 0, 0, 0, 26, 0, 0, 0,128, 63, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0,
128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128, 63, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63,
0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63,
0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,
0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0,
0, 0, 96, 65, 54, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63,
53,169, 40, 65,176,205, 90,191, 0, 0, 0, 0, 32, 65,158, 0, 0, 0, 12, 0, 0, 0,
2, 0, 3, 0, 6, 0, 3, 0, 1, 0, 0, 0, 6, 0, 4, 0, 5, 0, 7, 0, 6, 0,
7, 0, 6, 0, 4, 0, 6, 0, 8, 0, 9, 0, 10, 0, 6, 0, 11, 0, 12, 0, 13, 0,
6, 0, 1, 0, 14, 0, 7, 0, 6, 0, 7, 0, 15, 0, 1, 0, 6, 0, 16, 0, 17, 0,
18, 0, 6, 0, 19, 0, 20, 0, 21, 0, 6, 0, 22, 0, 0, 0, 23, 0, 6, 0, 24, 0,
6, 0, 25, 0, 6, 0, 80, 65, 54, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 4, 0,
0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0,
32, 0, 0, 0, 32, 0, 0, 0, 64, 0, 0, 0, 64, 0, 0, 0, 0, 64, 67, 0, 0, 0,
67, 97,109,101,114, 97, 48, 49, 0, 0, 71, 52, 0, 0, 0,189, 19, 25,195,136,104, 81,
64,147, 56,182, 65, 96,233, 20,194, 67,196, 97,190,147, 56,182, 65, 0, 0, 0, 0, 85,
85, 85, 66, 32, 71, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0,122, 68, 0,176,179, 1, 0,
0, 10,176, 21, 0, 0, 0, 5, 0, 77, 65, 88, 83, 67, 69, 78, 69, 0, 44, 1, 0, 0,
8,176, 14, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 9,176, 10, 0, 0, 0,128, 2,
0, 0, 2,176,168, 0, 0, 0, 48,176, 8, 0, 0, 0, 0, 0, 16,176, 18, 0, 0, 0,
66,111,120, 48, 49, 0, 0, 64, 0, 0,255,255, 19,176, 18, 0, 0, 0, 0, 0, 0,128,
0, 0, 0,128, 0, 0, 0,128, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53,169, 40, 65,176,205, 90,191, 0, 0,
0, 0, 33,176, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 3,176,143, 0, 0, 0,
48,176, 8, 0, 0, 0, 1, 0, 16,176, 21, 0, 0, 0, 67, 97,109,101,114, 97, 48, 49,
0, 0, 64, 0, 0,255,255, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,189, 19, 25,195,136,104, 81, 64,147, 56,182,
65, 35,176, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 52, 66, 36,176, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0,120,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,120, 13, 90,189,120, 0, 0, 0, 0,
0, 99,156,154,194, 4,176, 73, 0, 0, 0, 48,176, 8, 0, 0, 0, 2, 0, 16,176, 21,
0, 0, 0, 67, 97,109,101,114, 97, 48, 49, 0, 0, 64, 0, 0,255,255, 32,176, 38, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96,233, 20,194, 67,196, 97,190,147, 56,182, 65 };
// clang-format on
#define AIUT_DEF_ERROR_TEXT "sorry, this is a test"
static const aiImporterDesc desc = {
"UNIT TEST - IMPORTER",
"",
"",
"",
0,
0,
0,
0,
0,
"apple mac linux windows"
};
class TestPlugin : public BaseImporter {
public:
virtual bool CanRead(
const std::string &pFile, IOSystem * /*pIOHandler*/, bool /*test*/) const {
std::string::size_type pos = pFile.find_last_of('.');
// no file extension - can't read
if (pos == std::string::npos)
return false;
std::string extension = pFile.substr(pos);
// todo ... make case-insensitive
return (extension == ".apple" || extension == ".mac" ||
extension == ".linux" || extension == ".windows");
}
virtual const aiImporterDesc *GetInfo() const {
return &desc;
}
virtual void InternReadFile(
const std::string & /*pFile*/, aiScene * /*pScene*/, IOSystem * /*pIOHandler*/) {
throw DeadlyImportError(AIUT_DEF_ERROR_TEXT);
}
};
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testMemoryRead) {
const aiScene *sc = pImp->ReadFileFromMemory(InputData_abRawBlock, InputData_BLOCK_SIZE,
aiProcessPreset_TargetRealtime_Quality, "3ds");
ASSERT_TRUE(sc != nullptr);
EXPECT_EQ(aiString("<3DSRoot>"), sc->mRootNode->mName);
EXPECT_EQ(1U, sc->mNumMeshes);
EXPECT_EQ(24U, sc->mMeshes[0]->mNumVertices);
EXPECT_EQ(12U, sc->mMeshes[0]->mNumFaces);
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testIntProperty) {
bool b = pImp->SetPropertyInteger("quakquak", 1503);
EXPECT_FALSE(b);
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak", 0));
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there", 314159));
b = pImp->SetPropertyInteger("quakquak", 1504);
EXPECT_TRUE(b);
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testFloatProperty) {
bool b = pImp->SetPropertyFloat("quakquak", 1503.f);
EXPECT_TRUE(!b);
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak", 0.f));
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there", 314159.f));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testStringProperty) {
bool b = pImp->SetPropertyString("quakquak", "test");
EXPECT_TRUE(!b);
EXPECT_EQ("test", pImp->GetPropertyString("quakquak", "weghwekg"));
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there", "ILoveYou"));
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testPluginInterface) {
pImp->RegisterLoader(new TestPlugin());
EXPECT_TRUE(pImp->IsExtensionSupported(".apple"));
EXPECT_TRUE(pImp->IsExtensionSupported(".mac"));
EXPECT_TRUE(pImp->IsExtensionSupported("*.linux"));
EXPECT_TRUE(pImp->IsExtensionSupported("windows"));
EXPECT_TRUE(pImp->IsExtensionSupported(".x")); /* x and 3ds must be available in this Assimp build, of course! */
EXPECT_TRUE(pImp->IsExtensionSupported(".3ds"));
EXPECT_FALSE(pImp->IsExtensionSupported("."));
TestPlugin *p = (TestPlugin *)pImp->GetImporter(".windows");
ASSERT_TRUE(nullptr != p);
try {
p->InternReadFile("", nullptr, nullptr);
} catch (const DeadlyImportError &dead) {
EXPECT_TRUE(!strcmp(dead.what(), AIUT_DEF_ERROR_TEXT));
// unregister the plugin and delete it
pImp->UnregisterLoader(p);
delete p;
return;
}
EXPECT_TRUE(false); // control shouldn't reach this point
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testExtensionCheck) {
std::string s;
pImp->GetExtensionList(s);
// TODO
}
// ------------------------------------------------------------------------------------------------
TEST_F(ImporterTest, testMultipleReads) {
// see http://sourceforge.net/projects/assimp/forums/forum/817654/topic/3591099
// Check whether reading and post-processing multiple times using
// the same objects is *generally* fine. This test doesn't target
// importers. Testing post-processing stability is the main point.
const unsigned int flags =
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_GenSmoothNormals |
aiProcess_ValidateDataStructure |
aiProcess_RemoveRedundantMaterials |
aiProcess_SortByPType |
aiProcess_FindDegenerates |
aiProcess_FindInvalidData |
aiProcess_GenUVCoords |
aiProcess_OptimizeMeshes |
aiProcess_OptimizeGraph;
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", flags));
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", flags));
EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", flags));
//EXPECT_TRUE(pImp->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/dwarf.x",flags)); # is in nonbsd
}
TEST_F(ImporterTest, SearchFileHeaderForTokenTest) {
//DefaultIOSystem ioSystem;
// BaseImporter::SearchFileHeaderForToken( &ioSystem, assetPath, Token, 2 )
}
namespace {
// Description for an importer which fails in specific ways.
aiImporterDesc s_failingImporterDescription = {
"Failing importer",
"assimp team",
"",
"",
0,
1,
0,
1,
0,
"fail"
};
// This importer fails in specific ways.
class FailingImporter : public Assimp::BaseImporter {
public:
virtual ~FailingImporter() = default;
bool CanRead(const std::string &, Assimp::IOSystem *, bool) const override {
return true;
}
protected:
const aiImporterDesc *GetInfo() const override {
return &s_failingImporterDescription;
}
void InternReadFile(const std::string &pFile, aiScene *, Assimp::IOSystem *) override {
if (pFile == "deadlyImportError.fail") {
throw DeadlyImportError("Deadly import error test. Details: ", 42, " More Details: ", "Failure");
} else if (pFile == "stdException.fail") {
throw std::runtime_error("std::exception test");
} else if (pFile == "unexpectedException.fail") {
throw 5;
}
}
};
} // namespace
TEST_F(ImporterTest, deadlyImportError) {
pImp->RegisterLoader(new FailingImporter);
pImp->SetIOHandler(new TestIOSystem);
const aiScene *scene = pImp->ReadFile("deadlyImportError.fail", 0);
EXPECT_EQ(scene, nullptr);
EXPECT_STREQ(pImp->GetErrorString(), "Deadly import error test. Details: 42 More Details: Failure");
EXPECT_NE(pImp->GetException(), std::exception_ptr());
}
TEST_F(ImporterTest, stdException) {
pImp->RegisterLoader(new FailingImporter);
pImp->SetIOHandler(new TestIOSystem);
const aiScene *scene = pImp->ReadFile("stdException.fail", 0);
EXPECT_EQ(scene, nullptr);
EXPECT_STREQ(pImp->GetErrorString(), "std::exception test");
EXPECT_NE(pImp->GetException(), std::exception_ptr());
try {
std::rethrow_exception(pImp->GetException());
} catch (const std::exception &e) {
EXPECT_STREQ(e.what(), "std::exception test");
} catch (...) {
EXPECT_TRUE(false);
}
}
TEST_F(ImporterTest, unexpectedException) {
pImp->RegisterLoader(new FailingImporter);
pImp->SetIOHandler(new TestIOSystem);
const aiScene *scene = pImp->ReadFile("unexpectedException.fail", 0);
EXPECT_EQ(scene, nullptr);
EXPECT_STREQ(pImp->GetErrorString(), "Unknown exception");
ASSERT_NE(pImp->GetException(), std::exception_ptr());
try {
std::rethrow_exception(pImp->GetException());
} catch (int x) {
EXPECT_EQ(x, 5);
} catch (...) {
EXPECT_TRUE(false);
}
}
// ------------------------------------------------------------------------------------------------
struct ExtensionTestCase {
std::string testName;
std::string filename;
std::string getExtensionResult;
std::string hasExtension;
bool hasExtensionResult;
};
using ExtensionTest = ::testing::TestWithParam<ExtensionTestCase>;
TEST_P(ExtensionTest, testGetAndHasExtension) {
const ExtensionTestCase& testCase = GetParam();
EXPECT_EQ(testCase.getExtensionResult, BaseImporter::GetExtension(testCase.filename));
EXPECT_EQ(testCase.hasExtensionResult, BaseImporter::HasExtension(testCase.filename, {testCase.hasExtension}));
}
INSTANTIATE_TEST_SUITE_P(
ExtensionTests, ExtensionTest,
::testing::ValuesIn<ExtensionTestCase>({
{"NoExtension", "name", "", "glb", false},
{"NoExtensionAndEmptyVersion", "name#", "", "glb", false},
{"WithExtensionAndEmptyVersion", "name.glb#", "glb#", "glb", false},
{"WithExtensionAndVersion", "name.glb#1234", "glb", "glb", true},
{"WithExtensionAndHashInStem", "name#1234.glb", "glb", "glb", true},
{"WithExtensionAndInvalidVersion", "name.glb#_", "glb#_", "glb", false},
{"WithExtensionAndDotAndHashInStem", "name.glb#.abc", "abc", "glb", false},
{"WithTwoExtensions", "name.abc.def", "def", "abc.def", true},
}),
[](const ::testing::TestParamInfo<ExtensionTest::ParamType>& info) {
return info.param.testName;
});

View file

@ -0,0 +1,42 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"

83
vendor/assimp/test/unit/utIssues.cpp vendored Normal file
View file

@ -0,0 +1,83 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include "TestModelFactory.h"
using namespace Assimp;
class utIssues : public ::testing::Test {};
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
float opacity;
aiScene *scene = TestModelFactory::createDefaultTestModel(opacity);
Assimp::Importer importer;
Assimp::Exporter exporter;
const aiExportFormatDesc *desc = exporter.GetExportFormatDescription( 0 );
ASSERT_NE( desc, nullptr );
std::string path = "dae";
path.append(".");
path.append( desc->fileExtension );
EXPECT_EQ( AI_SUCCESS, exporter.Export( scene, desc->id, path ) );
const aiScene *newScene( importer.ReadFile( path, aiProcess_ValidateDataStructure ) );
ASSERT_NE( nullptr, newScene );
float newOpacity;
if (newScene->mNumMaterials > 0 ) {
EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) );
EXPECT_FLOAT_EQ( opacity, newOpacity );
}
TestModelFactory::releaseDefaultTestModel(&scene);
// Cleanup. Delete exported dae.dae file
EXPECT_EQ(0, std::remove(path.c_str()));
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,142 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/scene.h>
#include "PostProcessing/JoinVerticesProcess.h"
using namespace std;
using namespace Assimp;
class utJoinVertices : public ::testing::Test {
public:
utJoinVertices() :
Test(), piProcess(nullptr), pcMesh(nullptr) {
// empty
}
protected:
virtual void SetUp();
virtual void TearDown();
protected:
JoinVerticesProcess *piProcess;
aiMesh *pcMesh;
};
// ------------------------------------------------------------------------------------------------
void utJoinVertices::SetUp() {
// construct the process
piProcess = new JoinVerticesProcess();
// create a quite small mesh for testing purposes -
// the mesh itself is *something* but it has redundant vertices
pcMesh = new aiMesh();
pcMesh->mNumVertices = 900;
aiVector3D *&pv = pcMesh->mVertices = new aiVector3D[900];
for (unsigned int i = 0; i < 3; ++i) {
const unsigned int base = i * 300;
for (unsigned int a = 0; a < 300; ++a) {
pv[base + a].x = pv[base + a].y = pv[base + a].z = (float)a;
}
}
// generate faces - each vertex is referenced once
pcMesh->mNumFaces = 300;
pcMesh->mFaces = new aiFace[300];
for (unsigned int i = 0, p = 0; i < 300; ++i) {
aiFace &face = pcMesh->mFaces[i];
face.mIndices = new unsigned int[face.mNumIndices = 3];
for (unsigned int a = 0; a < 3; ++a) {
face.mIndices[a] = p++;
}
}
// generate extra members - set them to zero to make sure they're identical
pcMesh->mTextureCoords[0] = new aiVector3D[900];
pcMesh->mBitangents = new aiVector3D[900];
pcMesh->mNormals = new aiVector3D[900];
pcMesh->mTangents = new aiVector3D[900];
for (unsigned int i = 0; i < 900; ++i) {
pcMesh->mTextureCoords[0][i] = aiVector3D(0.f);
pcMesh->mNormals[i] = aiVector3D(0.f);
pcMesh->mTangents[i] = aiVector3D(0.f);
pcMesh->mBitangents[i] = aiVector3D(0.f);
}
}
// ------------------------------------------------------------------------------------------------
void utJoinVertices::TearDown() {
delete this->pcMesh;
pcMesh = nullptr;
delete this->piProcess;
piProcess = nullptr;
}
// ------------------------------------------------------------------------------------------------
TEST_F(utJoinVertices, testProcess) {
// execute the step on the given data
piProcess->ProcessMesh(pcMesh, 0);
// the number of faces shouldn't change
ASSERT_EQ(300U, pcMesh->mNumFaces);
ASSERT_EQ(300U, pcMesh->mNumVertices);
ASSERT_TRUE(nullptr != pcMesh->mNormals);
ASSERT_TRUE(nullptr != pcMesh->mTangents);
ASSERT_TRUE(nullptr != pcMesh->mBitangents);
ASSERT_TRUE(nullptr != pcMesh->mTextureCoords[0]);
// the order doesn't care
float fSum = 0.f;
for (unsigned int i = 0; i < 300; ++i) {
aiVector3D &v = pcMesh->mVertices[i];
fSum += v.x + v.y + v.z;
EXPECT_FALSE(pcMesh->mNormals[i].x);
EXPECT_FALSE(pcMesh->mTangents[i].x);
EXPECT_FALSE(pcMesh->mBitangents[i].x);
EXPECT_FALSE(pcMesh->mTextureCoords[0][i].x);
}
EXPECT_EQ(150.f * 299.f * 3.f, fSum); // gaussian sum equation
}

View file

@ -0,0 +1,389 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utLWOImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/boxuv.lwo", aiProcess_ValidateDataStructure);
EXPECT_EQ(1u, scene->mNumMeshes);
EXPECT_NE(nullptr, scene->mMeshes[0]);
EXPECT_EQ(24u, scene->mMeshes[0]->mNumVertices);
//This test model is using n-gons, so 6 faces instead of 12 tris
EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
EXPECT_EQ(aiPrimitiveType_POLYGON, scene->mMeshes[0]->mPrimitiveTypes);
EXPECT_EQ(true, scene->mMeshes[0]->HasTextureCoords(0));
return nullptr != scene;
}
};
TEST_F(utLWOImportExport, importLWObox_uv) {
EXPECT_TRUE(importerTest());
}
TEST_F(utLWOImportExport, importLWOformatdetection) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/formatDetection", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOempty) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/invalid/empty.lwo", aiProcess_ValidateDataStructure);
EXPECT_EQ(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWObox_2uv_1unused) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/box_2uv_1unused.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWObox_2vc_1unused) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/box_2vc_1unused.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOconcave_polygon) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/concave_polygon.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOconcave_self_intersecting) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/concave_self_intersecting.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOhierarchy) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/hierarchy.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOhierarchy_smoothed) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/hierarchy_smoothed.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_x) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_x.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_x_scale_222_wrap_21) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_x_scale_222_wrap_21.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_y) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_y.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_y_scale_111) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_y_scale_111.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_y_scale_111_wrap_21) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_y_scale_111_wrap_21.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_cylindrical_z) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_cylindrical_z.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_planar_x) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_planar_x.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_planar_y) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_planar_y.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_planar_z) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_planar_z.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_planar_z_scale_111) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_planar_z_scale_111.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_spherical_x) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_spherical_x.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_spherical_x_scale_222_wrap_22) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_spherical_x_scale_222_wrap_22.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_spherical_y) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_spherical_y.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_spherical_) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_spherical_z.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_spherical_z_wrap_22) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_spherical_z_wrap_22.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOearth_uv_cylindrical_y) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/MappingModes/earth_uv_cylindrical_y.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOModoExport_vertNormals) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/ModoExport_vertNormals.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOnonplanar_polygon) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/nonplanar_polygon.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOCellShader) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/shader_test/CellShader.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOfastFresne) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/shader_test/fastFresnel.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOrealFresnel) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/shader_test/realFresnel.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOSuperCellShader) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/shader_test/SuperCellShader.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOsphere_with_gradient) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/sphere_with_gradient.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOsphere_with_mat_gloss_10pc) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/sphere_with_mat_gloss_10pc.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOSubdivision) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/Subdivision.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOtransparency) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/transparency.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOUglyVertexColors) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/UglyVertexColors.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOuvtest) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWO2/uvtest.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOBConcavePolygon) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWOB/ConcavePolygon.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOBbluewithcylindrictex) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWOB/MappingModes/bluewithcylindrictexz.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOBsphere_with_mat_gloss_10pc) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWOB/sphere_with_mat_gloss_10pc.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWOImportExport, importLWOBsphere_with_mat_gloss_50pc) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWO/LWOB/sphere_with_mat_gloss_50pc.lwo", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,138 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utLWSImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x.lws", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utLWSImportExport, importLWSFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utLWSImportExport, importLWSmove_x_post_linear) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_linear.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_bezier) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_bezier.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_stepped) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_stepped.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_oldformat_56) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_56.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_offset_repeat) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_offset_repeat.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_hermite) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_hermite.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_y_pre_ofrep_post_osc) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_y_pre_ofrep_post_osc.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_oldformat_6) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_oldformat_6.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_repeat) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_repeat.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_linear) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_linear.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_constant) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_constant.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_x_post_reset) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_x_post_reset.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}
TEST_F(utLWSImportExport, importLWSmove_xz_spline) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/LWS/move_xz_spline.lws", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
}

View file

@ -0,0 +1,136 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "PostProcessing/LimitBoneWeightsProcess.h"
#include <assimp/scene.h>
using namespace std;
using namespace Assimp;
class LimitBoneWeightsTest : public ::testing::Test {
public:
LimitBoneWeightsTest() :
Test(), mProcess(nullptr), mMesh(nullptr) {
// empty
}
protected:
virtual void SetUp();
virtual void TearDown();
protected:
LimitBoneWeightsProcess *mProcess;
aiMesh *mMesh;
};
// ------------------------------------------------------------------------------------------------
void LimitBoneWeightsTest::SetUp() {
// construct the process
this->mProcess = new LimitBoneWeightsProcess();
// now need to create a nice mesh for testing purposes
this->mMesh = new aiMesh();
mMesh->mNumVertices = 500;
mMesh->mVertices = new aiVector3D[500]; // uninit.
mMesh->mNumBones = 30;
mMesh->mBones = new aiBone *[30];
unsigned int iCur = 0;
for (unsigned int i = 0; i < 30; ++i) {
aiBone *pc = mMesh->mBones[i] = new aiBone();
pc->mNumWeights = 250;
pc->mWeights = new aiVertexWeight[pc->mNumWeights];
for (unsigned int qq = 0; qq < pc->mNumWeights; ++qq) {
aiVertexWeight &v = pc->mWeights[qq];
v.mVertexId = iCur++;
if (500 == iCur) {
iCur = 0;
}
v.mWeight = 1.0f / 15; // each vertex should occur once in two bones
}
}
}
// ------------------------------------------------------------------------------------------------
void LimitBoneWeightsTest::TearDown() {
delete mMesh;
delete mProcess;
}
// ------------------------------------------------------------------------------------------------
TEST_F(LimitBoneWeightsTest, testProcess) {
// execute the step on the given data
mProcess->ProcessMesh(mMesh);
// check whether everything is ok ...
typedef std::vector<LimitBoneWeightsProcess::Weight> VertexWeightList;
VertexWeightList *asWeights = new VertexWeightList[mMesh->mNumVertices];
for (unsigned int i = 0; i < mMesh->mNumVertices; ++i) {
asWeights[i].reserve(4);
}
// sort back as per-vertex lists
for (unsigned int i = 0; i < mMesh->mNumBones; ++i) {
aiBone &pcBone = **(mMesh->mBones + i);
for (unsigned int q = 0; q < pcBone.mNumWeights; ++q) {
aiVertexWeight weight = pcBone.mWeights[q];
asWeights[weight.mVertexId].emplace_back(i, weight.mWeight);
}
}
// now validate the size of the lists and check whether all weights sum to 1.0f
for (unsigned int i = 0; i < mMesh->mNumVertices; ++i) {
EXPECT_LE(asWeights[i].size(), 4U);
float fSum = 0.0f;
for (VertexWeightList::const_iterator iter = asWeights[i].begin(); iter != asWeights[i].end(); ++iter) {
fSum += (*iter).mWeight;
}
EXPECT_GE(fSum, 0.95F);
EXPECT_LE(fSum, 1.04F);
}
// delete allocated storage
delete[] asWeights;
// everything seems to be OK
}

View file

@ -0,0 +1,84 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, assimp tea
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utM3DImportExport : public AbstractImportExportBase {
public:
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
#ifndef ASSIMP_BUILD_NO_M3D_IMPORTER
return nullptr != scene;
#else
return nullptr == scene;
#endif // ASSIMP_BUILD_NO_M3D_IMPORTER
}
#ifndef ASSIMP_BUILD_NO_EXPORT
bool exporterTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals.m3d", aiProcess_ValidateDataStructure);
Exporter exporter;
aiReturn ret = exporter.Export(scene, "m3d", ASSIMP_TEST_MODELS_DIR "/M3D/cube_normals_out.m3d");
return ret == AI_SUCCESS;
}
#endif
};
TEST_F(utM3DImportExport, importM3DFromFileTest) {
EXPECT_TRUE(importerTest());
}
#ifndef ASSIMP_BUILD_NO_EXPORT
TEST_F(utM3DImportExport, exportM3DFromFileTest) {
EXPECT_TRUE(exporterTest());
}
#endif // ASSIMP_BUILD_NO_EXPORT

View file

@ -0,0 +1,62 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2026, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utMDCImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
//const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0);
static_cast<void>(importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/MDC/spider.mdc", 0));
return true;
}
};
TEST_F(utMDCImportExport, importMDCFromFileTest) {
EXPECT_TRUE(importerTest());
}

Some files were not shown because too many files have changed in this diff Show more