Skip to content

Commit

Permalink
Backport changes from 7bea1e2 to fix #2273 for 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertnash authored and horenmar committed Sep 18, 2021
1 parent 85c9544 commit 3d01f3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/internal/catch_approx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions projects/SelfTest/UsageTests/Approx.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3d01f3a

Please sign in to comment.