[opencv] 130/251: test: FileStorage format regression test
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:34 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 5bc291937fbe00ec07c5182fcddbb55b2fa4193d
Author: Alexander Alekhin <alexander.alekhin at intel.com>
Date: Thu Jul 20 19:56:47 2017 +0300
test: FileStorage format regression test
---
modules/core/include/opencv2/core/persistence.hpp | 5 ++
modules/core/src/persistence.cpp | 6 +++
modules/core/test/test_io.cpp | 56 +++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/modules/core/include/opencv2/core/persistence.hpp b/modules/core/include/opencv2/core/persistence.hpp
index 8d48759..cf09891 100644
--- a/modules/core/include/opencv2/core/persistence.hpp
+++ b/modules/core/include/opencv2/core/persistence.hpp
@@ -462,6 +462,11 @@ public:
*/
static String getDefaultObjectName(const String& filename);
+ /** @brief Returns the current format.
+ * @returns The current format, see FileStorage::Mode
+ */
+ CV_WRAP int getFormat() const;
+
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
String elname; //!< the currently written element
std::vector<char> structs; //!< the stack of written structures
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index bb4d953..ef655e0 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -6920,6 +6920,12 @@ FileNode FileStorage::root(int streamidx) const
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
}
+int FileStorage::getFormat() const
+{
+ CV_Assert(!fs.empty());
+ return fs->fmt & FORMAT_MASK;
+}
+
FileStorage& operator << (FileStorage& fs, const String& str)
{
CV_TRACE_REGION_VERBOSE();
diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp
index 253d2a6..939e80d 100644
--- a/modules/core/test/test_io.cpp
+++ b/modules/core/test/test_io.cpp
@@ -1236,3 +1236,59 @@ TEST(Core_InputOutput, FileStorage_DMatch_vector_vector)
}
}
}
+
+TEST(Core_InputOutput, FileStorage_format_xml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.xml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_XML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_xml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.xml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_XML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_json)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.json", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_JSON, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_json_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.json.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_JSON, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yaml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yaml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yaml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yaml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
--
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