Final set of fixes for floating matchers approvals

This commit is contained in:
Martin Hořeňovský 2017-11-10 21:43:23 +01:00
parent a0dbc62955
commit 8dbaac61ff
5 changed files with 70 additions and 62 deletions

View File

@ -6,8 +6,9 @@
*/ */
#include "catch_matchers_floating.h" #include "catch_matchers_floating.h"
#include "catch_tostring.h"
#include <cmath> #include <cstdlib>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <stdexcept> #include <stdexcept>
@ -87,7 +88,7 @@ namespace Floating {
} }
std::string WithinAbsMatcher::describe() const { std::string WithinAbsMatcher::describe() const {
return "is within " + std::to_string(m_margin) + " of " + std::to_string(m_target); return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target);
} }
@ -110,7 +111,7 @@ namespace Floating {
} }
std::string WithinUlpsMatcher::describe() const { std::string WithinUlpsMatcher::describe() const {
return "is within " + std::to_string(m_ulps) + " ULPs of " + std::to_string(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); return "is within " + std::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : "");
} }
}// namespace Floating }// namespace Floating

View File

@ -17,6 +17,7 @@
#include "catch_interfaces_config.h" #include "catch_interfaces_config.h"
#include "catch_context.h" #include "catch_context.h"
#include <cmath>
#include <iomanip> #include <iomanip>
namespace Catch { namespace Catch {
@ -63,6 +64,10 @@ namespace Detail {
template<typename T> template<typename T>
std::string fpToString( T value, int precision ) { std::string fpToString( T value, int precision ) {
if (std::isnan(value)) {
return "nan";
}
ReusableStringStream rss; ReusableStringStream rss;
rss << std::setprecision( precision ) rss << std::setprecision( precision )
<< std::fixed << std::fixed

View File

@ -1740,31 +1740,31 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1., WithinAbs(1., 0) ) REQUIRE_THAT( 1., WithinAbs(1., 0) )
with expansion: with expansion:
1.0 is within 0.000000 of 1.000000 1.0 is within 0.0 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0., WithinAbs(1., 1) ) REQUIRE_THAT( 0., WithinAbs(1., 1) )
with expansion: with expansion:
0.0 is within 1.000000 of 1.000000 0.0 is within 1.0 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0., !WithinAbs(1., 0.99) ) REQUIRE_THAT( 0., !WithinAbs(1., 0.99) )
with expansion: with expansion:
0.0 not is within 0.990000 of 1.000000 0.0 not is within 0.99 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0., !WithinAbs(1., 0.99) ) REQUIRE_THAT( 0., !WithinAbs(1., 0.99) )
with expansion: with expansion:
0.0 not is within 0.990000 of 1.000000 0.0 not is within 0.99 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) ) REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) )
with expansion: with expansion:
nanf not is within 0.000000 of nan nanf not is within 0.0 of nan
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Floating point matchers: double Floating point matchers: double
@ -1777,37 +1777,37 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1., WithinULP(1., 0) ) REQUIRE_THAT( 1., WithinULP(1., 0) )
with expansion: with expansion:
1.0 is within 0 ULPs of 1.000000 1.0 is within 0 ULPs of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1., 2.), WithinULP(1., 1) ) REQUIRE_THAT( std::nextafter(1., 2.), WithinULP(1., 1) )
with expansion: with expansion:
1.0 is within 1 ULPs of 1.000000 1.0 is within 1 ULPs of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1., 0.), WithinULP(1., 1) ) REQUIRE_THAT( std::nextafter(1., 0.), WithinULP(1., 1) )
with expansion: with expansion:
1.0 is within 1 ULPs of 1.000000 1.0 is within 1 ULPs of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1., 2.), !WithinULP(1., 0) ) REQUIRE_THAT( std::nextafter(1., 2.), !WithinULP(1., 0) )
with expansion: with expansion:
1.0 not is within 0 ULPs of 1.000000 1.0 not is within 0 ULPs of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1., WithinULP(1., 0) ) REQUIRE_THAT( 1., WithinULP(1., 0) )
with expansion: with expansion:
1.0 is within 0 ULPs of 1.000000 1.0 is within 0 ULPs of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( -0., WithinULP(0., 0) ) REQUIRE_THAT( -0., WithinULP(0., 0) )
with expansion: with expansion:
-0.0 is within 0 ULPs of 0.000000 -0.0 is within 0 ULPs of 0.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
@ -1826,19 +1826,19 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1., WithinAbs(1., 0.5) || WithinULP(2., 1) ) REQUIRE_THAT( 1., WithinAbs(1., 0.5) || WithinULP(2., 1) )
with expansion: with expansion:
1.0 ( is within 0.500000 of 1.000000 or is within 1 ULPs of 2.000000 ) 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 )
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1., WithinAbs(2., 0.5) || WithinULP(1., 0) ) REQUIRE_THAT( 1., WithinAbs(2., 0.5) || WithinULP(1., 0) )
with expansion: with expansion:
1.0 ( is within 0.500000 of 2.000000 or is within 0 ULPs of 1.000000 ) 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 )
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) ) REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) )
with expansion: with expansion:
nanf not ( is within 100.000000 of nan or is within 123 ULPs of nanf ) nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Floating point matchers: float Floating point matchers: float
@ -1851,37 +1851,37 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1.f, WithinAbs(1.f, 0) ) REQUIRE_THAT( 1.f, WithinAbs(1.f, 0) )
with expansion: with expansion:
1.0f is within 0.000000 of 1.000000 1.0f is within 0.0 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0.f, WithinAbs(1.f, 1) ) REQUIRE_THAT( 0.f, WithinAbs(1.f, 1) )
with expansion: with expansion:
0.0f is within 1.000000 of 1.000000 0.0f is within 1.0 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) ) REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) )
with expansion: with expansion:
0.0f not is within 0.990000 of 1.000000 0.0f not is within 0.9900000095 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) ) REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) )
with expansion: with expansion:
0.0f not is within 0.990000 of 1.000000 0.0f not is within 0.9900000095 of 1.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 0.f, WithinAbs(-0.f, 0) ) REQUIRE_THAT( 0.f, WithinAbs(-0.f, 0) )
with expansion: with expansion:
0.0f is within 0.000000 of -0.000000 0.0f is within 0.0 of -0.0
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) ) REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) )
with expansion: with expansion:
nanf not is within 0.000000 of nan nanf not is within 0.0 of nan
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Floating point matchers: float Floating point matchers: float
@ -1894,37 +1894,37 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1.f, WithinULP(1.f, 0) ) REQUIRE_THAT( 1.f, WithinULP(1.f, 0) )
with expansion: with expansion:
1.0f is within 0 ULPs of 1.000000f 1.0f is within 0 ULPs of 1.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1.f, 2.f), WithinULP(1.f, 1) ) REQUIRE_THAT( std::nextafter(1.f, 2.f), WithinULP(1.f, 1) )
with expansion: with expansion:
1.0f is within 1 ULPs of 1.000000f 1.0f is within 1 ULPs of 1.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1.f, 0.f), WithinULP(1.f, 1) ) REQUIRE_THAT( std::nextafter(1.f, 0.f), WithinULP(1.f, 1) )
with expansion: with expansion:
1.0f is within 1 ULPs of 1.000000f 1.0f is within 1 ULPs of 1.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( std::nextafter(1.f, 2.f), !WithinULP(1.f, 0) ) REQUIRE_THAT( std::nextafter(1.f, 2.f), !WithinULP(1.f, 0) )
with expansion: with expansion:
1.0f not is within 0 ULPs of 1.000000f 1.0f not is within 0 ULPs of 1.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1.f, WithinULP(1.f, 0) ) REQUIRE_THAT( 1.f, WithinULP(1.f, 0) )
with expansion: with expansion:
1.0f is within 0 ULPs of 1.000000f 1.0f is within 0 ULPs of 1.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( -0.f, WithinULP(0.f, 0) ) REQUIRE_THAT( -0.f, WithinULP(0.f, 0) )
with expansion: with expansion:
-0.0f is within 0 ULPs of 0.000000f -0.0f is within 0 ULPs of 0.0f
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
@ -1943,19 +1943,19 @@ MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) ) REQUIRE_THAT( 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) )
with expansion: with expansion:
1.0f ( is within 0.500000 of 1.000000 or is within 1 ULPs of 1.000000f ) 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f )
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) ) REQUIRE_THAT( 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) )
with expansion: with expansion:
1.0f ( is within 0.500000 of 2.000000 or is within 0 ULPs of 1.000000f ) 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f )
MatchersTests.cpp:<line number>: MatchersTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) ) REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) )
with expansion: with expansion:
nanf not ( is within 100.000000 of nan or is within 123 ULPs of nanf ) nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Greater-than inequalities with different epsilons Greater-than inequalities with different epsilons

View File

@ -1968,7 +1968,7 @@
1., WithinAbs(1., 0) 1., WithinAbs(1., 0)
</Original> </Original>
<Expanded> <Expanded>
1.0 is within 0.000000 of 1.000000 1.0 is within 0.0 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -1976,7 +1976,7 @@
0., WithinAbs(1., 1) 0., WithinAbs(1., 1)
</Original> </Original>
<Expanded> <Expanded>
0.0 is within 1.000000 of 1.000000 0.0 is within 1.0 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -1984,7 +1984,7 @@
0., !WithinAbs(1., 0.99) 0., !WithinAbs(1., 0.99)
</Original> </Original>
<Expanded> <Expanded>
0.0 not is within 0.990000 of 1.000000 0.0 not is within 0.99 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -1992,7 +1992,7 @@
0., !WithinAbs(1., 0.99) 0., !WithinAbs(1., 0.99)
</Original> </Original>
<Expanded> <Expanded>
0.0 not is within 0.990000 of 1.000000 0.0 not is within 0.99 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2000,7 +2000,7 @@
NAN, !WithinAbs(NAN, 0) NAN, !WithinAbs(NAN, 0)
</Original> </Original>
<Expanded> <Expanded>
nanf not is within 0.000000 of nan nanf not is within 0.0 of nan
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="5" failures="0" expectedFailures="0"/> <OverallResults successes="5" failures="0" expectedFailures="0"/>
@ -2011,7 +2011,7 @@
1., WithinULP(1., 0) 1., WithinULP(1., 0)
</Original> </Original>
<Expanded> <Expanded>
1.0 is within 0 ULPs of 1.000000 1.0 is within 0 ULPs of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2019,7 +2019,7 @@
std::nextafter(1., 2.), WithinULP(1., 1) std::nextafter(1., 2.), WithinULP(1., 1)
</Original> </Original>
<Expanded> <Expanded>
1.0 is within 1 ULPs of 1.000000 1.0 is within 1 ULPs of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2027,7 +2027,7 @@
std::nextafter(1., 0.), WithinULP(1., 1) std::nextafter(1., 0.), WithinULP(1., 1)
</Original> </Original>
<Expanded> <Expanded>
1.0 is within 1 ULPs of 1.000000 1.0 is within 1 ULPs of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2035,7 +2035,7 @@
std::nextafter(1., 2.), !WithinULP(1., 0) std::nextafter(1., 2.), !WithinULP(1., 0)
</Original> </Original>
<Expanded> <Expanded>
1.0 not is within 0 ULPs of 1.000000 1.0 not is within 0 ULPs of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2043,7 +2043,7 @@
1., WithinULP(1., 0) 1., WithinULP(1., 0)
</Original> </Original>
<Expanded> <Expanded>
1.0 is within 0 ULPs of 1.000000 1.0 is within 0 ULPs of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2051,7 +2051,7 @@
-0., WithinULP(0., 0) -0., WithinULP(0., 0)
</Original> </Original>
<Expanded> <Expanded>
-0.0 is within 0 ULPs of 0.000000 -0.0 is within 0 ULPs of 0.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2070,7 +2070,7 @@
1., WithinAbs(1., 0.5) || WithinULP(2., 1) 1., WithinAbs(1., 0.5) || WithinULP(2., 1)
</Original> </Original>
<Expanded> <Expanded>
1.0 ( is within 0.500000 of 1.000000 or is within 1 ULPs of 2.000000 ) 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 )
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2078,7 +2078,7 @@
1., WithinAbs(2., 0.5) || WithinULP(1., 0) 1., WithinAbs(2., 0.5) || WithinULP(1., 0)
</Original> </Original>
<Expanded> <Expanded>
1.0 ( is within 0.500000 of 2.000000 or is within 0 ULPs of 1.000000 ) 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 )
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2086,7 +2086,7 @@
NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))
</Original> </Original>
<Expanded> <Expanded>
nanf not ( is within 100.000000 of nan or is within 123 ULPs of nanf ) nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/> <OverallResults successes="3" failures="0" expectedFailures="0"/>
@ -2100,7 +2100,7 @@
1.f, WithinAbs(1.f, 0) 1.f, WithinAbs(1.f, 0)
</Original> </Original>
<Expanded> <Expanded>
1.0f is within 0.000000 of 1.000000 1.0f is within 0.0 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2108,7 +2108,7 @@
0.f, WithinAbs(1.f, 1) 0.f, WithinAbs(1.f, 1)
</Original> </Original>
<Expanded> <Expanded>
0.0f is within 1.000000 of 1.000000 0.0f is within 1.0 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2116,7 +2116,7 @@
0.f, !WithinAbs(1.f, 0.99f) 0.f, !WithinAbs(1.f, 0.99f)
</Original> </Original>
<Expanded> <Expanded>
0.0f not is within 0.990000 of 1.000000 0.0f not is within 0.9900000095 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2124,7 +2124,7 @@
0.f, !WithinAbs(1.f, 0.99f) 0.f, !WithinAbs(1.f, 0.99f)
</Original> </Original>
<Expanded> <Expanded>
0.0f not is within 0.990000 of 1.000000 0.0f not is within 0.9900000095 of 1.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2132,7 +2132,7 @@
0.f, WithinAbs(-0.f, 0) 0.f, WithinAbs(-0.f, 0)
</Original> </Original>
<Expanded> <Expanded>
0.0f is within 0.000000 of -0.000000 0.0f is within 0.0 of -0.0
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2140,7 +2140,7 @@
NAN, !WithinAbs(NAN, 0) NAN, !WithinAbs(NAN, 0)
</Original> </Original>
<Expanded> <Expanded>
nanf not is within 0.000000 of nan nanf not is within 0.0 of nan
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="6" failures="0" expectedFailures="0"/> <OverallResults successes="6" failures="0" expectedFailures="0"/>
@ -2151,7 +2151,7 @@
1.f, WithinULP(1.f, 0) 1.f, WithinULP(1.f, 0)
</Original> </Original>
<Expanded> <Expanded>
1.0f is within 0 ULPs of 1.000000f 1.0f is within 0 ULPs of 1.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2159,7 +2159,7 @@
std::nextafter(1.f, 2.f), WithinULP(1.f, 1) std::nextafter(1.f, 2.f), WithinULP(1.f, 1)
</Original> </Original>
<Expanded> <Expanded>
1.0f is within 1 ULPs of 1.000000f 1.0f is within 1 ULPs of 1.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2167,7 +2167,7 @@
std::nextafter(1.f, 0.f), WithinULP(1.f, 1) std::nextafter(1.f, 0.f), WithinULP(1.f, 1)
</Original> </Original>
<Expanded> <Expanded>
1.0f is within 1 ULPs of 1.000000f 1.0f is within 1 ULPs of 1.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2175,7 +2175,7 @@
std::nextafter(1.f, 2.f), !WithinULP(1.f, 0) std::nextafter(1.f, 2.f), !WithinULP(1.f, 0)
</Original> </Original>
<Expanded> <Expanded>
1.0f not is within 0 ULPs of 1.000000f 1.0f not is within 0 ULPs of 1.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2183,7 +2183,7 @@
1.f, WithinULP(1.f, 0) 1.f, WithinULP(1.f, 0)
</Original> </Original>
<Expanded> <Expanded>
1.0f is within 0 ULPs of 1.000000f 1.0f is within 0 ULPs of 1.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2191,7 +2191,7 @@
-0.f, WithinULP(0.f, 0) -0.f, WithinULP(0.f, 0)
</Original> </Original>
<Expanded> <Expanded>
-0.0f is within 0 ULPs of 0.000000f -0.0f is within 0 ULPs of 0.0f
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2210,7 +2210,7 @@
1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1)
</Original> </Original>
<Expanded> <Expanded>
1.0f ( is within 0.500000 of 1.000000 or is within 1 ULPs of 1.000000f ) 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f )
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2218,7 +2218,7 @@
1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0)
</Original> </Original>
<Expanded> <Expanded>
1.0f ( is within 0.500000 of 2.000000 or is within 0 ULPs of 1.000000f ) 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f )
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
@ -2226,7 +2226,7 @@
NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))
</Original> </Original>
<Expanded> <Expanded>
nanf not ( is within 100.000000 of nan or is within 123 ULPs of nanf ) nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/> <OverallResults successes="3" failures="0" expectedFailures="0"/>

View File

@ -57,7 +57,9 @@ nanParser = re.compile(r'''
| |
\(\(float\)\(INFINITY\ \*\ 0\.0F\)\) # Yet another MSVC NAN macro \(\(float\)\(INFINITY\ \*\ 0\.0F\)\) # Yet another MSVC NAN macro
| |
\(__builtin_nanf\ \(""\)\) # Linux (ubuntu) NAN macro \(__builtin_nanf\ \(""\)\) # Linux (ubuntu) NAN macro
|
__builtin_nanf\("0x<hex\ digits>"\) # The weird content of the brackets is there because a different parser has already ran before this one
''', re.VERBOSE) ''', re.VERBOSE)