Skip to content

Commit f30aafc

Browse files
committed
core(test): regression test for 18473
1 parent 102d8f6 commit f30aafc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

modules/core/test/test_mat.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,4 +2185,32 @@ TEST(Mat, empty_iterator_16855)
21852185
EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>());
21862186
}
21872187

2188+
2189+
TEST(Mat, regression_18473)
2190+
{
2191+
std::vector<int> sizes(3);
2192+
sizes[0] = 20;
2193+
sizes[1] = 50;
2194+
sizes[2] = 100;
2195+
#if 1 // with the fix
2196+
std::vector<size_t> steps(2);
2197+
steps[0] = 50*100*2;
2198+
steps[1] = 100*2;
2199+
#else // without the fix
2200+
std::vector<size_t> steps(3);
2201+
steps[0] = 50*100*2;
2202+
steps[1] = 100*2;
2203+
steps[2] = 2;
2204+
#endif
2205+
std::vector<short> data(20*50*100, 0); // 1Mb
2206+
data[data.size() - 1] = 5;
2207+
2208+
// param steps Array of ndims-1 steps
2209+
Mat m(sizes, CV_16SC1, (void*)data.data(), (const size_t*)steps.data());
2210+
2211+
ASSERT_FALSE(m.empty());
2212+
EXPECT_EQ((int)5, (int)m.at<short>(19, 49, 99));
2213+
}
2214+
2215+
21882216
}} // namespace

0 commit comments

Comments
 (0)