JayBeams  0.1
Another project to have fun coding.
ut_order_executed_message.cpp
Go to the documentation of this file.
3 
4 #include <boost/test/unit_test.hpp>
5 
6 /**
7  * @test Verify that the jb::itch5::order_executed_message decoder works
8  * as expected.
9  */
10 BOOST_AUTO_TEST_CASE(decode_order_executed_message) {
11  using namespace jb::itch5;
12  using namespace std::chrono;
13 
16 
17  auto x = decoder<true, order_executed_message>::r(buf.second, buf.first, 0);
18  BOOST_CHECK_EQUAL(
19  x.header.message_type, order_executed_message::message_type);
20  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
21  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
22  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
23  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
24  BOOST_CHECK_EQUAL(x.executed_shares, 300);
25  BOOST_CHECK_EQUAL(x.match_number, 317ULL);
26 
27  x = decoder<false, order_executed_message>::r(buf.second, buf.first, 0);
28  BOOST_CHECK_EQUAL(
29  x.header.message_type, order_executed_message::message_type);
30  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
31  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
32  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
33  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
34  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
35  BOOST_CHECK_EQUAL(x.executed_shares, 300);
36  BOOST_CHECK_EQUAL(x.match_number, 317ULL);
37 }
38 
39 /**
40  * @test Verify that jb::itch5::order_executed_message iostream
41  * operator works as expected.
42  */
43 BOOST_AUTO_TEST_CASE(stream_order_executed_message) {
44  using namespace std::chrono;
45  using namespace jb::itch5;
46 
48  auto tmp =
49  decoder<false, order_executed_message>::r(buf.second, buf.first, 0);
50  std::ostringstream os;
51  os << tmp;
52  BOOST_CHECK_EQUAL(
53  os.str(), "message_type=E,stock_locate=0"
54  ",tracking_number=1,timestamp=113231.123456789"
55  ",order_reference_number=42"
56  ",executed_shares=300"
57  ",match_number=317");
58 }
std::pair< char const *, std::size_t > order_executed()
Definition: data.cpp:175
static T r(std::size_t size, void const *msg, std::size_t offset)
Read a single message or field.
Contains classes and functions to parse NASDAQ ITCH-5.0 messages, more information about ITCH-5...
BOOST_AUTO_TEST_CASE(decode_order_executed_message)
std::chrono::nanoseconds expected_ts()
Return the expected timestamp for all the test messages.
Definition: data.cpp:19