9#include "Constants/scaling.h"
10#include "DataTypes/common_types.h"
11#include "DataTypes/stormm_vector_types.h"
12#include "Reporting/error_format.h"
13#include "unit_test_enumerators.h"
18using data_types::isScalarType;
32 template <
typename T>
Approx(
const std::vector<T> &values_in,
33 ComparisonType style_in = ComparisonType::ABSOLUTE,
34 double tol_in = 1.0e-6);
46 Approx(
double value_in, ComparisonType style_in = ComparisonType::ABSOLUTE,
47 double tol_in = 1.0e-6);
48 Approx(
double value_in,
double tol_in, ComparisonType style_in = ComparisonType::ABSOLUTE);
69 double getTolerance()
const;
70 double getTol()
const;
87 void setValues(
const std::vector<double> &values_in);
88 void setValue(
double value_in,
size_t index);
99 void setTolerance(
double dtol_in);
100 void setTol(
double dtol_in);
114 Approx tolerance(
double dtol_in)
const;
115 Approx tol(
double dtol_in)
const;
121 bool test(
const double test_value)
const;
127 template <
typename T>
bool test(
const std::vector<T> &test_values)
const;
130 std::vector<double> values;
131 ComparisonType style;
140template <
typename T>
bool verifyVectorApproxCompatibility(
const std::vector<T> &test_values,
149bool operator==(
const double d,
const Approx &cr);
150bool operator==(
const Approx &cr,
const double d);
151bool operator!=(
const double d,
const Approx &cr);
152bool operator!=(
const Approx &cr,
const double d);
153bool operator>(
const double d,
const Approx &cr);
154bool operator>(
const Approx &cr,
const double d);
155bool operator<(
const double d,
const Approx &cr);
156bool operator<(
const Approx &cr,
const double d);
157bool operator>=(
const double d,
const Approx &cr);
158bool operator>=(
const Approx &cr,
const double d);
159bool operator<=(
const double d,
const Approx &cr);
160bool operator<=(
const Approx &cr,
const double d);
168template <
typename T>
bool operator==(
const std::vector<T> &tvec,
const Approx &cr);
169template <
typename T>
bool operator==(
const Approx &cr,
const std::vector<T> &tvec);
170template <
typename T>
bool operator!=(
const std::vector<T> &tvec,
const Approx &cr);
171template <
typename T>
bool operator!=(
const Approx &cr,
const std::vector<T> &tvec);
172template <
typename T>
bool operator>(
const std::vector<T> &tvec,
const Approx &cr);
173template <
typename T>
bool operator>(
const Approx &cr,
const std::vector<T> &tvec);
174template <
typename T>
bool operator<(
const std::vector<T> &tvec,
const Approx &cr);
175template <
typename T>
bool operator<(
const Approx &cr,
const std::vector<T> &tvec);
176template <
typename T>
bool operator>=(
const std::vector<T> &tvec,
const Approx &cr);
177template <
typename T>
bool operator>=(
const Approx &cr,
const std::vector<T> &tvec);
178template <
typename T>
bool operator<=(
const std::vector<T> &tvec,
const Approx &cr);
179template <
typename T>
bool operator<=(
const Approx &cr,
const std::vector<T> &tvec);
Approx(const std::vector< T > &values_in, ComparisonType style_in=ComparisonType::ABSOLUTE, double tol_in=1.0e-6)
Constructors for real number comparisons based on a vector of multiple input values....
Class for handling comparisons of floating-point results versus expected values in unit tests....
Definition approx.h:23
Approx margin(double dtol_in) const
Set the tolerance. This is written in such a way as to mimic the Catch2 unit testing framework in som...
Definition approx.cpp:97
void setValue(double value_in)
Set the values that form the basis of the approximate comparison.
Definition approx.cpp:61
bool test(const double test_value) const
Test whether a real-valued scalar is the same as the value held for comparison.
Definition approx.cpp:112
~Approx()=default
Default destructor.
int size() const
Get the size of the collection of numbers in a real number comparison.
Definition approx.cpp:19
double getMargin() const
Get the margin or tolerance associated with this approximate comparison.
Definition approx.cpp:46
Approx(const std::vector< T > &values_in, ComparisonType style_in=ComparisonType::ABSOLUTE, double tol_in=1.0e-6)
Constructors for real number comparisons based on a vector of multiple input values....
double getValue() const
Get the expectation value, sans any tolerance.
Definition approx.cpp:24
bool test(const std::vector< T > &test_values) const
Test whether a vector of real-valued scalars is the same as as vector held for comparison.
void setMargin(double dtol_in)
Set the tolerance of the existing object. This will not emit a new object.
Definition approx.cpp:82
ComparisonType getStyle() const
Get the style used in this approximate comparison.
Definition approx.cpp:41
std::vector< double > getValues() const
Get all values of an approximate comparison, sans any tolerance.
Definition approx.cpp:36