23namespace sequoia::testing
29 template<
class T,
class NormType>
30 inline constexpr static bool has_abs{
requires(
const T& x) { { abs(x) } -> std::same_as<NormType>; }};
33 template<
class T,
class NormType>
34 inline constexpr static bool has_abs{abs_detail::has_abs<T, NormType>};
42 template<
class Compare>
45 template<
bool IsFinalMessage,
class T>
54 template<std::totally_ordered ToleranceType>
57 ToleranceType m_Tol{};
59 using tolerance_type = ToleranceType;
61 constexpr explicit within_tolerance(ToleranceType tol) : m_Tol{std::move(tol)} {};
64 constexpr tolerance_type tol()
const noexcept
70 requires has_abs<T, ToleranceType>
72 constexpr bool operator()(
const T& obtained,
const T& prediction)
const noexcept
75 return abs(obtained - prediction) <= m_Tol;
82 template<
bool IsFinalMessage,
class ComparedType>
87 return prediction_message(obtained, prediction).append(
" +/- ").append(to_string(c.tol()));
94 template<
bool IsFinalMessage,
class T>
105 std::string relational_failure_message(std::string symbol,
const T& obtained,
const T& prediction)
107 return prediction_message(to_string(obtained), symbol.append(
" ").append(to_string(prediction)));
113 template<
bool IsFinalMessage,
class T>
118 return relational_failure_message(
"<", obtained, prediction);
125 template<
bool IsFinalMessage,
class T>
130 return relational_failure_message(
"<=", obtained, prediction);
137 template<
bool IsFinalMessage,
class T>
142 return relational_failure_message(
">", obtained, prediction);
149 template<
bool IsFinalMessage,
class T>
154 return relational_failure_message(
">=", obtained, prediction);
A collection of functions for formatting test output.
std::string failure_message(is_final_message_t, T, T)
To prevent implicit conversions to bool.
Definition: Output.hpp:146
Definition: Output.hpp:186
Function object for performing comparisons within an absolute tolerance.
Definition: BinaryRelationships.hpp:56
Definition: Output.hpp:140
Specialize this struct template to provide custom reporting for comparisons performed with a binary o...
Definition: BinaryRelationships.hpp:44
Definition: Output.hpp:131