1 #ifndef SRC_PACKER_NESTED_TESTS_HPP_
2 #define SRC_PACKER_NESTED_TESTS_HPP_
4 #include "Pack_selector.hpp"
6 #include "Unpacker.hpp"
7 #include "Grid/grid_util_test.hpp"
12 BOOST_AUTO_TEST_SUITE( packer_unpacker )
14 BOOST_AUTO_TEST_CASE ( vector_ptst_packer_unpacker )
16 std::cout <<
"Vector pack/unpack test start" <<
"\n";
19 for (
size_t i = 0; i < 5; i++) {
21 for (
size_t j = 0; j < 6; j++) {
22 v4.add(allocate_openfpm(7));
30 std::vector<size_t> pap_prp;
35 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],(
sizeof(float) +
sizeof(
float[3])) * 7);
41 for (
size_t i = 0; i < pap_prp.size(); i++)
42 std::cout << pap_prp[i] << std::endl;
46 size_t req = ExtPreAlloc<HeapMemory>::calculateMem(pap_prp);
51 ExtPreAlloc<HeapMemory> & mem = *(
new ExtPreAlloc<HeapMemory>(pap_prp,pmem));
69 for (
size_t k = 0; k < v_unp.size(); k++)
71 for (
size_t i = 0; i < v_unp.get(k).size(); i++)
73 auto it = v_unp.get(k).get(i).getIterator();
77 float f1 = v_unp.get(k).get(i).template get<pt::x>(it.get());
78 float f2 = v.get(k).get(i).template get<pt::x>(it.get());
80 BOOST_REQUIRE_EQUAL(f1,f2);
82 for (
size_t j = 0 ; j < 3 ; j++)
84 f1 = v_unp.get(k).get(i).template get<pt::v>(it.get())[j];
85 f2 = v.get(k).get(i).template get<pt::v>(it.get())[j];
87 BOOST_REQUIRE_EQUAL(f1,f2);
96 BOOST_AUTO_TEST_CASE ( vector_std_packer_unpacker )
99 for (
size_t i = 0; i < 5; i++) {
101 for (
size_t j = 0; j < 6; j++) {
103 for (
size_t k = 0; k < 7; k++) {
112 std::vector<size_t> pap_prp;
117 BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],
sizeof(float) * 7);
121 for (
size_t i = 0; i < pap_prp.size(); i++)
122 std::cout << pap_prp[i] << std::endl;
126 size_t req = ExtPreAlloc<HeapMemory>::calculateMem(pap_prp);
131 ExtPreAlloc<HeapMemory> & mem = *(
new ExtPreAlloc<HeapMemory>(pap_prp,pmem));
149 for (
size_t k = 0; k < v2_unp.size(); k++)
151 for (
size_t i = 0; i < v2_unp.get(k).size(); i++)
153 for (
size_t j = 0; j < v2_unp.get(k).get(i).size(); j++)
155 float f1 = v2_unp.get(k).get(i).get(j);
156 float f2 = v2.get(k).get(i).get(j);
158 BOOST_REQUIRE_EQUAL(f1,f2);
163 std::cout <<
"Vector pack/unpack test stop" <<
"\n";
166 BOOST_AUTO_TEST_SUITE_END()
Test structure used for several test.
Implementation of 1-D std::vector like structure.