mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
parent
1967feac49
commit
7142d5a8c9
@ -14,6 +14,9 @@
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
@ -74,8 +77,16 @@ bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
|
||||
return ulpDiff <= maxUlpDiff;
|
||||
}
|
||||
|
||||
template <typename FP>
|
||||
FP step(FP start, FP direction, int steps) {
|
||||
for (int i = 0; i < steps; ++i) {
|
||||
start = std::nextafter(start, direction);
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
@ -125,7 +136,29 @@ namespace Floating {
|
||||
#endif
|
||||
|
||||
std::string WithinUlpsMatcher::describe() const {
|
||||
return "is within " + Catch::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : "");
|
||||
std::stringstream ret;
|
||||
|
||||
ret << "is within " << m_ulps << " ULPs of " << ::Catch::Detail::stringify(m_target);
|
||||
|
||||
if (m_type == FloatingPointKind::Float) {
|
||||
ret << 'f';
|
||||
}
|
||||
|
||||
ret << " ([";
|
||||
ret << std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10);
|
||||
if (m_type == FloatingPointKind::Double) {
|
||||
ret << step(m_target, static_cast<double>(-INFINITY), m_ulps)
|
||||
<< ", "
|
||||
<< step(m_target, static_cast<double>(INFINITY), m_ulps);
|
||||
} else {
|
||||
ret << step<float>(static_cast<float>(m_target), -INFINITY, m_ulps)
|
||||
<< ", "
|
||||
<< step<float>(static_cast<float>(m_target), INFINITY, m_ulps);
|
||||
}
|
||||
ret << "])";
|
||||
|
||||
return ret.str();
|
||||
//return "is within " + Catch::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : "");
|
||||
}
|
||||
|
||||
}// namespace Floating
|
||||
|
@ -396,21 +396,18 @@ Matchers.tests.cpp:<line number>: passed: 1., WithinAbs(1., 0) for: 1.0 is withi
|
||||
Matchers.tests.cpp:<line number>: passed: 0., WithinAbs(1., 1) for: 0.0 is within 1.0 of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not is within 0.99 of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not is within 0.99 of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan
|
||||
Matchers.tests.cpp:<line number>: passed: 11., !WithinAbs(10., 0.5) for: 11.0 not is within 0.5 of 10.0
|
||||
Matchers.tests.cpp:<line number>: passed: 10., !WithinAbs(11., 0.5) for: 10.0 not is within 0.5 of 11.0
|
||||
Matchers.tests.cpp:<line number>: passed: -10., WithinAbs(-10., 0.5) for: -10.0 is within 0.5 of -10.0
|
||||
Matchers.tests.cpp:<line number>: passed: -10., WithinAbs(-9.6, 0.5) for: -10.0 is within 0.5 of -9.6
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), !WithinULP(1., 0) for: 1.0 not is within 0 ULPs of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinAbs(1., 0.5) || WithinULP(2., 1) for: 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 )
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinAbs(2., 0.5) || WithinULP(1., 0) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 )
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) for: nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), !WithinULP(1., 0) for: 1.0 not is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinAbs(1., 0.5) || WithinULP(2., 1) for: 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ([1.99999999999999978, 2.00000000000000044]) )
|
||||
Matchers.tests.cpp:<line number>: passed: 1., WithinAbs(2., 0.5) || WithinULP(1., 0) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000]) )
|
||||
Matchers.tests.cpp:<line number>: passed: WithinAbs(1., 0.)
|
||||
Matchers.tests.cpp:<line number>: passed: WithinAbs(1., -1.), std::domain_error
|
||||
Matchers.tests.cpp:<line number>: passed: WithinULP(1., 0)
|
||||
@ -420,21 +417,18 @@ Matchers.tests.cpp:<line number>: passed: 0.f, WithinAbs(1.f, 1) for: 0.0f is wi
|
||||
Matchers.tests.cpp:<line number>: passed: 0.f, !WithinAbs(1.f, 0.99f) for: 0.0f not is within 0.9900000095 of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: 0.f, !WithinAbs(1.f, 0.99f) for: 0.0f not is within 0.9900000095 of 1.0
|
||||
Matchers.tests.cpp:<line number>: passed: 0.f, WithinAbs(-0.f, 0) for: 0.0f is within 0.0 of -0.0
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan
|
||||
Matchers.tests.cpp:<line number>: passed: 11.f, !WithinAbs(10.f, 0.5f) for: 11.0f not is within 0.5 of 10.0
|
||||
Matchers.tests.cpp:<line number>: passed: 10.f, !WithinAbs(11.f, 0.5f) for: 10.0f not is within 0.5 of 11.0
|
||||
Matchers.tests.cpp:<line number>: passed: -10.f, WithinAbs(-10.f, 0.5f) for: -10.0f is within 0.5 of -10.0
|
||||
Matchers.tests.cpp:<line number>: passed: -10.f, WithinAbs(-9.6f, 0.5f) for: -10.0f is within 0.5 of -9.6000003815
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 0.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), !WithinULP(1.f, 0) for: 1.0f not is within 0 ULPs of 1.0f
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f
|
||||
Matchers.tests.cpp:<line number>: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.0f
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) for: 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f )
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f )
|
||||
Matchers.tests.cpp:<line number>: passed: NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) for: nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 0.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), !WithinULP(1.f, 0) for: 1.0f not is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.0f ([0.00000000000000000, 0.00000000000000000])
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) for: 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955]) )
|
||||
Matchers.tests.cpp:<line number>: passed: 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]) )
|
||||
Matchers.tests.cpp:<line number>: passed: WithinAbs(1.f, 0.f)
|
||||
Matchers.tests.cpp:<line number>: passed: WithinAbs(1.f, -1.f), std::domain_error
|
||||
Matchers.tests.cpp:<line number>: passed: WithinULP(1.f, 0)
|
||||
|
@ -1381,5 +1381,5 @@ due to unexpected exception with message:
|
||||
|
||||
===============================================================================
|
||||
test cases: 289 | 215 passed | 70 failed | 4 failed as expected
|
||||
assertions: 1547 | 1395 passed | 131 failed | 21 failed as expected
|
||||
assertions: 1541 | 1389 passed | 131 failed | 21 failed as expected
|
||||
|
||||
|
@ -2949,11 +2949,6 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
0.0 not is within 0.99 of 1.0
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) )
|
||||
with expansion:
|
||||
nanf not is within 0.0 of nan
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 11., !WithinAbs(10., 0.5) )
|
||||
with expansion:
|
||||
@ -2984,37 +2979,32 @@ Matchers.tests.cpp:<line number>
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1., WithinULP(1., 0) )
|
||||
with expansion:
|
||||
1.0 is within 0 ULPs of 1.0
|
||||
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1., 2.), WithinULP(1., 1) )
|
||||
with expansion:
|
||||
1.0 is within 1 ULPs of 1.0
|
||||
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1., 0.), WithinULP(1., 1) )
|
||||
with expansion:
|
||||
1.0 is within 1 ULPs of 1.0
|
||||
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1., 2.), !WithinULP(1., 0) )
|
||||
with expansion:
|
||||
1.0 not is within 0 ULPs of 1.0
|
||||
1.0 not is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1., WithinULP(1., 0) )
|
||||
with expansion:
|
||||
1.0 is within 0 ULPs of 1.0
|
||||
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( -0., WithinULP(0., 0) )
|
||||
with expansion:
|
||||
-0.0 is within 0 ULPs of 0.0
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !WithinULP(NAN, 123) )
|
||||
with expansion:
|
||||
nanf not is within 123 ULPs of nanf
|
||||
-0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000])
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Floating point matchers: double
|
||||
@ -3026,17 +3016,14 @@ Matchers.tests.cpp:<line number>
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1., WithinAbs(1., 0.5) || WithinULP(2., 1) )
|
||||
with expansion:
|
||||
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 )
|
||||
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ([1.99999999999999978,
|
||||
2.00000000000000044]) )
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1., WithinAbs(2., 0.5) || WithinULP(1., 0) )
|
||||
with expansion:
|
||||
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 )
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) )
|
||||
with expansion:
|
||||
nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ([1.00000000000000000,
|
||||
1.00000000000000000]) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Floating point matchers: double
|
||||
@ -3089,11 +3076,6 @@ Matchers.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
0.0f is within 0.0 of -0.0
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) )
|
||||
with expansion:
|
||||
nanf not is within 0.0 of nan
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 11.f, !WithinAbs(10.f, 0.5f) )
|
||||
with expansion:
|
||||
@ -3124,37 +3106,33 @@ Matchers.tests.cpp:<line number>
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1.f, WithinULP(1.f, 0) )
|
||||
with expansion:
|
||||
1.0f is within 0 ULPs of 1.0f
|
||||
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1.f, 2.f), WithinULP(1.f, 1) )
|
||||
with expansion:
|
||||
1.0f is within 1 ULPs of 1.0f
|
||||
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1.f, 0.f), WithinULP(1.f, 1) )
|
||||
with expansion:
|
||||
1.0f is within 1 ULPs of 1.0f
|
||||
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( nextafter(1.f, 2.f), !WithinULP(1.f, 0) )
|
||||
with expansion:
|
||||
1.0f not is within 0 ULPs of 1.0f
|
||||
1.0f not is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]
|
||||
)
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1.f, WithinULP(1.f, 0) )
|
||||
with expansion:
|
||||
1.0f is within 0 ULPs of 1.0f
|
||||
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( -0.f, WithinULP(0.f, 0) )
|
||||
with expansion:
|
||||
-0.0f is within 0 ULPs of 0.0f
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !WithinULP(NAN, 123) )
|
||||
with expansion:
|
||||
nanf not is within 123 ULPs of nanf
|
||||
-0.0f is within 0 ULPs of 0.0f ([0.00000000000000000, 0.00000000000000000])
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Floating point matchers: float
|
||||
@ -3166,17 +3144,14 @@ Matchers.tests.cpp:<line number>
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) )
|
||||
with expansion:
|
||||
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f )
|
||||
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ([0.
|
||||
99999994039535522, 1.00000011920928955]) )
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) )
|
||||
with expansion:
|
||||
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f )
|
||||
|
||||
Matchers.tests.cpp:<line number>: PASSED:
|
||||
REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) )
|
||||
with expansion:
|
||||
nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ([1.
|
||||
00000000000000000, 1.00000000000000000]) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Floating point matchers: float
|
||||
@ -12291,5 +12266,5 @@ Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 289 | 199 passed | 86 failed | 4 failed as expected
|
||||
assertions: 1564 | 1395 passed | 148 failed | 21 failed as expected
|
||||
assertions: 1558 | 1389 passed | 148 failed | 21 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="1565" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="1559" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
|
@ -3528,14 +3528,6 @@ Nor would this
|
||||
0.0 not is within 0.99 of 1.0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !WithinAbs(NAN, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not is within 0.0 of nan
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
11., !WithinAbs(10., 0.5)
|
||||
@ -3568,7 +3560,7 @@ Nor would this
|
||||
-10.0 is within 0.5 of -9.6
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="9" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="8" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="ULPs" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3576,7 +3568,7 @@ Nor would this
|
||||
1., WithinULP(1., 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 is within 0 ULPs of 1.0
|
||||
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3584,7 +3576,7 @@ Nor would this
|
||||
nextafter(1., 2.), WithinULP(1., 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 is within 1 ULPs of 1.0
|
||||
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3592,7 +3584,7 @@ Nor would this
|
||||
nextafter(1., 0.), WithinULP(1., 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 is within 1 ULPs of 1.0
|
||||
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3600,7 +3592,7 @@ Nor would this
|
||||
nextafter(1., 2.), !WithinULP(1., 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 not is within 0 ULPs of 1.0
|
||||
1.0 not is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3608,7 +3600,7 @@ Nor would this
|
||||
1., WithinULP(1., 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 is within 0 ULPs of 1.0
|
||||
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3616,18 +3608,10 @@ Nor would this
|
||||
-0., WithinULP(0., 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
-0.0 is within 0 ULPs of 0.0
|
||||
-0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !WithinULP(NAN, 123)
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not is within 123 ULPs of nanf
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="7" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Composed" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3635,7 +3619,7 @@ Nor would this
|
||||
1., WithinAbs(1., 0.5) || WithinULP(2., 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 )
|
||||
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ([1.99999999999999978, 2.00000000000000044]) )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3643,18 +3627,10 @@ Nor would this
|
||||
1., WithinAbs(2., 0.5) || WithinULP(1., 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 )
|
||||
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000]) )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Constructor validation" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3735,14 +3711,6 @@ Nor would this
|
||||
0.0f is within 0.0 of -0.0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !WithinAbs(NAN, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not is within 0.0 of nan
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
11.f, !WithinAbs(10.f, 0.5f)
|
||||
@ -3775,7 +3743,7 @@ Nor would this
|
||||
-10.0f is within 0.5 of -9.6000003815
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="10" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="9" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="ULPs" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3783,7 +3751,7 @@ Nor would this
|
||||
1.f, WithinULP(1.f, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f is within 0 ULPs of 1.0f
|
||||
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3791,7 +3759,7 @@ Nor would this
|
||||
nextafter(1.f, 2.f), WithinULP(1.f, 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f is within 1 ULPs of 1.0f
|
||||
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3799,7 +3767,7 @@ Nor would this
|
||||
nextafter(1.f, 0.f), WithinULP(1.f, 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f is within 1 ULPs of 1.0f
|
||||
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3807,7 +3775,7 @@ Nor would this
|
||||
nextafter(1.f, 2.f), !WithinULP(1.f, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f not is within 0 ULPs of 1.0f
|
||||
1.0f not is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3815,7 +3783,7 @@ Nor would this
|
||||
1.f, WithinULP(1.f, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f is within 0 ULPs of 1.0f
|
||||
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3823,18 +3791,10 @@ Nor would this
|
||||
-0.f, WithinULP(0.f, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
-0.0f is within 0 ULPs of 0.0f
|
||||
-0.0f is within 0 ULPs of 0.0f ([0.00000000000000000, 0.00000000000000000])
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !WithinULP(NAN, 123)
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not is within 123 ULPs of nanf
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="7" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Composed" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3842,7 +3802,7 @@ Nor would this
|
||||
1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f )
|
||||
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955]) )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -3850,18 +3810,10 @@ Nor would this
|
||||
1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f )
|
||||
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]) )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))
|
||||
</Original>
|
||||
<Expanded>
|
||||
nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Constructor validation" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
@ -14674,7 +14626,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1395" failures="149" expectedFailures="21"/>
|
||||
<OverallResults successes="1389" failures="149" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="1395" failures="148" expectedFailures="21"/>
|
||||
<OverallResults successes="1389" failures="148" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@ -347,7 +347,6 @@ namespace { namespace MatchersTests {
|
||||
REQUIRE_THAT(0.f, !WithinAbs(1.f, 0.99f));
|
||||
|
||||
REQUIRE_THAT(0.f, WithinAbs(-0.f, 0));
|
||||
REQUIRE_THAT(NAN, !WithinAbs(NAN, 0));
|
||||
|
||||
REQUIRE_THAT(11.f, !WithinAbs(10.f, 0.5f));
|
||||
REQUIRE_THAT(10.f, !WithinAbs(11.f, 0.5f));
|
||||
@ -363,14 +362,10 @@ namespace { namespace MatchersTests {
|
||||
|
||||
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
|
||||
REQUIRE_THAT(-0.f, WithinULP(0.f, 0));
|
||||
|
||||
REQUIRE_THAT(NAN, !WithinULP(NAN, 123));
|
||||
}
|
||||
SECTION("Composed") {
|
||||
REQUIRE_THAT(1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1));
|
||||
REQUIRE_THAT(1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0));
|
||||
|
||||
REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)));
|
||||
}
|
||||
SECTION("Constructor validation") {
|
||||
REQUIRE_NOTHROW(WithinAbs(1.f, 0.f));
|
||||
@ -389,8 +384,6 @@ namespace { namespace MatchersTests {
|
||||
REQUIRE_THAT(0., !WithinAbs(1., 0.99));
|
||||
REQUIRE_THAT(0., !WithinAbs(1., 0.99));
|
||||
|
||||
REQUIRE_THAT(NAN, !WithinAbs(NAN, 0));
|
||||
|
||||
REQUIRE_THAT(11., !WithinAbs(10., 0.5));
|
||||
REQUIRE_THAT(10., !WithinAbs(11., 0.5));
|
||||
REQUIRE_THAT(-10., WithinAbs(-10., 0.5));
|
||||
@ -405,14 +398,10 @@ namespace { namespace MatchersTests {
|
||||
|
||||
REQUIRE_THAT(1., WithinULP(1., 0));
|
||||
REQUIRE_THAT(-0., WithinULP(0., 0));
|
||||
|
||||
REQUIRE_THAT(NAN, !WithinULP(NAN, 123));
|
||||
}
|
||||
SECTION("Composed") {
|
||||
REQUIRE_THAT(1., WithinAbs(1., 0.5) || WithinULP(2., 1));
|
||||
REQUIRE_THAT(1., WithinAbs(2., 0.5) || WithinULP(1., 0));
|
||||
|
||||
REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)));
|
||||
}
|
||||
SECTION("Constructor validation") {
|
||||
REQUIRE_NOTHROW(WithinAbs(1., 0.));
|
||||
@ -423,6 +412,12 @@ namespace { namespace MatchersTests {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Floating point matchers that are problematic in approvals", "[approvals][matchers][floating-point]") {
|
||||
REQUIRE_THAT(NAN, !WithinAbs(NAN, 0));
|
||||
REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)));
|
||||
REQUIRE_THAT(NAN, !WithinULP(NAN, 123));
|
||||
}
|
||||
|
||||
TEST_CASE("Arbitrary predicate matcher", "[matchers][generic]") {
|
||||
SECTION("Function pointer") {
|
||||
REQUIRE_THAT(1, Predicate<int>(alwaysTrue, "always true"));
|
||||
|
Loading…
Reference in New Issue
Block a user