ATLAS Offline Software
AtlasTest
TestTools
TestTools
FLOATassert.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
#ifndef TESTTOOLS_FLOATASSERT_H
7
#define TESTTOOLS_FLOATASSERT_H
8
9
#include <iostream>
10
#include <cassert>
11
#include <cfloat>
12
#include <cmath>
13
14
15
namespace
Athena_test
{
16
inline
17
bool
floatEQ
(
float
lhs,
float
rhs) {
18
return
fabs(lhs-rhs)<=FLT_EPSILON;
19
}
20
inline
21
bool
floatNEQ
(
float
lhs,
float
rhs) {
22
return
fabs(lhs-rhs)>FLT_EPSILON;
23
}
24
25
inline
26
bool
isEqual
(
double
x1
,
double
x2
,
double
thresh
= 1
e
-6)
27
{
28
double
den = std::abs(
x1
+
x2
);
29
if
(den <
thresh
)
return
true
;
30
double
diff
= std::abs (
x1
-
x2
) / den;
31
if
(
diff
<
thresh
)
32
return
true
;
33
std::cout <<
"Match failure: "
<<
x1
<<
" "
<<
x2
<<
" ("
<<
diff
<<
")\n"
;
34
return
false
;
35
}
36
37
}
38
39
#define FLOAT_NEQassert( LHS, RHS ) assert(Athena_test::floatNEQ(LHS, RHS));
40
#define FLOAT_EQassert( LHS, RHS ) assert(Athena_test::floatEQ(LHS, RHS));
41
42
#endif
AllowedVariables::e
e
Definition:
AsgElectronSelectorTool.cxx:37
plotBeamSpotCompare.x1
x1
Definition:
plotBeamSpotCompare.py:216
Athena_test::floatEQ
bool floatEQ(float lhs, float rhs)
Definition:
FLOATassert.h:17
physval_make_web_display.thresh
thresh
Definition:
physval_make_web_display.py:36
plotBeamSpotCompare.x2
x2
Definition:
plotBeamSpotCompare.py:218
mc.diff
diff
Definition:
mc.SFGenPy8_MuMu_DD.py:14
Athena_test::isEqual
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition:
FLOATassert.h:26
Athena_test
functions & macros to test the difference between floats
Definition:
InitGaudiGoogleTest.h:31
Athena_test::floatNEQ
bool floatNEQ(float lhs, float rhs)
Definition:
FLOATassert.h:21
Generated on Sun Dec 22 2024 21:10:33 for ATLAS Offline Software by
1.8.18