mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-16 14:05:59 +08:00
Added error handling to ostream writing
This commit is contained in:
parent
84a83d39f5
commit
7658624bb4
@ -504,7 +504,8 @@ TEST_CASE("serialize-empty-material", "[issue-294]") {
|
|||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
|
|
||||||
tinygltf::TinyGLTF ctx;
|
tinygltf::TinyGLTF ctx;
|
||||||
ctx.WriteGltfSceneToStream(&m, os, false, false);
|
bool ret = ctx.WriteGltfSceneToStream(&m, os, false, false);
|
||||||
|
REQUIRE(true == ret);
|
||||||
|
|
||||||
// use nlohmann json
|
// use nlohmann json
|
||||||
nlohmann::json j = nlohmann::json::parse(os.str());
|
nlohmann::json j = nlohmann::json::parse(os.str());
|
||||||
@ -532,7 +533,8 @@ TEST_CASE("empty-skeleton-id", "[issue-321]") {
|
|||||||
|
|
||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
|
|
||||||
ctx.WriteGltfSceneToStream(&model, os, false, false);
|
ret = ctx.WriteGltfSceneToStream(&model, os, false, false);
|
||||||
|
REQUIRE(true == ret);
|
||||||
|
|
||||||
// use nlohmann json
|
// use nlohmann json
|
||||||
nlohmann::json j = nlohmann::json::parse(os.str());
|
nlohmann::json j = nlohmann::json::parse(os.str());
|
||||||
@ -634,8 +636,9 @@ TEST_CASE("serialize-const-image", "[issue-394]") {
|
|||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
|
|
||||||
tinygltf::TinyGLTF ctx;
|
tinygltf::TinyGLTF ctx;
|
||||||
ctx.WriteGltfSceneToStream(const_cast<const tinygltf::Model *>(&m), os, false,
|
bool ret = ctx.WriteGltfSceneToStream(const_cast<const tinygltf::Model *>(&m), os, false,
|
||||||
false);
|
false);
|
||||||
|
REQUIRE(true == ret);
|
||||||
REQUIRE(m.images[0].uri == i.uri);
|
REQUIRE(m.images[0].uri == i.uri);
|
||||||
|
|
||||||
// use nlohmann json
|
// use nlohmann json
|
||||||
|
@ -7780,7 +7780,7 @@ static void SerializeGltfModel(const Model *model, detail::json &o) {
|
|||||||
|
|
||||||
static bool WriteGltfStream(std::ostream &stream, const std::string &content) {
|
static bool WriteGltfStream(std::ostream &stream, const std::string &content) {
|
||||||
stream << content << std::endl;
|
stream << content << std::endl;
|
||||||
return true;
|
return stream.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool WriteGltfFile(const std::string &output,
|
static bool WriteGltfFile(const std::string &output,
|
||||||
@ -7863,8 +7863,8 @@ static bool WriteBinaryGltfStream(std::ostream &stream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check error on stream.write
|
stream.flush();
|
||||||
return true;
|
return stream.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool WriteBinaryGltfFile(const std::string &output,
|
static bool WriteBinaryGltfFile(const std::string &output,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user