$search
00001 00009 /***************************************************************************** 00010 ** Includes 00011 *****************************************************************************/ 00012 00013 #include <gtest/gtest.h> 00014 #include "../../include/ecl/geometry/cartesian_point.hpp" 00015 00016 /***************************************************************************** 00017 ** Using 00018 *****************************************************************************/ 00019 00020 using ecl::linear_algebra::Vector3d; 00021 using ecl::CartesianPoint; 00022 using ecl::CartesianPoint3d; 00023 00024 /***************************************************************************** 00025 ** Tests 00026 *****************************************************************************/ 00027 00028 TEST(CartesianPointTests,construct) { 00029 CartesianPoint3d point(0.1,0.2,0.3); 00030 EXPECT_EQ(0.1,point.x()); 00031 EXPECT_EQ(0.2,point.y()); 00032 EXPECT_EQ(0.3,point.z()); 00033 Vector3d v; v << 0.1, 0.2, 0.3; 00034 CartesianPoint3d p2(v); 00035 EXPECT_EQ(0.1,p2.x()); 00036 EXPECT_EQ(0.2,p2.y()); 00037 EXPECT_EQ(0.3,p2.z()); 00038 } 00039 00040 TEST(CartesianPointTests,assignment) { 00041 CartesianPoint3d point; 00042 point << 1.0, 2.0, 3.0; 00043 EXPECT_EQ(1.0,point.x()); 00044 EXPECT_EQ(2.0,point.y()); 00045 EXPECT_EQ(3.0,point.z()); 00046 point.x(1.0); 00047 point.y(2.0); 00048 point.z(3.0); 00049 EXPECT_EQ(1.0,point.x()); 00050 EXPECT_EQ(2.0,point.y()); 00051 EXPECT_EQ(3.0,point.z()); 00052 Vector3d v; v << 1.0, 2.0, 3.0; 00053 point = v; 00054 EXPECT_EQ(1.0,point.x()); 00055 EXPECT_EQ(2.0,point.y()); 00056 EXPECT_EQ(3.0,point.z()); 00057 } 00058 00059 TEST(CartesianPointTests,vectorHandle) { 00060 CartesianPoint3d point; 00061 point << 1.0, 2.0, 3.0; 00062 const Vector3d& v = point.positionVector(); 00063 EXPECT_EQ(1.0,v[0]); 00064 EXPECT_EQ(2.0,v[1]); 00065 EXPECT_EQ(3.0,v[2]); 00066 } 00067 00068 TEST(CartesianPointTests,constAccessors) { 00069 CartesianPoint3d point; 00070 point << 1.0, 2.0, 3.0; 00071 const int cx = point.x(); 00072 const int cy = point.y(); 00073 const int cz = point.z(); 00074 EXPECT_EQ(1.0,cx); 00075 EXPECT_EQ(2.0,cy); 00076 EXPECT_EQ(3.0,cz); 00077 } 00078 00079 /***************************************************************************** 00080 ** Main program 00081 *****************************************************************************/ 00082 00083 int main(int argc, char **argv) { 00084 00085 testing::InitGoogleTest(&argc,argv); 00086 return RUN_ALL_TESTS(); 00087 } 00088 00089