From f42b7d03b477bd21a39d0ddfbe6fd73659f1b0df Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Mon, 3 Jul 2017 12:42:47 +0300 Subject: [PATCH] core: add a test of iteration through the Mat_ with range-based for --- modules/core/test/test_mat.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 9ec196ba66..1739503314 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -1734,3 +1734,21 @@ TEST(Mat, regression_8680) mat.release(); ASSERT_EQ(mat.channels(), 2); } + +#ifdef CV_CXX_11 + +TEST(Mat_, range_based_for) +{ + Mat_ img = Mat_::zeros(3, 3); + + for(auto& pixel : img) + { + pixel = 1; + } + + Mat_ ref(3, 3); + ref.setTo(Scalar(1)); + ASSERT_DOUBLE_EQ(norm(img, ref), 0.); +} + +#endif