[opencv] 158/251: Fix JSON booleans without quotes
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:38 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 583b3275232c2b4878a4f25ef73762f8247fbc4e
Author: dkurt <dmitry.kurtaev+github at gmail.com>
Date: Wed Jul 26 11:08:09 2017 +0300
Fix JSON booleans without quotes
---
modules/core/src/persistence.cpp | 1 -
modules/core/test/test_io.cpp | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index 963c4a1..3f12fc4 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -3665,7 +3665,6 @@ static char* icvJSONParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node )
{
CV_PARSE_ERROR( "Unrecognized value" );
}
- ptr++;
}
return ptr;
diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp
index c121386..4d3bb81 100644
--- a/modules/core/test/test_io.cpp
+++ b/modules/core/test/test_io.cpp
@@ -1318,3 +1318,30 @@ TEST(Core_InputOutput, FileStorage_json_named_nodes)
ASSERT_EQ(fs["array"].name(), "array");
fs.release();
}
+
+TEST(Core_InputOutput, FileStorage_json_bool)
+{
+ std::string test =
+ "{ "
+ "\"str_true\": \"true\","
+ "\"map_value\": {"
+ "\"int_value\": -33333,\n"
+ "\"bool_true\": true,"
+ "\"str_false\": \"false\","
+ "},"
+ "\"bool_false\": false, \n"
+ "\"array\": [0.1, 0.2]"
+ "}";
+ FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
+
+ ASSERT_TRUE(fs["str_true"].isString());
+ ASSERT_TRUE(fs["map_value"]["bool_true"].isInt());
+ ASSERT_TRUE(fs["map_value"]["str_false"].isString());
+ ASSERT_TRUE(fs["bool_false"].isInt());
+
+ ASSERT_EQ((std::string)fs["str_true"], "true");
+ ASSERT_EQ((int)fs["map_value"]["bool_true"], 1);
+ ASSERT_EQ((std::string)fs["map_value"]["str_false"], "false");
+ ASSERT_EQ((int)fs["bool_false"], 0);
+ 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