diff --git a/include/internal/catch_matchers_floating.cpp b/include/internal/catch_matchers_floating.cpp index cdc0f0cb..68fd1bda 100644 --- a/include/internal/catch_matchers_floating.cpp +++ b/include/internal/catch_matchers_floating.cpp @@ -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 +void write(std::ostream& out, FloatingPoint num) { + out << std::scientific + << std::setprecision(std::numeric_limits::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(m_target)); ret << 'f'; + } else { + write(ret, m_target); } ret << " (["; - ret << std::fixed << std::setprecision(std::numeric_limits::max_digits10); if (m_type == FloatingPointKind::Double) { - ret << step(m_target, static_cast(-INFINITY), m_ulps) - << ", " - << step(m_target, static_cast(INFINITY), m_ulps); + write(ret, step(m_target, static_cast(-INFINITY), m_ulps)); + ret << ", "; + write(ret, step(m_target, static_cast( INFINITY), m_ulps)); } else { - ret << step(static_cast(m_target), -INFINITY, m_ulps) - << ", " - << step(static_cast(m_target), INFINITY, m_ulps); + write(ret, step(static_cast(m_target), -INFINITY, m_ulps)); + ret << ", "; + write(ret, step(static_cast(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): diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 30bdd58b..311183bc 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -424,14 +424,15 @@ Matchers.tests.cpp:: passed: 11., !WithinAbs(10., 0.5) for: 11.0 no Matchers.tests.cpp:: passed: 10., !WithinAbs(11., 0.5) for: 10.0 not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10., WithinAbs(-10., 0.5) for: -10.0 is within 0.5 of -10.0 Matchers.tests.cpp:: passed: -10., WithinAbs(-9.6, 0.5) for: -10.0 is within 0.5 of -9.6 -Matchers.tests.cpp:: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000]) -Matchers.tests.cpp:: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022]) -Matchers.tests.cpp:: passed: nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 ([0.99999999999999989, 1.00000000000000022]) -Matchers.tests.cpp:: 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:: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 ([1.00000000000000000, 1.00000000000000000]) -Matchers.tests.cpp:: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0 ([0.00000000000000000, 0.00000000000000000]) -Matchers.tests.cpp:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: passed: WithinAbs(1., 0.) Matchers.tests.cpp:: passed: WithinAbs(1., -1.), std::domain_error @@ -453,14 +454,15 @@ Matchers.tests.cpp:: passed: 11.f, !WithinAbs(10.f, 0.5f) for: 11.0 Matchers.tests.cpp:: passed: 10.f, !WithinAbs(11.f, 0.5f) for: 10.0f not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10.f, WithinAbs(-10.f, 0.5f) for: -10.0f is within 0.5 of -10.0 Matchers.tests.cpp:: passed: -10.f, WithinAbs(-9.6f, 0.5f) for: -10.0f is within 0.5 of -9.6000003815 -Matchers.tests.cpp:: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]) -Matchers.tests.cpp:: 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:: 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:: 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:: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f ([1.00000000000000000, 1.00000000000000000]) -Matchers.tests.cpp:: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.0f ([0.00000000000000000, 0.00000000000000000]) -Matchers.tests.cpp:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: 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:: passed: WithinAbs(1.f, 0.f) Matchers.tests.cpp:: passed: WithinAbs(1.f, -1.f), std::domain_error diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 77acca01..fd405a84 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -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 diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index c7f1d4c4..f234f882 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -3211,32 +3211,44 @@ Matchers.tests.cpp: Matchers.tests.cpp:: 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:: 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:: 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:: 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:: 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:: 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:: 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: Matchers.tests.cpp:: 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:: 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:: PASSED: REQUIRE_THAT( 0.0001, WithinAbs(0., 0.001) || WithinRel(0., 0.1) ) @@ -3389,33 +3401,38 @@ Matchers.tests.cpp: Matchers.tests.cpp:: 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:: 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:: 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:: 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:: 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:: 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:: 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: Matchers.tests.cpp:: 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:: 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:: PASSED: REQUIRE_THAT( 0.0001f, WithinAbs(0.f, 0.001f) || WithinRel(0.f, 0.1f) ) @@ -12940,5 +12957,5 @@ Misc.tests.cpp:: 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 diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 247816c3..bfacb033 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 2de31a40..6193dfb3 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -3811,7 +3811,7 @@ Nor would this 1., WithinULP(1., 0) - 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]) @@ -3819,23 +3819,31 @@ Nor would this nextafter(1., 2.), WithinULP(1., 1) - 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]) - nextafter(1., 0.), WithinULP(1., 1) + 0., WithinULP(nextafter(0., 1.), 1) - 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]) - nextafter(1., 2.), !WithinULP(1., 0) + 1., WithinULP(nextafter(1., 0.), 1) - 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]) + + + + + 1., !WithinULP(nextafter(1., 2.), 0) + + + 1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00, 1.0000000000000002e+00]) @@ -3843,7 +3851,7 @@ Nor would this 1., WithinULP(1., 0) - 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]) @@ -3851,10 +3859,10 @@ Nor would this -0., WithinULP(0., 0) - -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]) - +
@@ -3862,7 +3870,7 @@ Nor would this 1., WithinAbs(1., 0.5) || WithinULP(2., 1) - 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]) ) @@ -3870,7 +3878,7 @@ Nor would this 1., WithinAbs(2., 0.5) || WithinULP(1., 0) - 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]) ) @@ -4064,7 +4072,7 @@ Nor would this 1.f, WithinULP(1.f, 0) - 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]) @@ -4072,23 +4080,31 @@ Nor would this nextafter(1.f, 2.f), WithinULP(1.f, 1) - 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]) - nextafter(1.f, 0.f), WithinULP(1.f, 1) + 0.f, WithinULP(nextafter(0.f, 1.f), 1) - 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]) - nextafter(1.f, 2.f), !WithinULP(1.f, 0) + 1.f, WithinULP(nextafter(1.f, 0.f), 1) - 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]) + + + + + 1.f, !WithinULP(nextafter(1.f, 2.f), 0) + + + 1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+00]) @@ -4096,7 +4112,7 @@ Nor would this 1.f, WithinULP(1.f, 0) - 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]) @@ -4104,10 +4120,10 @@ Nor would this -0.f, WithinULP(0.f, 0) - -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]) - +
@@ -4115,7 +4131,7 @@ Nor would this 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) - 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]) ) @@ -4123,7 +4139,7 @@ Nor would this 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) - 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]) ) @@ -15411,7 +15427,7 @@ loose text artifact
- + - + diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp index 6f954ca0..80e0420f 100644 --- a/projects/SelfTest/UsageTests/Matchers.tests.cpp +++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp @@ -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));