angles.cpp
Go to the documentation of this file.
00001 
00011 /*****************************************************************************
00012 ** Includes
00013 *****************************************************************************/
00014 
00015 #include <gtest/gtest.h>
00016 #include <ecl/math/constants.hpp>
00017 #include "../../include/ecl/geometry/angle.hpp"
00018 
00019 /*****************************************************************************
00020 ** Using
00021 *****************************************************************************/
00022 
00023 using ecl::pi;
00024 using ecl::Angle;
00025 using ecl::wrap_angle;
00026 
00027 /*****************************************************************************
00028 ** Tests
00029 *****************************************************************************/
00030 
00031 TEST(AngleTests,setters) {
00032     Angle<double> angle;
00033     double d = angle; // default
00034     EXPECT_EQ(0.0,d);
00035     angle = Angle<double>::Degrees(45.0);
00036     d = angle;
00037     EXPECT_GT(0.786,d); // Allow some roundoff error here
00038     EXPECT_LT(0.785,d);
00039     angle = Angle<double>::Radians(0.3);
00040     d = angle;
00041     EXPECT_EQ(0.3,d);
00042     Angle<float> angle_f;
00043     float f = angle_f; // default
00044     EXPECT_EQ(0.0,f);
00045     angle_f = Angle<float>::Degrees(45.0);
00046     f = angle_f;
00047     EXPECT_GT(0.786,f); // Allow some roundoff error here
00048     EXPECT_LT(0.785,f);
00049     angle_f = Angle<float>::Radians(0.3);
00050     f = angle_f;
00051     EXPECT_EQ(0.3,d);
00052 }
00053 
00054 TEST(AngleTests,conversions) {
00055     Angle<double> angle(0.3);
00056     double d = angle.degrees();
00057     EXPECT_GT(17.19,d); // Allow some roundoff error here
00058     EXPECT_LT(17.18,d);
00059     Angle<float> angle_f(0.3);
00060     float f = angle.degrees();
00061     EXPECT_GT(17.19,f); // Allow some roundoff error here
00062     EXPECT_LT(17.18,f);
00063 }
00064 
00065 TEST(AngleTests,wrap) {
00066         double angle = 2*pi+0.1;
00067     wrap_angle(angle);
00068     EXPECT_GT(0.11,angle); // Allow some roundoff error here
00069     EXPECT_LT(0.09,angle);
00070         angle = 2*pi+0.1;
00071     double wa = wrap_angle(angle);
00072     EXPECT_GT(0.11,wa); // Allow some roundoff error here
00073     EXPECT_LT(0.09,wa);
00074         float angle_f = 2*pi+0.1;
00075     wrap_angle(angle_f);
00076     EXPECT_GT(0.11,angle_f); // Allow some roundoff error here
00077     EXPECT_LT(0.09,angle_f);
00078         angle_f = 2*pi+0.1;
00079     float wa_f = wrap_angle(angle_f);
00080     EXPECT_GT(0.11,wa_f); // Allow some roundoff error here
00081     EXPECT_LT(0.09,wa_f);
00082 }
00083 
00084 TEST(AngleTests,assignment) {
00085     Angle<double> angle;
00086     angle = 0.3;
00087     double d = angle;
00088     EXPECT_GT(0.31,d); // Allow some roundoff error here
00089     EXPECT_LT(0.29,d);
00090     Angle<float> angle_f;
00091     angle_f = 0.3;
00092     float f = angle_f;
00093     EXPECT_GT(0.31,f); // Allow some roundoff error here
00094     EXPECT_LT(0.29,f);
00095 }
00096 
00097 // operator tests
00098 
00099 /*****************************************************************************
00100 ** Main program
00101 *****************************************************************************/
00102 
00103 int main(int argc, char **argv) {
00104 
00105     testing::InitGoogleTest(&argc,argv);
00106     return RUN_ALL_TESTS();
00107 }
00108 
00109 


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:46