33 #include <boost/test/unit_test.hpp> 37 BOOST_AUTO_TEST_SUITE(ts_ByteOrderConversion)
42 float test_float = 15.08;
44 u_int8_t test_uint = 128;
45 u_int16_t test_uint2 = 128;
47 ab << test_int << test_float << test_uint << test_uint2;
53 float test_float_out = 0.0;
55 u_int8_t test_uint_out = 0;
56 u_int16_t test_uint2_out = 2;
57 int test_to_mouch = 0;
59 ab >> test_int_out >> test_float_out >> test_uint_out >> test_uint2_out >> test_to_mouch;
67 BOOST_CHECK_EQUAL(test_float, test_float_out);
68 BOOST_CHECK_EQUAL(test_int, test_int_out);
69 BOOST_CHECK_EQUAL(test_uint, test_uint_out);
70 BOOST_CHECK_EQUAL(test_uint2, test_uint2_out);
71 BOOST_CHECK_EQUAL(test_to_mouch, 0);
77 std::vector<u_int8_t> test_uint8_vector;
78 std::vector<u_int16_t> test_uint16_vector;
79 std::vector<u_int8_t> test_uint8_vector_out(4, 0);
80 std::vector<u_int16_t> test_uint16_vector_out(4, 0);
83 test_uint8_vector.push_back(1);
84 test_uint8_vector.push_back(2);
85 test_uint8_vector.push_back(3);
86 test_uint8_vector.push_back(4);
87 ab << test_uint8_vector;
92 test_uint16_vector.push_back(5);
93 test_uint16_vector.push_back(6);
94 test_uint16_vector.push_back(7);
95 test_uint16_vector.push_back(8);
96 ab << test_uint16_vector;
102 ab >> test_uint8_vector_out;
103 ab >> test_uint16_vector_out;
123 BOOST_CHECK_EQUAL_COLLECTIONS(test_uint8_vector.begin(),
124 test_uint8_vector.end(),
125 test_uint8_vector_out.begin(),
126 test_uint8_vector_out.end());
127 BOOST_CHECK_EQUAL_COLLECTIONS(test_uint16_vector.begin(),
128 test_uint16_vector.end(),
129 test_uint16_vector_out.begin(),
130 test_uint16_vector_out.end());
138 u_int32_t size_peek = 0;
139 u_int32_t size_out = 0;
142 size_peek = ab.
readBack<u_int32_t>();
147 BOOST_CHECK_EQUAL(size, size_out);
148 BOOST_CHECK_EQUAL(size, size_peek);
154 BOOST_CHECK_EQUAL(size_out, 0);
155 size_peek = ab.
readBack<u_int32_t>();
156 BOOST_CHECK_EQUAL(size, size_peek);
160 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ConvertTest)