MathLib
Loading...
Searching...
No Matches
TestAngle.cpp
Go to the documentation of this file.
1#include <Math/math/Angle.hpp>
2#include <cassert>
3#include <iostream>
4#include <numbers>
5#include <cstdlib>
6
7
8namespace AngleTests
9{
10
11using namespace Math;
12using namespace Math::Literals;
13
14constexpr double PI = std::numbers::pi;
15constexpr double PI_2 = std::numbers::pi / 2.0;
16constexpr double PI_4 = std::numbers::pi / 4.0;
17
18void FunctionThatPrintsInput(Degreef input)
19{
20
21 std::cout << "You passed in a variable designating " << input.value() << " Degrees" << std::endl;
22}
23
24void TestFunctionTakingRadian(Radianf input)
25{
26 std::cout << "You passed in a variable designating " << input.value() << " Radians" << std::endl;
28}
29
31{
32 std::cout << __func__ << std::endl;
33
34 TestFunctionTakingRadian(90.0_deg_f);
35 TestFunctionTakingRadian( Degreef(45.0f) );
36 TestFunctionTakingRadian( Radianf{std::numbers::pi_v<float>} );
37}
38
40{
41 // Float
42 {
43 Degreef a = 32.0_deg_f;
44 Degreef b = 32.0_deg_F;
45 Degreef c = 32.0_degf;
46 Degreef d = 32.0_degF;
47
48 assert( a == 32.0f );
49 assert( b == 32.0f );
50 assert( c == 32.0f );
51 assert( d == 32.0f );
52 }
53
54 // Double
55 {
56 Degree a = 32.0_deg;
57 Degreed b = 32.0_deg;
58
59 assert( a == 32.0 );
60 assert( b == 32.0 );
61 }
62
63 // Long Double
64 {
65 Degreel a = 32.0_deg_l;
66 Degreel b = 32.0_deg_L;
67 Degreel c = 32.0_degl;
68 Degreel d = 32.0_degL;
69
70 assert( a == 32.0l );
71 assert( b == 32.0l );
72 assert( c == 32.0l );
73 assert( d == 32.0l );
74 }
75}
76
78{
79 Radian a = 0.0_rad;
80 Radian b = a;
81 Radian c{ std::numbers::pi_v<double> / 2.0 };
82 Radian d{ -(std::numbers::pi_v<double> / 2.0) };
83
84 assert( a == b );
85 assert( a == 0.0 );
86 assert( 0.0 == a );
87 assert( a == b.value() );
88 assert( a != c );
89 assert( a != (std::numbers::pi_v<double> / 2.0) );
90 assert( (std::numbers::pi_v<double> / 2.0) != a );
91
92 assert( d < b );
93 assert( d < 0.0 );
94 assert( !(b < d) ); // check that the NOT of the operator holds
95
96 assert( d <= d );
97 assert( d <= -(std::numbers::pi_v<double> / 2.0) );
98
99 assert( c > b );
100 assert( c > 0.0 );
101 assert( !(b > c) ); // check that the NOT of the operator holds
102
103 assert( c >= c );
104 assert( c >= (std::numbers::pi_v<double> / 2.0) );
105 assert( c >= d );
106}
107
108void Run()
109{
110 std::cout << "Running Angle Tests..." << std::endl;
111
112 CommonUsage();
115
116 std::cout << "PASSED!" << std::endl;
117}
118
119}
120
121int main(void)
122{
124 return EXIT_SUCCESS;
125}
int main(void)
void FunctionThatPrintsInput(Degreef input)
Definition TestAngle.cpp:18
void CommonUsage()
Definition TestAngle.cpp:30
constexpr double PI
Definition TestAngle.cpp:14
void UsingUserDefinedLiterals()
Definition TestAngle.cpp:39
constexpr double PI_2
Definition TestAngle.cpp:15
constexpr double PI_4
Definition TestAngle.cpp:16
void TestFunctionTakingRadian(Radianf input)
Definition TestAngle.cpp:24
void RadianHasAllComparisonOperators()
Definition TestAngle.cpp:77
Definition Angle.hpp:16