MCPcopy Create free account
hub / github.com/MikeLankamp/fpm / TEST

Function TEST

tests/power.cpp:4–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <fpm/math.hpp>
3
4TEST(power, exp)
5{
6 // For several values, verify that fpm::exp is close to std::exp.
7 using P = fpm::fixed<std::int32_t, std::int64_t, 12>;
8
9 // Maximum relative error (percentage) we allow
10 constexpr auto MAX_ERROR_PERC = 0.02;
11
12 for (double value = -5; value <= 5; value += 0.1)
13 {
14 auto exp_real = std::exp(value);
15 auto exp_fixed = static_cast<double>(exp(P(value)));
16 EXPECT_TRUE(HasMaximumError(exp_fixed, exp_real, MAX_ERROR_PERC));
17 }
18}
19
20TEST(power, exp2)
21{

Callers

nothing calls this directly

Calls 11

HasMaximumErrorFunction · 0.85
exp2Function · 0.85
expm1Function · 0.85
log10Function · 0.85
log1pFunction · 0.85
powFunction · 0.85
cbrtFunction · 0.85
expFunction · 0.50
logFunction · 0.50
log2Function · 0.50
sqrtFunction · 0.50

Tested by

no test coverage detected