|
|
|
|
@ -57,6 +57,19 @@ namespace fuc2 { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ALMOST_EQUAL(auto v1, auto v2, int decimal_places, const std::string &message="", |
|
|
|
|
const std::source_location location = std::source_location::current()) |
|
|
|
|
{ |
|
|
|
|
double multiplier = std::pow(10.0, decimal_places); |
|
|
|
|
auto r_v1 = std::round(v1 * multiplier) / multiplier; |
|
|
|
|
auto r_v2 = std::round(v2 * multiplier) / multiplier; |
|
|
|
|
|
|
|
|
|
if(r_v1 != r_v2) { |
|
|
|
|
auto test_value = fmt::format("{} != {} rounded {} places {} != {}", v1, v2, decimal_places, r_v1, r_v2); |
|
|
|
|
throw std::runtime_error(craft_error("ALMOST_EQUAL", test_value, message, location)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void BLOWS_UP(std::function<void()> cb, const std::string &message="", |
|
|
|
|
const std::source_location location = std::source_location::current()); |
|
|
|
|
} |
|
|
|
|
|