From 76ac7ab4efeba0c55ad33fdffbd64fc1b9be44d5 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 22 May 2018 13:55:14 +0300 Subject: [PATCH] imgcodecs: added test for imwrite parameter types issue 11545 --- modules/imgcodecs/test/test_grfmt.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp index 88f8501d89..9bcb23205e 100644 --- a/modules/imgcodecs/test/test_grfmt.cpp +++ b/modules/imgcodecs/test/test_grfmt.cpp @@ -327,4 +327,18 @@ TEST(Imgcodecs_Pam, read_write) remove(writefile_no_param.c_str()); } +TEST(Imgcodecs, write_parameter_type) +{ + cv::Mat m(10, 10, CV_8UC1, cv::Scalar::all(0)); + cv::Mat1b m_type = cv::Mat1b::zeros(10, 10); + string tmp_file = cv::tempfile(".bmp"); + EXPECT_NO_THROW(cv::imwrite(tmp_file, cv::Mat(m * 2))) << "* Failed with cv::Mat"; + EXPECT_NO_THROW(cv::imwrite(tmp_file, m * 2)) << "* Failed with cv::MatExpr"; + EXPECT_NO_THROW(cv::imwrite(tmp_file, m_type)) << "* Failed with cv::Mat_"; + EXPECT_NO_THROW(cv::imwrite(tmp_file, m_type * 2)) << "* Failed with cv::MatExpr(Mat_)"; + cv::Matx matx; + EXPECT_NO_THROW(cv::imwrite(tmp_file, matx)) << "* Failed with cv::Matx"; + EXPECT_EQ(0, remove(tmp_file.c_str())); +} + }} // namespace