1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2023-09-28 16:42:08 +03:00
202 changed files with 14784 additions and 7242 deletions
+12
View File
@@ -1369,6 +1369,18 @@ TEST(Core_Mat, copyNx1ToVector)
ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), ref_dst16, cv::Mat_<ushort>(dst16).reshape(1, 5));
}
TEST(Core_Mat, copyMakeBoderUndefinedBehavior)
{
Mat1b src(4, 4), dst;
randu(src, Scalar(10), Scalar(100));
// This could trigger a (signed int)*size_t operation which is undefined behavior.
cv::copyMakeBorder(src, dst, 1, 1, 1, 1, cv::BORDER_REFLECT_101);
EXPECT_EQ(0, cv::norm(src.row(1), dst(Rect(1,0,4,1))));
EXPECT_EQ(0, cv::norm(src.row(2), dst(Rect(1,5,4,1))));
EXPECT_EQ(0, cv::norm(src.col(1), dst(Rect(0,1,1,4))));
EXPECT_EQ(0, cv::norm(src.col(2), dst(Rect(5,1,1,4))));
}
TEST(Core_Matx, fromMat_)
{
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
+23
View File
@@ -917,5 +917,28 @@ REGISTER_TYPED_TEST_CASE_P(Rect_Test, Overflows);
typedef ::testing::Types<int, float, double> RectTypes;
INSTANTIATE_TYPED_TEST_CASE_P(Negative_Test, Rect_Test, RectTypes);
// Expected that SkipTestException thrown in the constructor should skip test but not fail
struct TestFixtureSkip: public ::testing::Test {
TestFixtureSkip(bool throwEx = true) {
if (throwEx) {
throw SkipTestException("Skip test at constructor");
}
}
};
TEST_F(TestFixtureSkip, NoBodyRun) {
FAIL() << "Unreachable code called";
}
// Expected that SkipTestException thrown in SetUp method should skip test but not fail
struct TestSetUpSkip: public ::testing::Test {
virtual void SetUp() CV_OVERRIDE {
throw SkipTestException("Skip test at SetUp");
}
};
TEST_F(TestSetUpSkip, NoBodyRun) {
FAIL() << "Unreachable code called";
}
}} // namespace
+9
View File
@@ -1380,6 +1380,15 @@ TEST(MatTestRoi, adjustRoiOverflow)
ASSERT_EQ(roi.rows, m.rows);
}
TEST(MatTestRoi, adjustRoiUndefinedBehavior)
{
Mat m(6, 6, CV_8U);
Mat roi(m, cv::Range(2, 4), cv::Range(2, 4));
// This could trigger a (negative int)*size_t when updating data,
// which is undefined behavior.
roi.adjustROI(2, 2, 2, 2);
EXPECT_EQ(m.data, roi.data);
}
CV_ENUM(SortRowCol, SORT_EVERY_COLUMN, SORT_EVERY_ROW)
CV_ENUM(SortOrder, SORT_ASCENDING, SORT_DESCENDING)