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

Function TEST

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

Source from the content-addressed store, hash-verified

2#include <fpm/math.hpp>
3
4TEST(trigonometry, sin)
5{
6 using P = fpm::fixed<std::int32_t, std::int64_t, 16>;
7 const double PI = std::acos(-1);
8
9 constexpr auto MAX_ERROR_PERC = 0.002;
10
11 for (int angle = -1799; angle <= 1800; ++angle)
12 {
13 auto flt_angle = angle * PI / 180;
14 auto sin_real = std::sin(flt_angle);
15 auto sin_fixed = static_cast<double>(sin(P(flt_angle)));
16 EXPECT_TRUE(HasMaximumError(sin_fixed, sin_real, MAX_ERROR_PERC));
17 }
18}
19
20TEST(trigonometry, cos)
21{

Callers

nothing calls this directly

Calls 8

HasMaximumErrorFunction · 0.85
acosFunction · 0.50
sinFunction · 0.50
cosFunction · 0.50
tanFunction · 0.50
atanFunction · 0.50
asinFunction · 0.50
atan2Function · 0.50

Tested by

no test coverage detected