core(test): regression test for 18473

pull/18515/head
Alexander Alekhin 4 years ago
parent 102d8f67cd
commit f30aafc3cc
  1. 28
      modules/core/test/test_mat.cpp

@ -2185,4 +2185,32 @@ TEST(Mat, empty_iterator_16855)
EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>()); EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>());
} }
TEST(Mat, regression_18473)
{
std::vector<int> sizes(3);
sizes[0] = 20;
sizes[1] = 50;
sizes[2] = 100;
#if 1 // with the fix
std::vector<size_t> steps(2);
steps[0] = 50*100*2;
steps[1] = 100*2;
#else // without the fix
std::vector<size_t> steps(3);
steps[0] = 50*100*2;
steps[1] = 100*2;
steps[2] = 2;
#endif
std::vector<short> 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<short>(19, 49, 99));
}
}} // namespace }} // namespace

Loading…
Cancel
Save