Use scientific notation for the WithinULP matcher

This should now properly handle small numbers which would previously
output something like `[0.00000000000000019, 0.00000000000000019]`,
which does not allow user to read the numbers properly.

Closes #1760
This commit is contained in:
Martin Hořeňovský 2019-10-20 12:30:21 +02:00
parent 84856844e1
commit 9e8ae7d470
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
7 changed files with 129 additions and 88 deletions

View File

@ -101,14 +101,17 @@ FP step(FP start, FP direction, uint64_t steps) {
return start;
}
namespace {
// Performs equivalent check of std::fabs(lhs - rhs) <= margin
// But without the subtraction to allow for INFINITY in comparison
bool marginComparison(double lhs, double rhs, double margin) {
return (lhs + margin >= rhs) && (rhs + margin >= lhs);
}
// Performs equivalent check of std::fabs(lhs - rhs) <= margin
// But without the subtraction to allow for INFINITY in comparison
bool marginComparison(double lhs, double rhs, double margin) {
return (lhs + margin >= rhs) && (rhs + margin >= lhs);
}
template <typename FloatingPoint>
void write(std::ostream& out, FloatingPoint num) {
out << std::scientific
<< std::setprecision(std::numeric_limits<FloatingPoint>::max_digits10 - 1)
<< num;
}
} // end anonymous namespace
@ -170,27 +173,28 @@ namespace Floating {
std::string WithinUlpsMatcher::describe() const {
std::stringstream ret;
ret << "is within " << m_ulps << " ULPs of " << ::Catch::Detail::stringify(m_target);
ret << "is within " << m_ulps << " ULPs of ";
if (m_type == FloatingPointKind::Float) {
write(ret, static_cast<float>(m_target));
ret << 'f';
} else {
write(ret, m_target);
}
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);
write(ret, step(m_target, static_cast<double>(-INFINITY), m_ulps));
ret << ", ";
write(ret, 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);
write(ret, step(static_cast<float>(m_target), -INFINITY, m_ulps));
ret << ", ";
write(ret, step(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" : "");
}
WithinRelMatcher::WithinRelMatcher(double target, double epsilon):

View File

@ -424,14 +424,15 @@ Matchers.tests.cpp:<line number>: passed: 11., !WithinAbs(10., 0.5) for: 11.0 no
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 ([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: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00])
Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00])
Matchers.tests.cpp:<line number>: passed: 0., WithinULP(nextafter(0., 1.), 1) for: 0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324])
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(nextafter(1., 0.), 1) for: 1.0 is within 1 ULPs of 9.9999999999999989e-01 ([9.9999999999999978e-01, 1.0000000000000000e+00])
Matchers.tests.cpp:<line number>: passed: 1., !WithinULP(nextafter(1., 2.), 0) for: 1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00, 1.0000000000000002e+00])
Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00])
Matchers.tests.cpp:<line number>: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0000000000000000e+00 ([0.0000000000000000e+00, 0.0000000000000000e+00])
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.0000000000000000e+00 ([1.9999999999999998e+00, 2.0000000000000004e+00]) )
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.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) )
Matchers.tests.cpp:<line number>: passed: 0.0001, WithinAbs(0., 0.001) || WithinRel(0., 0.1) for: 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other )
Matchers.tests.cpp:<line number>: passed: WithinAbs(1., 0.)
Matchers.tests.cpp:<line number>: passed: WithinAbs(1., -1.), std::domain_error
@ -453,14 +454,15 @@ Matchers.tests.cpp:<line number>: passed: 11.f, !WithinAbs(10.f, 0.5f) for: 11.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 ([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: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00])
Matchers.tests.cpp:<line number>: passed: 0.f, WithinULP(nextafter(0.f, 1.f), 1) for: 0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45])
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(nextafter(1.f, 0.f), 1) for: 1.0f is within 1 ULPs of 9.99999940e-01f ([9.99999881e-01, 1.00000000e+00])
Matchers.tests.cpp:<line number>: passed: 1.f, !WithinULP(nextafter(1.f, 2.f), 0) for: 1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+00])
Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
Matchers.tests.cpp:<line number>: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.00000000e+00f ([0.00000000e+00, 0.00000000e+00])
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.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) )
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.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) )
Matchers.tests.cpp:<line number>: passed: 0.0001f, WithinAbs(0.f, 0.001f) || WithinRel(0.f, 0.1f) for: 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other )
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

View File

@ -1381,5 +1381,5 @@ due to unexpected exception with message:
===============================================================================
test cases: 304 | 230 passed | 70 failed | 4 failed as expected
assertions: 1619 | 1467 passed | 131 failed | 21 failed as expected
assertions: 1621 | 1469 passed | 131 failed | 21 failed as expected

View File

@ -3211,32 +3211,44 @@ 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.00000000000000000, 1.00000000000000000])
1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.
0000000000000000e+00])
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 ([0.99999999999999989, 1.00000000000000022])
1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.
0000000000000002e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( nextafter(1., 0.), WithinULP(1., 1) )
REQUIRE_THAT( 0., WithinULP(nextafter(0., 1.), 1) )
with expansion:
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.
8813129168249309e-324])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( nextafter(1., 2.), !WithinULP(1., 0) )
REQUIRE_THAT( 1., WithinULP(nextafter(1., 0.), 1) )
with expansion:
1.0 not is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
1.0 is within 1 ULPs of 9.9999999999999989e-01 ([9.9999999999999978e-01, 1.
0000000000000000e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( 1., !WithinULP(nextafter(1., 2.), 0) )
with expansion:
1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00,
1.0000000000000002e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( 1., WithinULP(1., 0) )
with expansion:
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.
0000000000000000e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( -0., WithinULP(0., 0) )
with expansion:
-0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000])
-0.0 is within 0 ULPs of 0.0000000000000000e+00 ([0.0000000000000000e+00, 0.
0000000000000000e+00])
-------------------------------------------------------------------------------
Floating point matchers: double
@ -3248,14 +3260,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.99999999999999978,
2.00000000000000044]) )
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0000000000000000e+00 ([1.
9999999999999998e+00, 2.0000000000000004e+00]) )
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 ([1.00000000000000000,
1.00000000000000000]) )
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.
0000000000000000e+00, 1.0000000000000000e+00]) )
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( 0.0001, WithinAbs(0., 0.001) || WithinRel(0., 0.1) )
@ -3389,33 +3401,38 @@ 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.00000000000000000, 1.00000000000000000])
1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
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 ([0.99999994039535522, 1.00000011920928955])
1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( nextafter(1.f, 0.f), WithinULP(1.f, 1) )
REQUIRE_THAT( 0.f, WithinULP(nextafter(0.f, 1.f), 1) )
with expansion:
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( nextafter(1.f, 2.f), !WithinULP(1.f, 0) )
REQUIRE_THAT( 1.f, WithinULP(nextafter(1.f, 0.f), 1) )
with expansion:
1.0f not is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]
)
1.0f is within 1 ULPs of 9.99999940e-01f ([9.99999881e-01, 1.00000000e+00])
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( 1.f, !WithinULP(nextafter(1.f, 2.f), 0) )
with expansion:
1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+
00])
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.00000000000000000, 1.00000000000000000])
1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
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 ([0.00000000000000000, 0.00000000000000000])
-0.0f is within 0 ULPs of 0.00000000e+00f ([0.00000000e+00, 0.00000000e+00])
-------------------------------------------------------------------------------
Floating point matchers: float
@ -3427,14 +3444,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 ([0.
99999994039535522, 1.00000011920928955]) )
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.00000000e+00f ([9.
99999940e-01, 1.00000012e+00]) )
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 ([1.
00000000000000000, 1.00000000000000000]) )
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.
00000000e+00, 1.00000000e+00]) )
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( 0.0001f, WithinAbs(0.f, 0.001f) || WithinRel(0.f, 0.1f) )
@ -12940,5 +12957,5 @@ Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 304 | 214 passed | 86 failed | 4 failed as expected
assertions: 1636 | 1467 passed | 148 failed | 21 failed as expected
assertions: 1638 | 1469 passed | 148 failed | 21 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="132" tests="1637" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="132" tests="1639" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/>

View File

@ -3811,7 +3811,7 @@ Nor would this
1., WithinULP(1., 0)
</Original>
<Expanded>
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -3819,23 +3819,31 @@ Nor would this
nextafter(1., 2.), WithinULP(1., 1)
</Original>
<Expanded>
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
nextafter(1., 0.), WithinULP(1., 1)
0., WithinULP(nextafter(0., 1.), 1)
</Original>
<Expanded>
1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022])
0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
nextafter(1., 2.), !WithinULP(1., 0)
1., WithinULP(nextafter(1., 0.), 1)
</Original>
<Expanded>
1.0 not is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
1.0 is within 1 ULPs of 9.9999999999999989e-01 ([9.9999999999999978e-01, 1.0000000000000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
1., !WithinULP(nextafter(1., 2.), 0)
</Original>
<Expanded>
1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00, 1.0000000000000002e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -3843,7 +3851,7 @@ Nor would this
1., WithinULP(1., 0)
</Original>
<Expanded>
1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000])
1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -3851,10 +3859,10 @@ Nor would this
-0., WithinULP(0., 0)
</Original>
<Expanded>
-0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000])
-0.0 is within 0 ULPs of 0.0000000000000000e+00 ([0.0000000000000000e+00, 0.0000000000000000e+00])
</Expanded>
</Expression>
<OverallResults successes="6" failures="0" expectedFailures="0"/>
<OverallResults successes="7" 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" >
@ -3862,7 +3870,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.99999999999999978, 2.00000000000000044]) )
1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0000000000000000e+00 ([1.9999999999999998e+00, 2.0000000000000004e+00]) )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -3870,7 +3878,7 @@ 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.00000000000000000, 1.00000000000000000]) )
1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -4064,7 +4072,7 @@ Nor would this
1.f, WithinULP(1.f, 0)
</Original>
<Expanded>
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -4072,23 +4080,31 @@ Nor would this
nextafter(1.f, 2.f), WithinULP(1.f, 1)
</Original>
<Expanded>
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
nextafter(1.f, 0.f), WithinULP(1.f, 1)
0.f, WithinULP(nextafter(0.f, 1.f), 1)
</Original>
<Expanded>
1.0f is within 1 ULPs of 1.0f ([0.99999994039535522, 1.00000011920928955])
0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
nextafter(1.f, 2.f), !WithinULP(1.f, 0)
1.f, WithinULP(nextafter(1.f, 0.f), 1)
</Original>
<Expanded>
1.0f not is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
1.0f is within 1 ULPs of 9.99999940e-01f ([9.99999881e-01, 1.00000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
1.f, !WithinULP(nextafter(1.f, 2.f), 0)
</Original>
<Expanded>
1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -4096,7 +4112,7 @@ Nor would this
1.f, WithinULP(1.f, 0)
</Original>
<Expanded>
1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000])
1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00])
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -4104,10 +4120,10 @@ Nor would this
-0.f, WithinULP(0.f, 0)
</Original>
<Expanded>
-0.0f is within 0 ULPs of 0.0f ([0.00000000000000000, 0.00000000000000000])
-0.0f is within 0 ULPs of 0.00000000e+00f ([0.00000000e+00, 0.00000000e+00])
</Expanded>
</Expression>
<OverallResults successes="6" failures="0" expectedFailures="0"/>
<OverallResults successes="7" 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" >
@ -4115,7 +4131,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 ([0.99999994039535522, 1.00000011920928955]) )
1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -4123,7 +4139,7 @@ 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.00000000000000000, 1.00000000000000000]) )
1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
@ -15411,7 +15427,7 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="1467" failures="149" expectedFailures="21"/>
<OverallResults successes="1469" failures="149" expectedFailures="21"/>
</Group>
<OverallResults successes="1467" failures="148" expectedFailures="21"/>
<OverallResults successes="1469" failures="148" expectedFailures="21"/>
</Catch>

View File

@ -382,8 +382,9 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
REQUIRE_THAT(nextafter(1.f, 2.f), WithinULP(1.f, 1));
REQUIRE_THAT(nextafter(1.f, 0.f), WithinULP(1.f, 1));
REQUIRE_THAT(nextafter(1.f, 2.f), !WithinULP(1.f, 0));
REQUIRE_THAT(0.f, WithinULP(nextafter(0.f, 1.f), 1));
REQUIRE_THAT(1.f, WithinULP(nextafter(1.f, 0.f), 1));
REQUIRE_THAT(1.f, !WithinULP(nextafter(1.f, 2.f), 0));
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
REQUIRE_THAT(-0.f, WithinULP(0.f, 0));
@ -437,8 +438,9 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(1., WithinULP(1., 0));
REQUIRE_THAT(nextafter(1., 2.), WithinULP(1., 1));
REQUIRE_THAT(nextafter(1., 0.), WithinULP(1., 1));
REQUIRE_THAT(nextafter(1., 2.), !WithinULP(1., 0));
REQUIRE_THAT(0., WithinULP(nextafter(0., 1.), 1));
REQUIRE_THAT(1., WithinULP(nextafter(1., 0.), 1));
REQUIRE_THAT(1., !WithinULP(nextafter(1., 2.), 0));
REQUIRE_THAT(1., WithinULP(1., 0));
REQUIRE_THAT(-0., WithinULP(0., 0));