Packer_unit_tests.hpp 2.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/*
 * Packer_unit_tests.hpp
 *
 *  Created on: Jul 15, 2015
 *      Author: Pietro Incardona
 */

#ifndef SRC_PACKER_UNIT_TESTS_HPP_
#define SRC_PACKER_UNIT_TESTS_HPP_

BOOST_AUTO_TEST_SUITE( Packer )

#include "Pack_selector.hpp"

BOOST_AUTO_TEST_CASE ( Packer_test )
{
	//! [Pack selector usage]

	int val = Pack_selector<unsigned char>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<char>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<short>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<unsigned short>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<int>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<unsigned int>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<long int>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<unsigned long int>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<float>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
	val = Pack_selector<double>::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);

	val = Pack_selector< openfpm::vector<Point_test<float>> >::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_VECTOR);
	val = Pack_selector< grid_cpu<3,Point_test<float>> >::value;
	BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
incardon's avatar
incardon committed
44 45
//	val = Pack_selector< encapc<3,Point_test<float>, memory_traits_lin<Point_test<float>> > >::value;
//	BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
46 47 48 49 50 51 52 53 54 55

	struct test_s
	{
		float a;
		float b;

		bool noPointers() {return true;}
	};

	val = Pack_selector< test_s >::value;
56
//	BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

	//! [Pack selector usage]

	//! [Pack into a message primitives objects vector and grids]

	unsigned char uc = 1;
	char c = 2;
	short s = 3;
	unsigned short us = 4;
	int i = 5;
	unsigned int ui = 6;
	long int li = 7;
	unsigned long int uli = 8;
	float f = 9;
	double d = 10;

	std::vector<size_t> pap_prp;

/*	Packer<unsigned char>::packRequest(pap_prp);
	Packer<char>::packRequest();
	Packer<short>*/


	// try to pack all the primitives

	//! [Pack into a message primitives objects vector and grids]
}

BOOST_AUTO_TEST_SUITE_END()



#endif /* SRC_PACKER_UNIT_TESTS_HPP_ */