JayBeams  0.1
Another project to have fun coding.
ut_unit_clear_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::unit_clear_message works as expected.
8  */
9 BOOST_AUTO_TEST_CASE(unit_clear_message_basic) {
10  using namespace jb::pitch2;
11  BOOST_CHECK_EQUAL(true, std::is_pod<unit_clear_message>::value);
12  BOOST_CHECK_EQUAL(sizeof(unit_clear_message), std::size_t(6));
13 
14  char const buf[] = u8"\x06" // Length (6)
15  "\x97" // Message Type (0x97)
16  "\x18\xD2\x06\x00" // Time Offset (447,000 ns)
17  ;
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()), 0x97);
23  BOOST_CHECK_EQUAL(msg.time_offset.value(), 447000);
24 
25  std::ostringstream os;
26  os << msg;
27  BOOST_CHECK_EQUAL(
28  os.str(), std::string("length=6,message_type=151,time_offset=447000"));
29 }
boost::endian::little_uint8_buf_t message_type
boost::endian::little_uint32_buf_t time_offset
BOOST_AUTO_TEST_CASE(unit_clear_message_basic)
boost::endian::little_uint8_buf_t length
Represent the &#39;Unit Clear&#39; message in the PITCH-2.X protocol.