Replace exception by error in log (#6133)
* Replace exception by error in log * Separate tests for new behaviour --------- Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
This commit is contained in:
@@ -185,7 +185,7 @@ void SetAccessorRange(Ref<Accessor> acc, void *data, size_t count,
|
||||
|
||||
// Allocate and initialize with large values.
|
||||
for (unsigned int i = 0; i < numCompsOut; i++) {
|
||||
acc->min.push_back(std::numeric_limits<double>::max());
|
||||
acc->min.push_back(std::numeric_limits<double>::min());
|
||||
acc->max.push_back(-std::numeric_limits<double>::max());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_IMPORTER
|
||||
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
@@ -444,7 +445,7 @@ inline Value *FindArrayInContext(Value &val, const char *memberId, const char *c
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
inline Value *FindObjectInContext(Value &val, const char *memberId, const char *context, const char *extraContext = nullptr) {
|
||||
inline Value *FindObjectInContext(Value &val, const char * memberId, const char *context, const char *extraContext = nullptr) {
|
||||
if (!val.IsObject()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -453,8 +454,9 @@ inline Value *FindObjectInContext(Value &val, const char *memberId, const char *
|
||||
return nullptr;
|
||||
}
|
||||
if (!it->value.IsObject()) {
|
||||
throwUnexpectedTypeError("object", memberId, context, extraContext);
|
||||
}
|
||||
ASSIMP_LOG_ERROR("Member \"", memberId, "\" was not of type \"", context, "\" when reading ", extraContext);
|
||||
return nullptr;
|
||||
}
|
||||
return &it->value;
|
||||
}
|
||||
|
||||
|
||||
@@ -933,8 +933,8 @@ TEST_F(utglTF2ImportExport, wrongTypes) {
|
||||
TUPLE("/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]"),
|
||||
TUPLE("/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]"),
|
||||
TUPLE("/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]"),
|
||||
TUPLE("/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]"),
|
||||
TUPLE("/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]")
|
||||
//TUPLE("/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]"),
|
||||
//TUPLE("/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]")
|
||||
#undef TUPLE
|
||||
};
|
||||
for (const auto& tuple : wrongTypes)
|
||||
@@ -952,6 +952,28 @@ TEST_F(utglTF2ImportExport, wrongTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, wrongObject) {
|
||||
// Deliberately broken version of the BoxTextured.gltf asset.
|
||||
using tup_T = std::tuple<std::string, std::string, std::string, std::string>;
|
||||
std::vector<tup_T> wrongTypes = {
|
||||
#ifdef __cpp_lib_constexpr_tuple
|
||||
#define TUPLE(x, y, z, w) \
|
||||
{ x, y, z, w }
|
||||
#else
|
||||
#define TUPLE(x, y, z, w) tup_T(x, y, z, w)
|
||||
#endif
|
||||
TUPLE("/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]"),
|
||||
TUPLE("/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]")
|
||||
#undef TUPLE
|
||||
};
|
||||
for (const auto &tuple : wrongTypes) {
|
||||
const auto &file = std::get<0>(tuple);
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR + file, aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(scene, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// This class provides a fake schema to the GLTF importer.
|
||||
/// It just checks that the file has a top-level "scene" property which is an integer.
|
||||
|
||||
Reference in New Issue
Block a user