mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #26052 from savuor:rv/rounding_lock
Fix rounding mode for test
This commit is contained in:
commit
7e3b69e02b
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
#include "opencv2/ts/ocl_test.hpp" // T-API like tests
|
#include "opencv2/ts/ocl_test.hpp" // T-API like tests
|
||||||
|
#include <fenv.h>
|
||||||
|
|
||||||
namespace opencv_test {
|
namespace opencv_test {
|
||||||
namespace {
|
namespace {
|
||||||
@ -1596,9 +1597,12 @@ TEST_P(Core_Arith_Regression24163, test_for_ties_to_even)
|
|||||||
const Mat src2(matSize, matType, Scalar(beta, beta, beta, beta));
|
const Mat src2(matSize, matType, Scalar(beta, beta, beta, beta));
|
||||||
const Mat result = ( src1 + src2 ) / 2;
|
const Mat result = ( src1 + src2 ) / 2;
|
||||||
|
|
||||||
// Expected that default is FE_TONEAREST(Ties to Even).
|
const int rounding = fegetround();
|
||||||
|
fesetround(FE_TONEAREST);
|
||||||
const int mean = lrint( static_cast<double>(alpha + beta) / 2.0 );
|
const int mean = lrint( static_cast<double>(alpha + beta) / 2.0 );
|
||||||
const Mat expected(matSize, matType, Scalar(mean,mean,mean,mean));
|
fesetround(rounding);
|
||||||
|
|
||||||
|
const Mat expected(matSize, matType, Scalar::all(mean));
|
||||||
|
|
||||||
// Compare result and extected.
|
// Compare result and extected.
|
||||||
ASSERT_EQ(expected.size(), result.size());
|
ASSERT_EQ(expected.size(), result.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user