JayBeams  0.1
Another project to have fun coding.
ut_order_cancel_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_cancel_message decoder works
8  * as expected.
9  */
10 BOOST_AUTO_TEST_CASE(decode_order_cancel_message) {
11  using namespace jb::itch5;
12  using namespace std::chrono;
13 
16 
17  auto x = decoder<true, order_cancel_message>::r(buf.second, buf.first, 0);
18  BOOST_CHECK_EQUAL(x.header.message_type, order_cancel_message::message_type);
19  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
20  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
21  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
22  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
23  BOOST_CHECK_EQUAL(x.canceled_shares, 300);
24 
25  x = decoder<false, order_cancel_message>::r(buf.second, buf.first, 0);
26  BOOST_CHECK_EQUAL(x.header.message_type, order_cancel_message::message_type);
27  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
28  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
29  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
30  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
31  BOOST_CHECK_EQUAL(x.order_reference_number, 42ULL);
32  BOOST_CHECK_EQUAL(x.canceled_shares, 300);
33 }
34 
35 /**
36  * @test Verify that jb::itch5::order_cancel_message iostream
37  * operator works as expected.
38  */
39 BOOST_AUTO_TEST_CASE(stream_order_cancel_message) {
40  using namespace std::chrono;
41  using namespace jb::itch5;
42 
44  auto tmp = decoder<false, order_cancel_message>::r(buf.second, buf.first, 0);
45  std::ostringstream os;
46  os << tmp;
47  BOOST_CHECK_EQUAL(
48  os.str(), "message_type=X,stock_locate=0"
49  ",tracking_number=1,timestamp=113231.123456789"
50  ",order_reference_number=42"
51  ",canceled_shares=300");
52 }
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...
std::pair< char const *, std::size_t > order_cancel()
Definition: data.cpp:154
std::chrono::nanoseconds expected_ts()
Return the expected timestamp for all the test messages.
Definition: data.cpp:19
BOOST_AUTO_TEST_CASE(decode_order_cancel_message)