8 #ifndef SRC_PACKER_UNIT_TESTS_HPP_
9 #define SRC_PACKER_UNIT_TESTS_HPP_
11 #include "Pack_selector.hpp"
13 #include "Unpacker.hpp"
14 #include "Grid/grid_util_test.hpp"
16 #include "Vector/vector_test_util.hpp"
17 #include "data_type/aggregate.hpp"
19 BOOST_AUTO_TEST_SUITE( packer_unpacker )
21 BOOST_AUTO_TEST_CASE ( packer_unpacker_test )
26 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
28 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
30 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
32 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
34 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
36 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
38 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
40 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
42 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
44 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
47 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
51 BOOST_REQUIRE_EQUAL(val,PACKER_GENERAL);
53 BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
55 BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
62 static bool noPointers() {
return true;}
66 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
80 unsigned short us = 4;
84 unsigned long int uli = 8;
93 size_t sz[] = {16,16,16};
104 size_t size_total = 0;
105 size_t size_total_old = 0;
108 BOOST_REQUIRE_EQUAL(size_total,
sizeof(
unsigned char));
109 size_total_old = size_total;
112 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
char));
113 size_total_old = size_total;
116 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
short));
117 size_total_old = size_total;
120 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
unsigned short));
121 size_total_old = size_total;
124 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
int));
125 size_total_old = size_total;
128 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
unsigned int));
129 size_total_old = size_total;
132 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
long int));
133 size_total_old = size_total;
136 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
long unsigned int));
137 size_total_old = size_total;
140 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
float));
141 size_total_old = size_total;
144 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
double));
145 size_total_old = size_total;
150 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float)*4 +
sizeof(
float[3]) +
sizeof(
float[3][3])));
152 size_total_old = size_total;
156 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float) +
sizeof(
float[3])) * v.size() +
sizeof(v.size()));
158 size_total_old = size_total;
162 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float) +
sizeof(
float[3])) * sub.getVolume());
169 pmem.allocate(size_total);
210 unsigned long int uli2;
223 v_test.resize(v.size());
228 BOOST_REQUIRE_EQUAL(uc2,uc);
229 BOOST_REQUIRE_EQUAL(c2,c);
230 BOOST_REQUIRE_EQUAL(s2,s);
231 BOOST_REQUIRE_EQUAL(us2,us);
232 BOOST_REQUIRE_EQUAL(i2,i);
233 BOOST_REQUIRE_EQUAL(ui2,ui);
234 BOOST_REQUIRE_EQUAL(li2,li);
235 BOOST_REQUIRE_EQUAL(uli2,uli);
236 BOOST_REQUIRE_EQUAL(f2,f);
237 BOOST_REQUIRE_EQUAL(d2,d);
239 bool val = (p_test == p);
240 BOOST_REQUIRE_EQUAL(
true,val);
242 auto it = v_test.getIterator();
246 float f1 = v_test.template get<pt::x>(it.get());
247 float f2 = v.template get<pt::x>(it.get());
249 BOOST_REQUIRE_EQUAL(f1,f2);
251 for (
size_t i = 0 ; i < 3 ; i++)
253 f1 = v_test.template get<pt::v>(it.get())[i];
254 f2 = v.template get<pt::v>(it.get())[i];
256 BOOST_REQUIRE_EQUAL(f1,f2);
264 size_t sz2[] = {16,16,16};
277 float f1 = g_test.template get<pt::x>(sub2.
get());
278 float f2 = g.template get<pt::x>(sub2.
get());
280 BOOST_REQUIRE_EQUAL(f1,f2);
282 for (
size_t i = 0 ; i < 3 ; i++)
284 f1 = g_test.template get<pt::v>(sub2.
get())[i];
285 f2 = g.template get<pt::v>(sub2.
get())[i];
287 BOOST_REQUIRE_EQUAL(f1,f2);
302 BOOST_AUTO_TEST_SUITE_END()
Transform the boost::fusion::vector into memory specification (memory_traits)
This class allocate, and destroy CPU memory.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
virtual void incRef()
Increment the reference counter.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
Declaration grid_key_dx_iterator_sub.
Test structure used for several test.
void reset()
Reset the iterator (it restart from the beginning)
Implementation of 1-D std::vector like structure.
bool isNext()
Check if there is the next element.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.