提交 aa54acd5 编写于 作者: V Vladislav Sovrasov

core: add a test to reproduce #9312

上级 87c27a07
......@@ -1345,3 +1345,24 @@ TEST(Core_InputOutput, FileStorage_json_bool)
ASSERT_EQ((int)fs["bool_false"], 0);
fs.release();
}
TEST(Core_InputOutput, FileStorage_free_file_after_exception)
{
const std::string fileName = "test.yml";
const std::string content = "%YAML:1.0\n cameraMatrix;:: !<tag:yaml.org,2002:opencv-matrix>\n";
fstream testFile;
testFile.open(fileName, std::fstream::out);
if(!testFile.is_open()) FAIL();
testFile << content;
testFile.close();
try
{
FileStorage fs(fileName, FileStorage::READ + FileStorage::FORMAT_YAML);
}
catch (const std::exception&)
{
ASSERT_EQ(std::remove(fileName.c_str()), 0);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册