From 09cb329d737ae34ab00a0c182aef8061b3d338af Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 14 Oct 2018 01:28:54 +0000 Subject: [PATCH] core(test): zero values divide test (4.0+) --- modules/core/test/test_arithm.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 96d5f42..b9a7d78 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -2286,6 +2286,7 @@ template static inline void testDivideChecks(const Mat& dst) { ASSERT_FALSE(dst.empty()); + CV_StaticAssert(std::numeric_limits::is_integer, ""); for (int y = 0; y < dst.rows; y++) { for (int x = 0; x < dst.cols; x++) @@ -2298,6 +2299,35 @@ void testDivideChecks(const Mat& dst) } } +template static inline +void testDivideChecksFP(const Mat& dst) +{ + ASSERT_FALSE(dst.empty()); + CV_StaticAssert(!std::numeric_limits::is_integer, ""); + for (int y = 0; y < dst.rows; y++) + { + for (int x = 0; x < dst.cols; x++) + { + if (y == 0 && x == 2) + { + EXPECT_TRUE(cvIsNaN(dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + } + else if (x == 2) + { + EXPECT_TRUE(cvIsInf(dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + } + else + { + EXPECT_FALSE(cvIsNaN(dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + EXPECT_FALSE(cvIsInf(dst.at(y, x))) << "dst(" << y << ", " << x << ") = " << dst.at(y, x); + } + } + } +} + +template <> inline void testDivideChecks(const Mat& dst) { testDivideChecksFP(dst); } +template <> inline void testDivideChecks(const Mat& dst) { testDivideChecksFP(dst); } + template static inline void testDivide() -- 2.7.4