Use Catch::StringMaker for output in WithinRelMatcher (#2846)

The WithinRelMatcher does not listen to the precision specification; it just naively pipes to stringstream. If you specify the precision, that has no impact on the outputted values when the match fails.

This fix makes the WithinRelMatcher listen to the precision (https://github.com/catchorg/Catch2/blob/devel/docs/tostring.md#floating-point-precision) specified by: Catch::StringMaker<float>::precision
This commit is contained in:
Ian Bell
2024-04-15 05:35:39 -06:00
committed by GitHub
parent 029fe3b460
commit 53ddf37af4
9 changed files with 81 additions and 81 deletions

View File

@@ -176,7 +176,7 @@ namespace Detail {
std::string WithinRelMatcher::describe() const {
Catch::ReusableStringStream sstr;
sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other";
sstr << "and " << ::Catch::Detail::stringify(m_target) << " are within " << m_epsilon * 100. << "% of each other";
return sstr.str();
}