eliminated possible memory leak

(cherry picked from commit e7e63fac6c)
pull/2570/head
Ilya Lavrenov 11 years ago committed by Alexander Smorkalov
parent 5f88e2b496
commit f6367a2ea5
  1. 36
      modules/core/test/test_math.cpp

@ -2392,16 +2392,14 @@ TYPED_TEST_P(Core_CheckRange, Negative)
double min_bound = 4.5; double min_bound = 4.5;
double max_bound = 16.0; double max_bound = 16.0;
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14}; TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data); cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
cv::Point* bad_pt = new cv::Point(0, 0); cv::Point bad_pt(0, 0);
ASSERT_FALSE(checkRange(src, true, bad_pt, min_bound, max_bound)); ASSERT_FALSE(checkRange(src, true, &bad_pt, min_bound, max_bound));
ASSERT_EQ(bad_pt->x,0); ASSERT_EQ(bad_pt.x, 0);
ASSERT_EQ(bad_pt->y,1); ASSERT_EQ(bad_pt.y, 1);
delete bad_pt;
} }
TYPED_TEST_P(Core_CheckRange, Positive) TYPED_TEST_P(Core_CheckRange, Positive)
@ -2409,16 +2407,14 @@ TYPED_TEST_P(Core_CheckRange, Positive)
double min_bound = -1; double min_bound = -1;
double max_bound = 16.0; double max_bound = 16.0;
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14}; TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data); cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
cv::Point* bad_pt = new cv::Point(0, 0); cv::Point bad_pt(0, 0);
ASSERT_TRUE(checkRange(src, true, bad_pt, min_bound, max_bound));
ASSERT_EQ(bad_pt->x,0);
ASSERT_EQ(bad_pt->y,0);
delete bad_pt; ASSERT_TRUE(checkRange(src, true, &bad_pt, min_bound, max_bound));
ASSERT_EQ(bad_pt.x, 0);
ASSERT_EQ(bad_pt.y, 0);
} }
TYPED_TEST_P(Core_CheckRange, Bounds) TYPED_TEST_P(Core_CheckRange, Bounds)
@ -2426,16 +2422,14 @@ TYPED_TEST_P(Core_CheckRange, Bounds)
double min_bound = 24.5; double min_bound = 24.5;
double max_bound = 1.0; double max_bound = 1.0;
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14}; TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data); cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
cv::Point* bad_pt = new cv::Point(0, 0); cv::Point bad_pt(0, 0);
ASSERT_FALSE(checkRange(src, true, bad_pt, min_bound, max_bound));
ASSERT_EQ(bad_pt->x,0);
ASSERT_EQ(bad_pt->y,0);
delete bad_pt; ASSERT_FALSE(checkRange(src, true, &bad_pt, min_bound, max_bound));
ASSERT_EQ(bad_pt.x, 0);
ASSERT_EQ(bad_pt.y, 0);
} }
TYPED_TEST_P(Core_CheckRange, Zero) TYPED_TEST_P(Core_CheckRange, Zero)

Loading…
Cancel
Save