cartesian_points.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/geometry/cartesian_point.hpp"
15 
16 /*****************************************************************************
17 ** Using
18 *****************************************************************************/
19 
20 using ecl::linear_algebra::Vector3d;
23 
24 /*****************************************************************************
25 ** Tests
26 *****************************************************************************/
27 
28 TEST(CartesianPointTests,construct) {
29  CartesianPoint3d point(0.1,0.2,0.3);
30  EXPECT_EQ(0.1,point.x());
31  EXPECT_EQ(0.2,point.y());
32  EXPECT_EQ(0.3,point.z());
33  Vector3d v; v << 0.1, 0.2, 0.3;
34  CartesianPoint3d p2(v);
35  EXPECT_EQ(0.1,p2.x());
36  EXPECT_EQ(0.2,p2.y());
37  EXPECT_EQ(0.3,p2.z());
38 }
39 
40 TEST(CartesianPointTests,assignment) {
41  CartesianPoint3d point;
42  point << 1.0, 2.0, 3.0;
43  EXPECT_EQ(1.0,point.x());
44  EXPECT_EQ(2.0,point.y());
45  EXPECT_EQ(3.0,point.z());
46  point.x(1.0);
47  point.y(2.0);
48  point.z(3.0);
49  EXPECT_EQ(1.0,point.x());
50  EXPECT_EQ(2.0,point.y());
51  EXPECT_EQ(3.0,point.z());
52  Vector3d v; v << 1.0, 2.0, 3.0;
53  point = v;
54  EXPECT_EQ(1.0,point.x());
55  EXPECT_EQ(2.0,point.y());
56  EXPECT_EQ(3.0,point.z());
57 }
58 
59 TEST(CartesianPointTests,vectorHandle) {
60  CartesianPoint3d point;
61  point << 1.0, 2.0, 3.0;
62  const Vector3d& v = point.positionVector();
63  EXPECT_EQ(1.0,v[0]);
64  EXPECT_EQ(2.0,v[1]);
65  EXPECT_EQ(3.0,v[2]);
66 }
67 
68 TEST(CartesianPointTests,constAccessors) {
69  CartesianPoint3d point;
70  point << 1.0, 2.0, 3.0;
71  const int cx = point.x();
72  const int cy = point.y();
73  const int cz = point.z();
74  EXPECT_EQ(1.0,cx);
75  EXPECT_EQ(2.0,cy);
76  EXPECT_EQ(3.0,cz);
77 }
78 
79 /*****************************************************************************
80 ** Main program
81 *****************************************************************************/
82 
83 int main(int argc, char **argv) {
84 
85  testing::InitGoogleTest(&argc,argv);
86  return RUN_ALL_TESTS();
87 }
88 
89 
CartesianPoint< double, 3 > CartesianPoint3d
Eigen style convenience handle for x, y, z triples in double format.
TEST(CartesianPointTests, construct)
int main(int argc, char **argv)
Generic container storing a cartesian point of dimension N.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37