Skip to content

Commit f42b7d0

Browse files
committed
core: add a test of iteration through the Mat_ with range-based for
1 parent 267fdc4 commit f42b7d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

modules/core/test/test_mat.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,3 +1734,21 @@ TEST(Mat, regression_8680)
17341734
mat.release();
17351735
ASSERT_EQ(mat.channels(), 2);
17361736
}
1737+
1738+
#ifdef CV_CXX_11
1739+
1740+
TEST(Mat_, range_based_for)
1741+
{
1742+
Mat_<uchar> img = Mat_<uchar>::zeros(3, 3);
1743+
1744+
for(auto& pixel : img)
1745+
{
1746+
pixel = 1;
1747+
}
1748+
1749+
Mat_<uchar> ref(3, 3);
1750+
ref.setTo(Scalar(1));
1751+
ASSERT_DOUBLE_EQ(norm(img, ref), 0.);
1752+
}
1753+
1754+
#endif

0 commit comments

Comments
 (0)