Merge branch 'master' into explicitly-default-dtors
commit
f527e56f22
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2022, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -50,23 +48,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
void Assimp::defaultAiAssertHandler(const char* failedExpression, const char* file, int line)
|
void Assimp::defaultAiAssertHandler(const char* failedExpression, const char* file, int line) {
|
||||||
{
|
|
||||||
std::cerr << "ai_assert failure in " << file << "(" << line << "): " << failedExpression << std::endl;
|
std::cerr << "ai_assert failure in " << file << "(" << line << "): " << failedExpression << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
Assimp::AiAssertHandler s_handler = Assimp::defaultAiAssertHandler;
|
Assimp::AiAssertHandler s_handler = Assimp::defaultAiAssertHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assimp::setAiAssertHandler(AiAssertHandler handler)
|
void Assimp::setAiAssertHandler(AiAssertHandler handler) {
|
||||||
{
|
if (handler != nullptr) {
|
||||||
s_handler = handler;
|
s_handler = handler;
|
||||||
|
} else {
|
||||||
|
s_handler = Assimp::defaultAiAssertHandler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assimp::aiAssertViolation(const char* failedExpression, const char* file, int line)
|
void Assimp::aiAssertViolation(const char* failedExpression, const char* file, int line) {
|
||||||
{
|
|
||||||
s_handler(failedExpression, file, line);
|
s_handler(failedExpression, file, line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,29 +47,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
#include <assimp/defs.h>
|
#include <assimp/defs.h>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
/** Signature of functions which handle assert violations.
|
|
||||||
*/
|
|
||||||
using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** Set the assert handler.
|
/**
|
||||||
*/
|
* @brief Signature of functions which handle assert violations.
|
||||||
ASSIMP_API void setAiAssertHandler(AiAssertHandler handler);
|
*/
|
||||||
|
using AiAssertHandler = void (*)(const char* failedExpression, const char* file, int line);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** The assert handler which is set by default.
|
/**
|
||||||
*
|
* @brief Set the assert handler.
|
||||||
* This issues a message to stderr and calls abort.
|
*/
|
||||||
*/
|
ASSIMP_API void setAiAssertHandler(AiAssertHandler handler);
|
||||||
ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line);
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** The assert handler which is set by default.
|
||||||
|
*
|
||||||
|
* @brief This issues a message to stderr and calls abort.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief Dispatches an assert violation to the assert handler.
|
||||||
|
*/
|
||||||
|
ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
/** Dispatches an assert violation to the assert handler.
|
|
||||||
*/
|
|
||||||
ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line);
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif // INCLUDED_AI_ASSERTHANDLER_H
|
#endif // INCLUDED_AI_ASSERTHANDLER_H
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Assimp {
|
||||||
|
|
||||||
namespace Base64 {
|
namespace Base64 {
|
||||||
|
|
||||||
static const uint8_t tableDecodeBase64[128] = {
|
static constexpr uint8_t tableDecodeBase64[128] = {
|
||||||
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, 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, 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, 62, 0, 0, 0, 63,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
|
||||||
|
@ -57,7 +57,7 @@ static const uint8_t tableDecodeBase64[128] = {
|
||||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *tableEncodeBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
static constexpr char tableEncodeBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
|
|
||||||
static inline char EncodeChar(uint8_t b) {
|
static inline char EncodeChar(uint8_t b) {
|
||||||
return tableEncodeBase64[size_t(b)];
|
return tableEncodeBase64[size_t(b)];
|
||||||
|
@ -71,6 +71,11 @@ inline uint8_t DecodeChar(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Encode(const uint8_t *in, size_t inLength, std::string &out) {
|
void Encode(const uint8_t *in, size_t inLength, std::string &out) {
|
||||||
|
if (in == nullptr || inLength==0) {
|
||||||
|
out.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size_t outLength = ((inLength + 2) / 3) * 4;
|
size_t outLength = ((inLength + 2) / 3) * 4;
|
||||||
|
|
||||||
size_t j = out.size();
|
size_t j = out.size();
|
||||||
|
@ -115,8 +120,14 @@ std::string Encode(const std::vector<uint8_t> &in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Decode(const char *in, size_t inLength, uint8_t *&out) {
|
size_t Decode(const char *in, size_t inLength, uint8_t *&out) {
|
||||||
|
if (in == nullptr) {
|
||||||
|
out = nullptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (inLength % 4 != 0) {
|
if (inLength % 4 != 0) {
|
||||||
throw DeadlyImportError("Invalid base64 encoded data: \"", std::string(in, std::min(size_t(32), inLength)), "\", length:", inLength);
|
throw DeadlyImportError("Invalid base64 encoded data: \"", std::string(in, std::min(size_t(32), inLength)),
|
||||||
|
"\", length:", inLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inLength < 4) {
|
if (inLength < 4) {
|
||||||
|
|
|
@ -232,19 +232,23 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
|
||||||
std::string::size_type pos = pFile.find_last_of('.');
|
std::string::size_type pos = pFile.find_last_of('.');
|
||||||
|
|
||||||
// no file extension - can't read
|
// no file extension - can't read
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const char *ext_real = &pFile[pos + 1];
|
const char *ext_real = &pFile[pos + 1];
|
||||||
if (!ASSIMP_stricmp(ext_real, ext0))
|
if (!ASSIMP_stricmp(ext_real, ext0)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// check for other, optional, file extensions
|
// check for other, optional, file extensions
|
||||||
if (ext1 && !ASSIMP_stricmp(ext_real, ext1))
|
if (ext1 && !ASSIMP_stricmp(ext_real, ext1)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (ext2 && !ASSIMP_stricmp(ext_real, ext2))
|
if (ext2 && !ASSIMP_stricmp(ext_real, ext2)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,17 +66,26 @@ BaseProcess::~BaseProcess() {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BaseProcess::ExecuteOnScene(Importer *pImp) {
|
void BaseProcess::ExecuteOnScene(Importer *pImp) {
|
||||||
ai_assert( nullptr != pImp );
|
ai_assert( nullptr != pImp );
|
||||||
ai_assert( nullptr != pImp->Pimpl()->mScene);
|
if (pImp == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ai_assert(nullptr != pImp->Pimpl()->mScene);
|
||||||
|
if (pImp->Pimpl()->mScene == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
progress = pImp->GetProgressHandler();
|
progress = pImp->GetProgressHandler();
|
||||||
ai_assert(nullptr != progress);
|
ai_assert(nullptr != progress);
|
||||||
|
if (progress == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetupProperties(pImp);
|
SetupProperties(pImp);
|
||||||
|
|
||||||
// catch exceptions thrown inside the PostProcess-Step
|
// catch exceptions thrown inside the PostProcess-Step
|
||||||
try {
|
try {
|
||||||
Execute(pImp->Pimpl()->mScene);
|
Execute(pImp->Pimpl()->mScene);
|
||||||
|
|
||||||
} catch (const std::exception &err) {
|
} catch (const std::exception &err) {
|
||||||
|
|
||||||
// extract error description
|
// extract error description
|
||||||
|
|
|
@ -175,23 +175,24 @@ private:
|
||||||
* should be executed. If the function returns true, the class' Execute()
|
* should be executed. If the function returns true, the class' Execute()
|
||||||
* function is called subsequently.
|
* function is called subsequently.
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API_WINONLY BaseProcess {
|
class ASSIMP_API BaseProcess {
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor to be privately used by Importer */
|
/** @brief onstructor to be privately used by Importer */
|
||||||
BaseProcess() AI_NO_EXCEPT;
|
BaseProcess() AI_NO_EXCEPT;
|
||||||
|
|
||||||
/** Destructor, private as well */
|
/** @brief Destructor, private as well */
|
||||||
virtual ~BaseProcess();
|
virtual ~BaseProcess();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the processing step is present in the given flag.
|
/**
|
||||||
|
* @brief Returns whether the processing step is present in the given flag.
|
||||||
* @param pFlags The processing flags the importer was called with. A
|
* @param pFlags The processing flags the importer was called with. A
|
||||||
* bitwise combination of #aiPostProcessSteps.
|
* bitwise combination of #aiPostProcessSteps.
|
||||||
* @return true if the process is present in this flag fields,
|
* @return true if the process is present in this flag fields,
|
||||||
* false if not.
|
* false if not.
|
||||||
*/
|
*/
|
||||||
virtual bool IsActive(unsigned int pFlags) const = 0;
|
virtual bool IsActive(unsigned int pFlags) const = 0;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -200,33 +201,36 @@ public:
|
||||||
virtual bool RequireVerboseFormat() const;
|
virtual bool RequireVerboseFormat() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Executes the post processing step on the given imported data.
|
/**
|
||||||
* The function deletes the scene if the postprocess step fails (
|
* @brief Executes the post processing step on the given imported data.
|
||||||
* the object pointer will be set to nullptr).
|
* The function deletes the scene if the post-process step fails (
|
||||||
* @param pImp Importer instance (pImp->mScene must be valid)
|
* the object pointer will be set to nullptr).
|
||||||
*/
|
* @param pImp Importer instance (pImp->mScene must be valid)
|
||||||
|
*/
|
||||||
void ExecuteOnScene(Importer *pImp);
|
void ExecuteOnScene(Importer *pImp);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Called prior to ExecuteOnScene().
|
/**
|
||||||
* The function is a request to the process to update its configuration
|
* @brief Called prior to ExecuteOnScene().
|
||||||
* basing on the Importer's configuration property list.
|
* The function is a request to the process to update its configuration
|
||||||
*/
|
* basing on the Importer's configuration property list.
|
||||||
|
*/
|
||||||
virtual void SetupProperties(const Importer *pImp);
|
virtual void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Executes the post processing step on the given imported data.
|
/**
|
||||||
* A process should throw an ImportErrorException* if it fails.
|
* @brief Executes the post processing step on the given imported data.
|
||||||
* This method must be implemented by deriving classes.
|
* A process should throw an ImportErrorException* if it fails.
|
||||||
* @param pScene The imported data to work at.
|
* This method must be implemented by deriving classes.
|
||||||
*/
|
* @param pScene The imported data to work at.
|
||||||
|
*/
|
||||||
virtual void Execute(aiScene *pScene) = 0;
|
virtual void Execute(aiScene *pScene) = 0;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Assign a new SharedPostProcessInfo to the step. This object
|
/** Assign a new SharedPostProcessInfo to the step. This object
|
||||||
* allows multiple postprocess steps to share data.
|
* allows multiple post-process steps to share data.
|
||||||
* @param sh May be nullptr
|
* @param sh May be nullptr
|
||||||
*/
|
*/
|
||||||
inline void SetSharedData(SharedPostProcessInfo *sh) {
|
inline void SetSharedData(SharedPostProcessInfo *sh) {
|
||||||
shared = sh;
|
shared = sh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,8 +341,7 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex) {
|
||||||
uniqueVertices.push_back(v);
|
uniqueVertices.push_back(v);
|
||||||
if (hasAnimMeshes) {
|
if (hasAnimMeshes) {
|
||||||
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
for (unsigned int animMeshIndex = 0; animMeshIndex < pMesh->mNumAnimMeshes; animMeshIndex++) {
|
||||||
Vertex aniMeshVertex(pMesh->mAnimMeshes[animMeshIndex], a);
|
uniqueAnimatedVertices[animMeshIndex].emplace_back(pMesh->mAnimMeshes[animMeshIndex], a);
|
||||||
uniqueAnimatedVertices[animMeshIndex].push_back(v);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
|
|
|
@ -50,16 +50,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace Base64 {
|
namespace Base64 {
|
||||||
|
|
||||||
/// @brief Will encode the given
|
/// @brief Will encode the given character buffer from UTF64 to ASCII
|
||||||
/// @param in
|
/// @param in The UTF-64 buffer.
|
||||||
/// @param inLength
|
/// @param inLength The size of the buffer
|
||||||
/// @param out
|
/// @param out The encoded ASCII string.
|
||||||
void Encode(const uint8_t *in, size_t inLength, std::string &out);
|
void Encode(const uint8_t *in, size_t inLength, std::string &out);
|
||||||
|
|
||||||
|
/// @brief Will encode the given character buffer from UTF64 to ASCII.
|
||||||
|
/// @param in A vector, which contains the buffer for encoding.
|
||||||
|
/// @param out The encoded ASCII string.
|
||||||
void Encode(const std::vector<uint8_t>& in, std::string &out);
|
void Encode(const std::vector<uint8_t>& in, std::string &out);
|
||||||
|
|
||||||
|
/// @brief Will encode the given character buffer from UTF64 to ASCII.
|
||||||
|
/// @param in A vector, which contains the buffer for encoding.
|
||||||
|
/// @return The encoded ASCII string.
|
||||||
std::string Encode(const std::vector<uint8_t>& in);
|
std::string Encode(const std::vector<uint8_t>& in);
|
||||||
|
|
||||||
|
/// @brief Will decode the given character buffer from ASCII to UTF64.
|
||||||
|
/// @param in The ASCII buffer to decode.
|
||||||
|
/// @param inLength The size of the buffer.
|
||||||
|
/// @param out The decoded buffer.
|
||||||
|
/// @return The new buffer size.
|
||||||
size_t Decode(const char *in, size_t inLength, uint8_t *&out);
|
size_t Decode(const char *in, size_t inLength, uint8_t *&out);
|
||||||
|
|
||||||
|
/// @brief Will decode the given character buffer from ASCII to UTF64.
|
||||||
|
/// @param in The ASCII buffer to decode as a std::string.
|
||||||
|
/// @param out The decoded buffer.
|
||||||
|
/// @return The new buffer size.
|
||||||
size_t Decode(const std::string& in, std::vector<uint8_t>& out);
|
size_t Decode(const std::string& in, std::vector<uint8_t>& out);
|
||||||
|
|
||||||
|
/// @brief Will decode the given character buffer from ASCII to UTF64.
|
||||||
|
/// @param in The ASCII string.
|
||||||
|
/// @return The decoded buffer in a vector.
|
||||||
std::vector<uint8_t> Decode(const std::string& in);
|
std::vector<uint8_t> Decode(const std::string& in);
|
||||||
|
|
||||||
} // namespace Base64
|
} // namespace Base64
|
||||||
|
|
|
@ -71,7 +71,6 @@ SET( COMMON
|
||||||
unit/AssimpAPITest_aiQuaternion.cpp
|
unit/AssimpAPITest_aiQuaternion.cpp
|
||||||
unit/AssimpAPITest_aiVector2D.cpp
|
unit/AssimpAPITest_aiVector2D.cpp
|
||||||
unit/AssimpAPITest_aiVector3D.cpp
|
unit/AssimpAPITest_aiVector3D.cpp
|
||||||
unit/Common/utHash.cpp
|
|
||||||
unit/MathTest.cpp
|
unit/MathTest.cpp
|
||||||
unit/MathTest.h
|
unit/MathTest.h
|
||||||
unit/RandomNumberGeneration.h
|
unit/RandomNumberGeneration.h
|
||||||
|
@ -98,6 +97,8 @@ SET( COMMON
|
||||||
unit/Common/utAssertHandler.cpp
|
unit/Common/utAssertHandler.cpp
|
||||||
unit/Common/utXmlParser.cpp
|
unit/Common/utXmlParser.cpp
|
||||||
unit/Common/utBase64.cpp
|
unit/Common/utBase64.cpp
|
||||||
|
unit/Common/utHash.cpp
|
||||||
|
unit/Common/utBaseProcess.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( IMPORTERS
|
SET( IMPORTERS
|
||||||
|
|
|
@ -47,26 +47,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
class Base64Test : public ::testing::Test {
|
class Base64Test : public ::testing::Test {};
|
||||||
public:
|
|
||||||
virtual void SetUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void TearDown() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const std::vector<uint8_t> assimpStringBinary = { 97, 115, 115, 105, 109, 112 };
|
static const std::vector<uint8_t> assimpStringBinary = { 97, 115, 115, 105, 109, 112 };
|
||||||
static const std::string assimpStringEncoded = "YXNzaW1w";
|
static const std::string assimpStringEncoded = "YXNzaW1w";
|
||||||
|
|
||||||
TEST_F( Base64Test, encodeTest ) {
|
TEST_F( Base64Test, encodeTest) {
|
||||||
EXPECT_EQ( "", Base64::Encode (std::vector<uint8_t>{}) );
|
EXPECT_EQ( "", Base64::Encode(std::vector<uint8_t>{}) );
|
||||||
EXPECT_EQ( "Vg==", Base64::Encode (std::vector<uint8_t>{ 86 }) );
|
EXPECT_EQ( "Vg==", Base64::Encode(std::vector<uint8_t>{ 86 }) );
|
||||||
EXPECT_EQ( assimpStringEncoded, Base64::Encode (assimpStringBinary) );
|
EXPECT_EQ( assimpStringEncoded, Base64::Encode(assimpStringBinary) );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( Base64Test, decodeTest ) {
|
TEST_F( Base64Test, encodeTestWithNullptr ) {
|
||||||
EXPECT_EQ( std::vector<uint8_t> {}, Base64::Decode ("") );
|
std::string out;
|
||||||
EXPECT_EQ( std::vector<uint8_t> { 86 }, Base64::Decode ("Vg==") );
|
Base64::Encode(nullptr, 100u, out);
|
||||||
EXPECT_EQ( assimpStringBinary, Base64::Decode (assimpStringEncoded) );
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2022, 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 "Common/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
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue