From dccfd79da83057c3cfda29e6664ef374697f2041 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 10 Apr 2012 08:22:33 +0000 Subject: [PATCH] #1783: test and fix for the bug --- modules/core/src/mathfuncs.cpp | 2 +- modules/core/test/test_math.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index b9e09faaf0..4e25eed5e4 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -2051,7 +2051,7 @@ bool chackIntegerRang(cv::Mat src, Point& bad_pt, int minVal, int maxVal, double for (int j = 0; j < as_one_channel.rows; ++j) for (int i = 0; i < as_one_channel.cols; ++i) { - if (as_one_channel.at(j ,i) <= minVal || as_one_channel.at(j ,i) >= maxVal) + if (as_one_channel.at(j ,i) < minVal || as_one_channel.at(j ,i) >= maxVal) { bad_pt.y = j ; bad_pt.x = i % src.channels(); diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index 35afafc373..1c4293b804 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -2402,7 +2402,17 @@ TYPED_TEST_P(Core_CheckRange, Bounds) delete bad_pt; } -REGISTER_TYPED_TEST_CASE_P(Core_CheckRange, Negative, Positive, Bounds); +TYPED_TEST_P(Core_CheckRange, Zero) +{ + double min_bound = 0.0; + double max_bound = 0.1; + + cv::Mat src = cv::Mat::zeros(3,3, cv::DataDepth::value); + + ASSERT_TRUE( checkRange(src, true, NULL, min_bound, max_bound) ); +} + +REGISTER_TYPED_TEST_CASE_P(Core_CheckRange, Negative, Positive, Bounds, Zero); typedef ::testing::Types mat_data_types; INSTANTIATE_TYPED_TEST_CASE_P(Negative_Test, Core_CheckRange, mat_data_types);