MCPcopy Index your code
hub / github.com/HandmadeMath/HandmadeMath / TEST

Function TEST

test/categories/ScalarMath.h:3–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "../HandmadeTest.h"
2
3TEST(ScalarMath, Trigonometry)
4{
5 // We have to be a little looser with our equality constraint
6 // because of floating-point precision issues.
7 const float trigAbsError = 0.0001f;
8
9 EXPECT_NEAR(HMM_SinF(0.0f), 0.0f, trigAbsError);
10 EXPECT_NEAR(HMM_SinF(HMM_PI32 / 2), 1.0f, trigAbsError);
11 EXPECT_NEAR(HMM_SinF(HMM_PI32), 0.0f, trigAbsError);
12 EXPECT_NEAR(HMM_SinF(3 * HMM_PI32 / 2), -1.0f, trigAbsError);
13 EXPECT_NEAR(HMM_SinF(-HMM_PI32 / 2), -1.0f, trigAbsError);
14
15 EXPECT_NEAR(HMM_CosF(0.0f), 1.0f, trigAbsError);
16 EXPECT_NEAR(HMM_CosF(HMM_PI32 / 2), 0.0f, trigAbsError);
17 EXPECT_NEAR(HMM_CosF(HMM_PI32), -1.0f, trigAbsError);
18 EXPECT_NEAR(HMM_CosF(3 * HMM_PI32 / 2), 0.0f, trigAbsError);
19 EXPECT_NEAR(HMM_CosF(-HMM_PI32), -1.0f, trigAbsError);
20
21 EXPECT_NEAR(HMM_TanF(0.0f), 0.0f, trigAbsError);
22 EXPECT_NEAR(HMM_TanF(HMM_PI32 / 4), 1.0f, trigAbsError);
23 EXPECT_NEAR(HMM_TanF(3 * HMM_PI32 / 4), -1.0f, trigAbsError);
24 EXPECT_NEAR(HMM_TanF(HMM_PI32), 0.0f, trigAbsError);
25 EXPECT_NEAR(HMM_TanF(-HMM_PI32 / 4), -1.0f, trigAbsError);
26
27 // This isn't the most rigorous because we're really just sanity-
28 // checking that things work by default.
29}
30
31TEST(ScalarMath, SquareRoot)
32{

Callers

nothing calls this directly

Calls 7

HMM_SinFFunction · 0.85
HMM_CosFFunction · 0.85
HMM_TanFFunction · 0.85
HMM_SqrtFFunction · 0.85
HMM_InvSqrtFFunction · 0.85
HMM_LerpFunction · 0.85
HMM_ClampFunction · 0.85

Tested by

no test coverage detected