From e7e63fac6c3eaa65a8eb0926c7c9557f0614ab03 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 30 Jan 2014 01:14:02 +0400 Subject: [PATCH] eliminated possible memory leak --- modules/core/test/test_math.cpp | 36 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index 3847afce6e..a572cd0d92 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -2392,16 +2392,14 @@ TYPED_TEST_P(Core_CheckRange, Negative) double min_bound = 4.5; 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::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,1); - - 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, 1); } TYPED_TEST_P(Core_CheckRange, Positive) @@ -2409,16 +2407,14 @@ TYPED_TEST_P(Core_CheckRange, Positive) double min_bound = -1; 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::value, data); - cv::Point* bad_pt = new cv::Point(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); + cv::Point bad_pt(0, 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) @@ -2426,16 +2422,14 @@ TYPED_TEST_P(Core_CheckRange, Bounds) double min_bound = 24.5; 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::value, data); - cv::Point* bad_pt = new cv::Point(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); + cv::Point bad_pt(0, 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)