new stuff
This commit is contained in:
parent
8998bc3936
commit
64c8492e5c
6907 changed files with 3401899 additions and 0 deletions
109
vendor/assimp/test/unit/Common/uiScene.cpp
vendored
Normal file
109
vendor/assimp/test/unit/Common/uiScene.cpp
vendored
Normal 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) {
|
||||
}
|
||||
110
vendor/assimp/test/unit/Common/utAssertHandler.cpp
vendored
Normal file
110
vendor/assimp/test/unit/Common/utAssertHandler.cpp
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
81
vendor/assimp/test/unit/Common/utBase64.cpp
vendored
Normal file
81
vendor/assimp/test/unit/Common/utBase64.cpp
vendored
Normal 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);
|
||||
}
|
||||
110
vendor/assimp/test/unit/Common/utBaseProcess.cpp
vendored
Normal file
110
vendor/assimp/test/unit/Common/utBaseProcess.cpp
vendored
Normal 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
|
||||
|
||||
}
|
||||
56
vendor/assimp/test/unit/Common/utHash.cpp
vendored
Normal file
56
vendor/assimp/test/unit/Common/utHash.cpp
vendored
Normal 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);
|
||||
}
|
||||
67
vendor/assimp/test/unit/Common/utLineSplitter.cpp
vendored
Normal file
67
vendor/assimp/test/unit/Common/utLineSplitter.cpp
vendored
Normal 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 );
|
||||
}
|
||||
52
vendor/assimp/test/unit/Common/utLogger.cpp
vendored
Normal file
52
vendor/assimp/test/unit/Common/utLogger.cpp
vendored
Normal 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);
|
||||
}
|
||||
54
vendor/assimp/test/unit/Common/utMaybe.cpp
vendored
Normal file
54
vendor/assimp/test/unit/Common/utMaybe.cpp
vendored
Normal 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);
|
||||
}
|
||||
97
vendor/assimp/test/unit/Common/utMesh.cpp
vendored
Normal file
97
vendor/assimp/test/unit/Common/utMesh.cpp
vendored
Normal 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));
|
||||
}
|
||||
|
||||
66
vendor/assimp/test/unit/Common/utParsingUtils.cpp
vendored
Normal file
66
vendor/assimp/test/unit/Common/utParsingUtils.cpp
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
120
vendor/assimp/test/unit/Common/utSpatialSort.cpp
vendored
Normal file
120
vendor/assimp/test/unit/Common/utSpatialSort.cpp
vendored
Normal 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;
|
||||
}
|
||||
57
vendor/assimp/test/unit/Common/utStandardShapes.cpp
vendored
Normal file
57
vendor/assimp/test/unit/Common/utStandardShapes.cpp
vendored
Normal 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;
|
||||
}
|
||||
|
||||
86
vendor/assimp/test/unit/Common/utXmlParser.cpp
vendored
Normal file
86
vendor/assimp/test/unit/Common/utXmlParser.cpp
vendored
Normal 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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue