JayBeams  0.1
Another project to have fun coding.
ut_time_message.cpp
Go to the documentation of this file.
2 
3 #include <boost/test/unit_test.hpp>
4 #include <type_traits>
5 
6 /**
7  * @test Verify that jb::pitch2::time_message works as expected.
8  */
9 BOOST_AUTO_TEST_CASE(time_message_basic) {
10  using namespace jb::pitch2;
11  BOOST_CHECK_EQUAL(true, std::is_pod<time_message>::value);
12  BOOST_CHECK_EQUAL(sizeof(time_message), std::size_t(6));
13 
14  char const buf[] = u8"\x06" // Length (6)
15  "\x20" // Message Type (32)
16  "\x98\x85\x00\x00" // Time (34200 seconds)
17  ;
18  time_message msg;
19  BOOST_REQUIRE_EQUAL(sizeof(buf) - 1, sizeof(msg));
20  std::memcpy(&msg, buf, sizeof(msg));
21  BOOST_CHECK_EQUAL(int(msg.length.value()), 6);
22  BOOST_CHECK_EQUAL(int(msg.message_type.value()), 0x20);
23  BOOST_CHECK_EQUAL(msg.time.value(), 34200);
24 
25  std::ostringstream os;
26  os << msg;
27  BOOST_CHECK_EQUAL(
28  os.str(), std::string("length=6,message_type=32,time=34200"));
29 }
BOOST_AUTO_TEST_CASE(time_message_basic)
boost::endian::little_uint8_buf_t length
boost::endian::little_uint8_buf_t message_type
Represent the &#39;Time&#39; message in the PITCH-2.X protocol.
boost::endian::little_int32_buf_t time