[opencv] 77/98: operator<< handles keys starting with underscore
Mattia Rizzolo
mattia at debian.org
Tue Oct 4 17:51:29 UTC 2016
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to annotated tag 2.4.13
in repository opencv.
commit b6d8c9d9906ac1daab65ec1ca49852d0a36c40ef
Author: Philipp Hasper <vcs at hasper.info>
Date: Mon Apr 11 09:55:33 2016 +0200
operator<< handles keys starting with underscore
---
modules/core/src/persistence.cpp | 2 +-
modules/core/test/test_io.cpp | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index fe39dc0..bdf2f59 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -5248,7 +5248,7 @@ FileStorage& operator << (FileStorage& fs, const string& str)
}
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
{
- if( !cv_isalpha(*_str) )
+ if (!cv_isalpha(*_str) && *_str != '_')
CV_Error_( CV_StsError, ("Incorrect element name %s", _str) );
fs.elname = str;
fs.state = VALUE_EXPECTED + INSIDE_MAP;
diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp
index 431ff43..3972a4a 100644
--- a/modules/core/test/test_io.cpp
+++ b/modules/core/test/test_io.cpp
@@ -522,3 +522,14 @@ TEST(Core_InputOutput, FileStorage)
sprintf(arr, "sprintf is hell %d", 666);
EXPECT_NO_THROW(f << arr);
}
+
+TEST(Core_InputOutput, FileStorageKey)
+{
+ cv::FileStorage f("dummy.yml", cv::FileStorage::WRITE | cv::FileStorage::MEMORY);
+
+ EXPECT_NO_THROW(f << "key1" << "value1");
+ EXPECT_NO_THROW(f << "_key2" << "value2");
+ EXPECT_NO_THROW(f << "key_3" << "value3");
+ const std::string expected = "%YAML:1.0\nkey1: value1\n_key2: value2\nkey_3: value3\n";
+ ASSERT_STREQ(f.releaseAndGetString().c_str(), expected.c_str());
+}
--
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