Floating-point near-equality assertions with given tolerances.
For given atol and rtol values, is_close(actual, desired) succeeds according to:
tolerance = atol + rtol * abs(desired);
success = abs(actual - desired) <= tolerance;
Example:
with_tolerance(double atol, double rtol)
Set the comparison tolerances.
Definition Testutils.hpp:462
#include <Testutils.hpp>
|
| | with_tolerance (double atol, double rtol) |
| | Set the comparison tolerances.
|
| template<std::floating_point T> |
| void | assert_close (T actual, T desired, const std::source_location loc=std::source_location::current()) const |
| | Check if two values are equal up to the set tolerances.
|
| template<std::ranges::sized_range R1, std::ranges::sized_range R2> |
| void | assert_allclose (const R1 &actual, const R2 &desired, const std::source_location loc=std::source_location::current()) const |
| | Check if the elements of two ranges are pairwise equal up to the set tolerances.
|
| template<std::ranges::sized_range R1> |
| void | assert_allclose (const R1 &actual, std::ranges::range_value_t< R1 > desired, const std::source_location loc=std::source_location::current()) const |
| | Check if the elements of a range are equal to a desired value up to the set tolerances.
|
| template<memory::IFieldView TFieldView> |
| void | assert_allclose (const TFieldView &actual, const TFieldView &desired, bool withGhostLayers=false, const std::source_location loc=std::source_location::current()) const |
| | Check if the elements of two waLBerla fields are equal up to the set tolerances.
|
|
| template<std::floating_point T> |
| bool | isclose (T actual, T desired) const |
| void | fail_not_close (auto &actual, auto &desired, const std::source_location loc) const |
◆ with_tolerance()
| walberla::v8::testing::with_tolerance::with_tolerance |
( |
double | atol, |
|
|
double | rtol ) |
|
inline |
Set the comparison tolerances.
◆ assert_allclose() [1/3]
template<std::ranges::sized_range R1, std::ranges::sized_range R2>
| void walberla::v8::testing::with_tolerance::assert_allclose |
( |
const R1 & | actual, |
|
|
const R2 & | desired, |
|
|
const std::source_location | loc = std::source_location::current() ) const |
|
inline |
Check if the elements of two ranges are pairwise equal up to the set tolerances.
- Note
- Assertion will fail if the ranges are not of the same length.
◆ assert_allclose() [2/3]
template<std::ranges::sized_range R1>
| void walberla::v8::testing::with_tolerance::assert_allclose |
( |
const R1 & | actual, |
|
|
std::ranges::range_value_t< R1 > | desired, |
|
|
const std::source_location | loc = std::source_location::current() ) const |
|
inline |
Check if the elements of a range are equal to a desired value up to the set tolerances.
- Note
- Assertion will succeed if the range is empty
◆ assert_allclose() [3/3]
template<memory::IFieldView TFieldView>
| void walberla::v8::testing::with_tolerance::assert_allclose |
( |
const TFieldView & | actual, |
|
|
const TFieldView & | desired, |
|
|
bool | withGhostLayers = false, |
|
|
const std::source_location | loc = std::source_location::current() ) const |
|
inline |
Check if the elements of two waLBerla fields are equal up to the set tolerances.
◆ assert_close()
template<std::floating_point T>
| void walberla::v8::testing::with_tolerance::assert_close |
( |
T | actual, |
|
|
T | desired, |
|
|
const std::source_location | loc = std::source_location::current() ) const |
|
inline |
Check if two values are equal up to the set tolerances.
◆ fail_not_close()
| void walberla::v8::testing::with_tolerance::fail_not_close |
( |
auto & | actual, |
|
|
auto & | desired, |
|
|
const std::source_location | loc ) const |
|
inlineprivate |
◆ isclose()
template<std::floating_point T>
| bool walberla::v8::testing::with_tolerance::isclose |
( |
T | actual, |
|
|
T | desired ) const |
|
inlineprivate |
◆ atol_
| double walberla::v8::testing::with_tolerance::atol_ |
|
private |
◆ rtol_
| double walberla::v8::testing::with_tolerance::rtol_ |
|
private |
The documentation for this class was generated from the following file:
- /builds/administration/walberla-website/walberla/include/walberla/v8/testing/Testutils.hpp