From 5bafc1db757ca736dd8338fb9831d41c92f0608f Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 18 Oct 2016 16:58:20 +0300 Subject: [PATCH] test: fix tolerance cv::rand result is not bitexact for floating-point numbers --- modules/core/perf/perf_merge.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/core/perf/perf_merge.cpp b/modules/core/perf/perf_merge.cpp index e7e8d2fe3f..6af7feeb41 100644 --- a/modules/core/perf/perf_merge.cpp +++ b/modules/core/perf/perf_merge.cpp @@ -22,16 +22,19 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge, int srcDepth = get<1>(GetParam()); int dstChannels = get<2>(GetParam()); + int maxValue = 255; + vector mv; for( int i = 0; i < dstChannels; ++i ) { mv.push_back( Mat(sz, CV_MAKETYPE(srcDepth, 1)) ); - randu(mv[i], 0, 255); + randu(mv[i], 0, maxValue); } Mat dst; int runs = (sz.width <= 640) ? 8 : 1; TEST_CYCLE_MULTIRUN(runs) merge( (vector &)mv, dst ); - SANITY_CHECK(dst, 1e-12); + double eps = srcDepth <= CV_32S ? 1e-12 : (FLT_EPSILON * maxValue); + SANITY_CHECK(dst, eps); }