JayBeams  0.1
Another project to have fun coding.
ut_auction_update_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::auction_update_message works as expected.
8  */
9 BOOST_AUTO_TEST_CASE(auction_update_message_basic) {
10  using namespace jb::pitch2;
11  BOOST_CHECK_EQUAL(true, std::is_pod<auction_update_message>::value);
12  BOOST_CHECK_EQUAL(sizeof(auction_update_message), std::size_t(47));
13 
14  char const buf[] =
15  u8"\x2F" // Length (47)
16  "\x95" // Message Type (149)
17  "\x18\xD2\x06\x00" // Time Offset (447,000)
18  "\x5A\x56\x5A\x5A\x54\x20\x20\x20" // Symbol (ZVZZT)
19  "\x49" // Auction Type (I = IPO)
20  "\xE8\xA3\x0F\x00\x00\x00\x00\x00" // Reference Price ($102.50)
21  "\xF8\x24\x01\x00" // Buy Side Shares (75,000)
22  "\x20\x4E\x00\x00" // Sell Side Shares (20,000)
23  "\xE9\xA3\x0F\x00\x00\x00\x00\x00" // Indicative Price ($102.5001)
24  "\xEA\xA3\x0F\x00\x00\x00\x00\x00" // Auction Only Price ($102.5002)
25  ;
27  BOOST_REQUIRE_EQUAL(sizeof(buf) - 1, sizeof(msg));
28  std::memcpy(&msg, buf, sizeof(msg));
29  BOOST_CHECK_EQUAL(int(msg.length.value()), 47);
30  BOOST_CHECK_EQUAL(int(msg.message_type.value()), 0x95);
31  BOOST_CHECK_EQUAL(msg.time_offset.value(), 447000);
32  BOOST_CHECK_EQUAL(msg.stock_symbol, jb::fixed_string<8>("ZVZZT"));
33  BOOST_CHECK_EQUAL(int(msg.auction_type.value()), 0x49);
34  BOOST_CHECK_EQUAL(msg.reference_price.value(), 1025000);
35  BOOST_CHECK_EQUAL(msg.buy_shares.value(), 75000);
36  BOOST_CHECK_EQUAL(msg.sell_shares.value(), 20000);
37  BOOST_CHECK_EQUAL(msg.indicative_price.value(), 1025001);
38  BOOST_CHECK_EQUAL(msg.auction_only_price.value(), 1025002);
39 
40  std::ostringstream os;
41  os << msg;
42  BOOST_CHECK_EQUAL(
43  os.str(),
44  std::string(
45  "length=47,message_type=149,time_offset=447000,stock_symbol=ZVZZT "
46  ",auction_type=I,reference_price=1025000,buy_shares=75000"
47  ",sell_shares=20000,indicative_price=1025001"
48  ",auction_only_price=1025002"));
49 }
boost::endian::little_uint32_buf_t time_offset
boost::endian::little_uint64_buf_t indicative_price
BOOST_AUTO_TEST_CASE(auction_update_message_basic)
boost::endian::little_uint32_buf_t buy_shares
boost::endian::little_uint8_buf_t length
boost::endian::little_uint8_buf_t auction_type
boost::endian::little_uint8_buf_t message_type
boost::endian::little_uint64_buf_t auction_only_price
boost::endian::little_uint32_buf_t sell_shares
Represent the &#39;Auction Update&#39; message in the PITCH-2.X protocol.
boost::endian::little_uint64_buf_t reference_price