13 Mar
2007
13 Mar
'07
2:09 p.m.
I've been having some problems using BOOST_CHECK_CLOSE() (1.33.1) in cases where one of the two arguments is exactly equal to zero: the tolerance check fails in this case (d'oh). I know that I can use BOOST_CHECK_SMALL() in those cases, but it's a real drag to have to write the boilerplate code to handle specific cases where one operand is zero. So this is what I've done: #define MY_CHECK_CLOSE(a,b,c) \ if (a == 0) { BOOST_CHECK_SMALL(b,c); } \ else if (b == 0) { BOOST_CHECK_SMALL(a,c); } \ else { BOOST_CHECK_CLOSE(a,b,c); } I wonder: did I miss something, is there a better way? If not, perhaps this logic could be integrated in the _CLOSE tools. pj