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"
18 BOOST_AUTO_TEST_SUITE( packer_unpacker )
20 BOOST_AUTO_TEST_CASE ( packer_unpacker_test )
25 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
27 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
29 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
31 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
33 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
35 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
37 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
39 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
41 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
43 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
46 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
50 BOOST_REQUIRE_EQUAL(val,PACKER_VECTOR);
52 BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
54 BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
61 static bool noPointers() {
return true;}
65 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
79 unsigned short us = 4;
83 unsigned long int uli = 8;
92 size_t sz[] = {16,16,16};
100 std::vector<size_t> pap_prp;
103 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(
unsigned char));
105 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(char));
107 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(short));
109 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(
unsigned short));
111 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(int));
113 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(
unsigned int));
115 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(
long int));
117 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(
long unsigned int));
119 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(float));
121 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(double));
124 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],(
sizeof(float) +
sizeof(
float[3])) * v.size());
126 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],(
sizeof(float) +
sizeof(
float[3])) * sub.getVolume());
129 size_t req = ExtPreAlloc<HeapMemory>::calculateMem(pap_prp);
134 ExtPreAlloc<HeapMemory> & mem = *(
new ExtPreAlloc<HeapMemory>(pap_prp,pmem));
152 Packer<grid_cpu<3,Point_test<float>>,HeapMemory>::pack<pt::x,pt::v>(mem,g,sub,sts);
174 unsigned long int uli2;
187 v_test.resize(v.size());
192 BOOST_REQUIRE_EQUAL(uc2,uc);
193 BOOST_REQUIRE_EQUAL(c2,c);
194 BOOST_REQUIRE_EQUAL(s2,s);
195 BOOST_REQUIRE_EQUAL(us2,us);
196 BOOST_REQUIRE_EQUAL(i2,i);
197 BOOST_REQUIRE_EQUAL(ui2,ui);
198 BOOST_REQUIRE_EQUAL(li2,li);
199 BOOST_REQUIRE_EQUAL(uli2,uli);
200 BOOST_REQUIRE_EQUAL(f2,f);
201 BOOST_REQUIRE_EQUAL(d2,d);
203 bool val = (p_test == p);
204 BOOST_REQUIRE_EQUAL(
true,val);
206 auto it = v_test.getIterator();
210 float f1 = v_test.template get<pt::x>(it.get());
211 float f2 = v.template get<pt::x>(it.get());
213 BOOST_REQUIRE_EQUAL(f1,f2);
215 for (
size_t i = 0 ; i < 3 ; i++)
217 f1 = v_test.template get<pt::v>(it.get())[i];
218 f2 = v.template get<pt::v>(it.get())[i];
220 BOOST_REQUIRE_EQUAL(f1,f2);
228 size_t sz2[] = {16,16,16};
240 float f1 = g_test.template get<pt::x>(sub2.
get());
241 float f2 = g.template get<pt::x>(sub2.
get());
243 BOOST_REQUIRE_EQUAL(f1,f2);
245 for (
size_t i = 0 ; i < 3 ; i++)
247 f1 = g_test.template get<pt::v>(sub2.
get())[i];
248 f2 = g.template get<pt::v>(sub2.
get())[i];
250 BOOST_REQUIRE_EQUAL(f1,f2);
265 BOOST_AUTO_TEST_SUITE_END()
Transform the boost::fusion::vector into memory specification (memory_traits)
bool isNext()
Check if there is the next element.
static size_t packRequest(std::vector< size_t > &req)
Error, no implementation.
grid_key_dx< dim > get()
Return the actual grid key iterator.
void reset()
Reset the iterator (it restart from the beginning)
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
Test structure used for several test.
Implementation of 1-D std::vector like structure.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.