Move Approx's validity checks out of line into cpp file
This avoids having to include <stdexcept> in the main include path and speeds up the compilation if Approx is used with multiple different types.
This commit is contained in:
parent
fcd91c7d6b
commit
84fa76e985
2 changed files with 31 additions and 17 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -54,6 +55,27 @@ namespace Detail {
|
|||
return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value)));
|
||||
}
|
||||
|
||||
void Approx::setMargin(double margin) {
|
||||
if (margin < 0) {
|
||||
throw std::domain_error
|
||||
("Invalid Approx::margin: " +
|
||||
Catch::Detail::stringify(margin) +
|
||||
", Approx::Margin has to be non-negative.");
|
||||
|
||||
}
|
||||
m_margin = margin;
|
||||
}
|
||||
|
||||
void Approx::setEpsilon(double epsilon) {
|
||||
if (epsilon < 0 || epsilon > 1.0) {
|
||||
throw std::domain_error
|
||||
("Invalid Approx::epsilon: " +
|
||||
Catch::Detail::stringify(epsilon) +
|
||||
", Approx::epsilon has to be between 0 and 1");
|
||||
}
|
||||
m_epsilon = epsilon;
|
||||
}
|
||||
|
||||
} // end namespace Detail
|
||||
|
||||
namespace literals {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue