OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_key_dx_expression_unit_tests.hpp
1 /*
2  * grid_key_dx_expression_unit_tests.hpp
3  *
4  * Created on: Jun 21, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef GRID_KEY_DX_EXPRESSION_UNIT_TESTS_HPP_
9 #define GRID_KEY_DX_EXPRESSION_UNIT_TESTS_HPP_
10 
11 #include "Grid/grid_key.hpp"
12 
13 BOOST_AUTO_TEST_SUITE( grid_expression_test )
14 
15 
16 BOOST_AUTO_TEST_CASE( grid_expression_use)
17 {
18  const grid_key_dx<3> key1(1,2,3);
19  const comb<3> c({1,0,-1});
20  const grid_key_dx<3> key2(4,5,6);
21  const grid_key_dx<3> key3(12,11,10);
22 
23  grid_key_dx<3> res2 = key3 + key2;
24 
25  BOOST_REQUIRE_EQUAL(res2.get(0),16);
26  BOOST_REQUIRE_EQUAL(res2.get(1),16);
27  BOOST_REQUIRE_EQUAL(res2.get(2),16);
28 
29  grid_key_dx<3> res = key3 + c - key2;
30 
31  BOOST_REQUIRE_EQUAL(res.get(0),3);
32  BOOST_REQUIRE_EQUAL(res.get(1),6);
33  BOOST_REQUIRE_EQUAL(res.get(2),9);
34 
35  res = res - res;
36 
37  BOOST_REQUIRE_EQUAL(res.get(0),0);
38  BOOST_REQUIRE_EQUAL(res.get(1),0);
39  BOOST_REQUIRE_EQUAL(res.get(2),0);
40 
41  const Point<3,long int> p({1,2,3});
42 
43  res = res + p;
44 
45  BOOST_REQUIRE_EQUAL(res.get(0),1);
46  BOOST_REQUIRE_EQUAL(res.get(1),2);
47  BOOST_REQUIRE_EQUAL(res.get(2),3);
48 }
49 
50 BOOST_AUTO_TEST_SUITE_END()
51 
52 #endif /* GRID_KEY_DX_EXPRESSION_UNIT_TESTS_HPP_ */
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:394