Tetrapod Project
test_angle_utils.cpp
Go to the documentation of this file.
1 // API for testing
3 
4 // gtest
5 #include <gtest/gtest.h>
6 
7 
8 // Declare tests
9 TEST(AngleUtils, constants)
10 {
11  EXPECT_DOUBLE_EQ(boost::math::constants::pi<double>(), math_utils::PI);
12  EXPECT_DOUBLE_EQ(2*boost::math::constants::pi<double>(), 2*math_utils::PI);
13  EXPECT_NEAR(3.1415926, math_utils::PI, 0.0000001);
14 }
15 
16 TEST(AngleUtils, conversions)
17 {
18  EXPECT_DOUBLE_EQ(math_utils::TWO_PI, math_utils::degToRad(360));
19  EXPECT_DOUBLE_EQ(3*math_utils::PI, math_utils::degToRad(540));
20  EXPECT_DOUBLE_EQ(180, math_utils::radToDeg(math_utils::PI));
21  EXPECT_DOUBLE_EQ(360, math_utils::radToDeg(math_utils::TWO_PI));
22 }
23 
24 TEST(AngleUtils, wrappers)
25 {
26  EXPECT_DOUBLE_EQ(0, math_utils::wrapAngleTo2Pi(-math_utils::TWO_PI));
29  EXPECT_DOUBLE_EQ(0, math_utils::wrapAngleTo2Pi(4*math_utils::PI));
30 
31  EXPECT_DOUBLE_EQ(0, math_utils::wrapAngleToPi(2*math_utils::PI));
35 
36  EXPECT_DOUBLE_EQ(0, math_utils::angleDiff(math_utils::PI,-3*math_utils::PI));
39 
40 }
41 
42 // Run all the tests that were declared with TEST()
43 int main(int argc, char **argv)
44 {
45  testing::InitGoogleTest(&argc, argv);
46  return RUN_ALL_TESTS();
47 }
static constexpr double HALF_PI
Define PI/2.
Definition: angle_utils.h:53
double wrapAngleToPi(const double &_rad)
The wrapAngleToPi function wraps an input angle to the interval [-pi, pi).
Definition: angle_utils.cpp:45
double degToRad(const double &_deg)
The degToRad function converts degrees to radians.
Definition: angle_utils.cpp:33
double angleDiff(const double &_ang1, const double &_ang2)
The angleDiff function returns the difference in angle between two given angles in the interval [0,...
Definition: angle_utils.cpp:72
static constexpr double THREE_QUARTERS_PI
Define 3PI/4.
Definition: angle_utils.h:47
double radToDeg(const double &_rad)
The radToDeg function converts radians to degrees.
Definition: angle_utils.cpp:39
static constexpr double TWO_PI
Define 2PI.
Definition: angle_utils.h:38
static constexpr double PI
Define PI.
Definition: angle_utils.h:44
double wrapAngleTo2Pi(const double &_rad)
The wrapAngleTo2Pi function wraps an input angle to the interval [0, 2pi).
Definition: angle_utils.cpp:59
int main(int argc, char **argv)
TEST(AngleUtils, constants)