diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 0eb2318c76..78ad907603 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -2249,33 +2249,53 @@ void testDivideChecks(const Mat& dst) { for (int x = 0; x < dst.cols; x++) { - if (x == 2) + if ((x % 4) == 2) { EXPECT_EQ(0, dst.at(y, x)) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); } + else + { + EXPECT_TRUE(0 == cvIsNaN((double)dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + EXPECT_TRUE(0 == cvIsInf((double)dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + } } } } - -template static inline -void testDivide() +template static inline +void testDivide(bool isUMat, double scale, bool largeSize, bool tailProcessing, bool roi) { Mat src1, src2; testDivideInitData(src1, src2); ASSERT_FALSE(src1.empty()); ASSERT_FALSE(src2.empty()); + if (largeSize) + { + repeat(src1.clone(), 1, 8, src1); + repeat(src2.clone(), 1, 8, src2); + } + if (tailProcessing) + { + src1 = src1(Rect(0, 0, src1.cols - 1, src1.rows)); + src2 = src2(Rect(0, 0, src2.cols - 1, src2.rows)); + } + if (!roi && tailProcessing) + { + src1 = src1.clone(); + src2 = src2.clone(); + } + Mat dst; if (!isUMat) { - cv::divide(src1, src2, dst); + cv::divide(src1, src2, dst, scale); } else { UMat usrc1, usrc2, udst; src1.copyTo(usrc1); src2.copyTo(usrc2); - cv::divide(usrc1, usrc2, udst); + cv::divide(usrc1, usrc2, udst, scale); udst.copyTo(dst); } @@ -2289,14 +2309,46 @@ void testDivide() } } -TEST(Core_DivideRules, type_32s) { testDivide(); } -TEST(UMat_Core_DivideRules, type_32s) { testDivide(); } -TEST(Core_DivideRules, type_16s) { testDivide(); } -TEST(UMat_Core_DivideRules, type_16s) { testDivide(); } -TEST(Core_DivideRules, type_32f) { testDivide(); } -TEST(UMat_Core_DivideRules, type_32f) { testDivide(); } -TEST(Core_DivideRules, type_64f) { testDivide(); } -TEST(UMat_Core_DivideRules, type_64f) { testDivide(); } +typedef tuple DivideRulesParam; +typedef testing::TestWithParam Core_DivideRules; + +TEST_P(Core_DivideRules, type_32s) +{ + DivideRulesParam param = GetParam(); + testDivide(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param)); +} +TEST_P(Core_DivideRules, type_16s) +{ + DivideRulesParam param = GetParam(); + testDivide(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param)); +} +TEST_P(Core_DivideRules, type_32f) +{ + DivideRulesParam param = GetParam(); + testDivide(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param)); +} +TEST_P(Core_DivideRules, type_64f) +{ + DivideRulesParam param = GetParam(); + testDivide(get<0>(param), get<1>(param), get<2>(param), get<3>(param), get<4>(param)); +} + + +INSTANTIATE_TEST_CASE_P(/* */, Core_DivideRules, testing::Combine( +/* isMat */ testing::Values(false), +/* scale */ testing::Values(1.0, 5.0), +/* largeSize */ testing::Bool(), +/* tail */ testing::Bool(), +/* roi */ testing::Bool() +)); + +INSTANTIATE_TEST_CASE_P(UMat, Core_DivideRules, testing::Combine( +/* isMat */ testing::Values(true), +/* scale */ testing::Values(1.0, 5.0), +/* largeSize */ testing::Bool(), +/* tail */ testing::Bool(), +/* roi */ testing::Bool() +)); TEST(Core_MinMaxIdx, rows_overflow)