From f30aafc3cc77e87898dbbb9013f9de7ca32a73b4 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 4 Oct 2020 07:11:41 +0000 Subject: [PATCH] core(test): regression test for 18473 --- modules/core/test/test_mat.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 43e0078ec8..0bc3961fe2 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -2185,4 +2185,32 @@ TEST(Mat, empty_iterator_16855) EXPECT_TRUE(m.begin() == m.end()); } + +TEST(Mat, regression_18473) +{ + std::vector sizes(3); + sizes[0] = 20; + sizes[1] = 50; + sizes[2] = 100; +#if 1 // with the fix + std::vector steps(2); + steps[0] = 50*100*2; + steps[1] = 100*2; +#else // without the fix + std::vector steps(3); + steps[0] = 50*100*2; + steps[1] = 100*2; + steps[2] = 2; +#endif + std::vector data(20*50*100, 0); // 1Mb + data[data.size() - 1] = 5; + + // param steps Array of ndims-1 steps + Mat m(sizes, CV_16SC1, (void*)data.data(), (const size_t*)steps.data()); + + ASSERT_FALSE(m.empty()); + EXPECT_EQ((int)5, (int)m.at(19, 49, 99)); +} + + }} // namespace