catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Backport changes from 7bea1e2ac36ac54b648ae5c9d381a59bc69db912 to fix #2273 for 2.x
- Commit
3d01f3ae3279b806739936f0ffd44598bf20245c- Author
- Rupert Nash ·
- Committer
- Martin Hořeňovský
- Parents
85c9544fa4c9
Changes
include/internal/catch_approx.h | 2 +- projects/SelfTest/UsageTests/Approx.tests.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/internal/catch_approx.h b/include/internal/catch_approx.h index 4522e5ad..2d12efe4 100644 --- a/include/internal/catch_approx.h +++ b/include/internal/catch_approx.h @@ -33,7 +33,7 @@ namespace Detail { Approx operator-() const; template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> - Approx operator()( T const& value ) { + Approx operator()( T const& value ) const { Approx approx( static_cast<double>(value) ); approx.m_epsilon = m_epsilon; approx.m_margin = m_margin; diff --git a/projects/SelfTest/UsageTests/Approx.tests.cpp b/projects/SelfTest/UsageTests/Approx.tests.cpp index 4029223a..6280599e 100644 --- a/projects/SelfTest/UsageTests/Approx.tests.cpp +++ b/projects/SelfTest/UsageTests/Approx.tests.cpp @@ -212,4 +212,11 @@ TEST_CASE( "Comparison with explicitly convertible types", "[Approx]" ) } +TEST_CASE("Approx::operator() is const correct", "[Approx][.approvals]") { + const Approx ap = Approx(0.0).margin(0.01); + + // As long as this compiles, the test should be considered passing + REQUIRE(1.0 == ap(1.0)); +} + }} // namespace ApproxTests