mirror of
https://github.com/opencv/opencv.git
synced 2024-12-03 08:19:52 +08:00
Merge pull request #6383 from alalek:backport_6381
This commit is contained in:
commit
ff3bb9f4e6
@ -5248,7 +5248,7 @@ FileStorage& operator << (FileStorage& fs, const string& str)
|
|||||||
}
|
}
|
||||||
else if( fs.state == NAME_EXPECTED + INSIDE_MAP )
|
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) );
|
CV_Error_( CV_StsError, ("Incorrect element name %s", _str) );
|
||||||
fs.elname = str;
|
fs.elname = str;
|
||||||
fs.state = VALUE_EXPECTED + INSIDE_MAP;
|
fs.state = VALUE_EXPECTED + INSIDE_MAP;
|
||||||
|
@ -522,3 +522,14 @@ TEST(Core_InputOutput, FileStorage)
|
|||||||
sprintf(arr, "sprintf is hell %d", 666);
|
sprintf(arr, "sprintf is hell %d", 666);
|
||||||
EXPECT_NO_THROW(f << arr);
|
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());
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user