OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Point_test_unit_tests.hpp
1/*
2 * Point_test_unit_tests.hpp
3 *
4 * Created on: Jun 20, 2015
5 * Author: i-bird
6 */
7
8#ifndef POINT_TEST_UNIT_TESTS_HPP_
9#define POINT_TEST_UNIT_TESTS_HPP_
10
11#include "Point_test.hpp"
12
13BOOST_AUTO_TEST_SUITE( Point_test_unit_tests )
14
15BOOST_AUTO_TEST_CASE( Point_test_unit_tests )
16{
17 typedef Point_test<float> P;
18
20
21 // fill the point p with data
22
23 p.setx(1.0);
24 p.sety(2.0);
25 p.setz(3.0);
26 p.sets(4.0);
27
28 p.template get<P::v>()[0] = 5.0;
29 p.template get<P::v>()[1] = 6.0;
30 p.template get<P::v>()[2] = 7.0;
31
32 p.template get<P::t>()[0][0] = 8.0;
33 p.template get<P::t>()[0][1] = 9.0;
34 p.template get<P::t>()[0][2] = 10.0;
35 p.template get<P::t>()[1][0] = 11.0;
36 p.template get<P::t>()[1][1] = 12.0;
37 p.template get<P::t>()[1][2] = 13.0;
38 p.template get<P::t>()[2][0] = 14.0;
39 p.template get<P::t>()[2][1] = 15.0;
40 p.template get<P::t>()[2][2] = 16.0;
41
42 BOOST_REQUIRE_EQUAL(p.template get<P::x>(),1.0);
43 BOOST_REQUIRE_EQUAL(p.template get<P::y>(),2.0);
44 BOOST_REQUIRE_EQUAL(p.template get<P::z>(),3.0);
45 BOOST_REQUIRE_EQUAL(p.template get<P::s>(),4.0);
46
47 BOOST_REQUIRE_EQUAL(p.template get<P::v>()[0],5.0);
48 BOOST_REQUIRE_EQUAL(p.template get<P::v>()[1],6.0);
49 BOOST_REQUIRE_EQUAL(p.template get<P::v>()[2],7.0);
50
51 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[0][0],8.0);
52 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[0][1],9.0);
53 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[0][2],10.0);
54 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[1][0],11.0);
55 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[1][1],12.0);
56 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[1][2],13.0);
57 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[2][0],14.0);
58 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[2][1],15.0);
59 BOOST_REQUIRE_EQUAL(p.template get<P::t>()[2][2],16.0);
60
61 // operator equal
62 Point_test<float> p2 = p;
63
64 BOOST_REQUIRE_EQUAL(p2.template get<P::x>(),1.0);
65 BOOST_REQUIRE_EQUAL(p2.template get<P::y>(),2.0);
66 BOOST_REQUIRE_EQUAL(p2.template get<P::z>(),3.0);
67 BOOST_REQUIRE_EQUAL(p2.template get<P::s>(),4.0);
68
69 BOOST_REQUIRE_EQUAL(p2.template get<P::v>()[0],5.0);
70 BOOST_REQUIRE_EQUAL(p2.template get<P::v>()[1],6.0);
71 BOOST_REQUIRE_EQUAL(p2.template get<P::v>()[2],7.0);
72
73 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[0][0],8.0);
74 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[0][1],9.0);
75 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[0][2],10.0);
76 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[1][0],11.0);
77 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[1][1],12.0);
78 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[1][2],13.0);
79 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[2][0],14.0);
80 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[2][1],15.0);
81 BOOST_REQUIRE_EQUAL(p2.template get<P::t>()[2][2],16.0);
82
83 // equal from vector
84
85/* openfpm::vector<Point_test<float>> v;
86
87 v.add(p);
88
89 Point_test<float> p3;
90
91 p3 = v.get(0);
92
93 BOOST_REQUIRE_EQUAL(p3.template get<P::x>(),1.0);
94 BOOST_REQUIRE_EQUAL(p3.template get<P::y>(),2.0);
95 BOOST_REQUIRE_EQUAL(p3.template get<P::z>(),3.0);
96 BOOST_REQUIRE_EQUAL(p3.template get<P::s>(),4.0);
97
98 BOOST_REQUIRE_EQUAL(p3.template get<P::v>()[0],5.0);
99 BOOST_REQUIRE_EQUAL(p3.template get<P::v>()[1],6.0);
100 BOOST_REQUIRE_EQUAL(p3.template get<P::v>()[2],7.0);
101
102 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[0][0],8.0);
103 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[0][1],9.0);
104 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[0][2],10.0);
105 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[1][0],11.0);
106 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[1][1],12.0);
107 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[1][2],13.0);
108 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[2][0],14.0);
109 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[2][1],15.0);
110 BOOST_REQUIRE_EQUAL(p3.template get<P::t>()[2][2],16.0);*/
111}
112
113BOOST_AUTO_TEST_SUITE_END()
114
115#endif /* POINT_TEST_UNIT_TESTS_HPP_ */
Test structure used for several test.
void sety(T y_)
set the y property
void setz(T z_)
set the z property
void sets(T s_)
set the s property
void setx(T x_)
set the x property