JayBeams  0.1
Another project to have fun coding.
ut_order_executed_price_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::order_executed_price_message works as expected.
8  */
9 BOOST_AUTO_TEST_CASE(order_executed_price_message_basic) {
10  using namespace jb::pitch2;
11  BOOST_CHECK_EQUAL(true, std::is_pod<order_executed_price_message>::value);
12  BOOST_CHECK_EQUAL(sizeof(order_executed_price_message), std::size_t(38));
13 
14  char const buf[] = u8"\x26" // Length (38)
15  "\x24" // Message Type (0x24)
16  "\x18\xD2\x06\x00" // Time Offset (447,000 ns)
17  "\x05\x40\x5B\x77\x8F\x56\x1D\x0B" // Order Id
18  "\x64\x00\x00\x00" // Executed Quantity (100)
19  "\xBC\x4D\x00\x00" // Remaining Quantity (19,900)
20  "\x34\x2B\x46\xE0\xBB\x00\x00\x00" // Execution Id
21  "\xE8\xA3\x0F\x00\x00\x00\x00\x00" // Price ($102.50)
22  ;
24  BOOST_REQUIRE_EQUAL(sizeof(buf) - 1, sizeof(msg));
25  std::memcpy(&msg, buf, sizeof(msg));
26  BOOST_CHECK_EQUAL(int(msg.length.value()), 38);
27  BOOST_CHECK_EQUAL(int(msg.message_type.value()), 0x24);
28  BOOST_CHECK_EQUAL(msg.time_offset.value(), 447000);
29  BOOST_CHECK_EQUAL(msg.order_id.value(), 0x0B1D568F775B4005ULL);
30  BOOST_CHECK_EQUAL(msg.executed_quantity.value(), 100);
31  BOOST_CHECK_EQUAL(msg.remaining_quantity.value(), 19900);
32  BOOST_CHECK_EQUAL(msg.execution_id.value(), 0x000000BBE0462B34ULL);
33  BOOST_CHECK_EQUAL(msg.price.value(), 1025000);
34 
35  std::ostringstream os;
36  os << msg;
37  BOOST_CHECK_EQUAL(
38  os.str(),
39  std::string("length=38,message_type=36,time_offset=447000"
40  ",order_id=800891482924597253,executed_quantity=100"
41  ",remaining_quantity=19900,execution_id=806921579316"
42  ",price=1025000"));
43 }
Represent the &#39;Order Executed at Price/Size&#39; message in the PITCH-2.X protocol.
boost::endian::little_uint32_buf_t executed_quantity
boost::endian::little_uint32_buf_t remaining_quantity
BOOST_AUTO_TEST_CASE(decode_order_executed_price_message)