mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #27579 from fengyuentau:4x/core/filestorage
core: support parsing null in json parser in FileStorage #27579 Fixes https://github.com/opencv/opencv/issues/27578 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -1545,6 +1545,30 @@ TEST(Core_InputOutput, FileStorage_format_yml_gz)
|
||||
EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
|
||||
}
|
||||
|
||||
TEST(Core_InputOutput, FileStorage_json_null_object)
|
||||
{
|
||||
std::string test =
|
||||
"{ "
|
||||
"\"padding\": null,"
|
||||
"\"truncation\": null,"
|
||||
"\"version\": \"1.0\""
|
||||
"}";
|
||||
FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
|
||||
|
||||
ASSERT_TRUE(fs["padding"].isNone());
|
||||
ASSERT_TRUE(fs["truncation"].isNone());
|
||||
ASSERT_TRUE(fs["version"].isString());
|
||||
|
||||
ASSERT_EQ(fs["padding"].name(), "padding");
|
||||
ASSERT_EQ(fs["truncation"].name(), "truncation");
|
||||
ASSERT_EQ(fs["version"].name(), "version");
|
||||
|
||||
ASSERT_EQ(fs["padding"].string(), "");
|
||||
ASSERT_EQ(fs["truncation"].string(), "");
|
||||
ASSERT_EQ(fs["version"].string(), "1.0");
|
||||
fs.release();
|
||||
}
|
||||
|
||||
TEST(Core_InputOutput, FileStorage_json_named_nodes)
|
||||
{
|
||||
std::string test =
|
||||
|
||||
Reference in New Issue
Block a user