[opencv] 151/251: Missed NAMED bit of JSON nodes tag
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.
commit 3515f6ec3329d35624b4e30b55ca55cf469b0cc0
Author: dkurt <dmitry.kurtaev+github at gmail.com>
Date: Tue Jul 25 13:39:32 2017 +0300
Missed NAMED bit of JSON nodes tag
---
modules/core/src/persistence.cpp | 1 +
modules/core/test/test_io.cpp | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index a675784..963c4a1 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -3781,6 +3781,7 @@ static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node )
ptr = icvJSONParseMap( fs, ptr, child );
else
ptr = icvJSONParseValue( fs, ptr, child );
+ child->tag |= CV_NODE_NAMED;
}
}
diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp
index 939e80d..c121386 100644
--- a/modules/core/test/test_io.cpp
+++ b/modules/core/test/test_io.cpp
@@ -1292,3 +1292,29 @@ TEST(Core_InputOutput, FileStorage_format_yml_gz)
fs.open("opencv_storage.yml.gz", FileStorage::WRITE | FileStorage::MEMORY);
EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
}
+
+TEST(Core_InputOutput, FileStorage_json_named_nodes)
+{
+ std::string test =
+ "{ "
+ "\"int_value\": -324,"
+ "\"map_value\": {"
+ "\"str_value\": \"mystring\""
+ "},"
+ "\"array\": [0.2, 0.1]"
+ "}";
+ FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
+
+ ASSERT_TRUE(fs["int_value"].isNamed());
+ ASSERT_TRUE(fs["map_value"].isNamed());
+ ASSERT_TRUE(fs["map_value"]["str_value"].isNamed());
+ ASSERT_TRUE(fs["array"].isNamed());
+ ASSERT_FALSE(fs["array"][0].isNamed());
+ ASSERT_FALSE(fs["array"][1].isNamed());
+
+ ASSERT_EQ(fs["int_value"].name(), "int_value");
+ ASSERT_EQ(fs["map_value"].name(), "map_value");
+ ASSERT_EQ(fs["map_value"]["str_value"].name(), "str_value");
+ ASSERT_EQ(fs["array"].name(), "array");
+ fs.release();
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list