Add regression test for issue 321

This commit is contained in:
Syoyo Fujita 2021-04-29 16:04:52 +09:00
parent d07b976d59
commit 688ba8a60e
2 changed files with 297 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -436,6 +436,36 @@ TEST_CASE("serialize-empty-material", "[issue-294]") {
} }
TEST_CASE("empty-skeleton-id", "[issue-321]") {
tinygltf::Model model;
tinygltf::TinyGLTF ctx;
std::string err;
std::string warn;
bool ret = ctx.LoadASCIIFromFile(&model, &err, &warn, "../models/regression/unassigned-skeleton.gltf");
if (!err.empty()) {
std::cerr << err << std::endl;
}
REQUIRE(true == ret);
REQUIRE(model.skins.size() == 1);
REQUIRE(model.skins[0].skeleton == -1); // unassigned
std::stringstream os;
ctx.WriteGltfSceneToStream(&model, os, false, false);
// use nlohmann json
nlohmann::json j = nlohmann::json::parse(os.str());
// Ensure `skeleton` property is not written to .gltf(was serialized as -1)
REQUIRE(1 == j["skins"].size());
REQUIRE(j["skins"][0].is_object());
REQUIRE(j["skins"][0].count("skeleton") == 0);
}
#ifndef TINYGLTF_NO_FS #ifndef TINYGLTF_NO_FS
TEST_CASE("expandpath-utf-8", "[pr-226]") { TEST_CASE("expandpath-utf-8", "[pr-226]") {