JayBeams  0.1
Another project to have fun coding.
ut_market_participant_position_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::market_participant_position_message
8  * decoder works as expected.
9  */
10 BOOST_AUTO_TEST_CASE(decode_market_participant_position_message) {
11  using namespace jb::itch5;
12  using namespace std::chrono;
13 
16 
18  buf.second, buf.first, 0);
19  BOOST_CHECK_EQUAL(
21  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
22  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
23  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
24  BOOST_CHECK_EQUAL(x.mpid, "LOOF");
25  BOOST_CHECK_EQUAL(x.stock, "HSART");
26  BOOST_CHECK_EQUAL(x.primary_market_maker, u'N');
27  BOOST_CHECK_EQUAL(x.market_maker_mode, u'N');
28  BOOST_CHECK_EQUAL(x.market_participant_state, u'A');
29 
31  buf.second, buf.first, 0);
32  BOOST_CHECK_EQUAL(
34  BOOST_CHECK_EQUAL(x.header.stock_locate, 0);
35  BOOST_CHECK_EQUAL(x.header.tracking_number, 1);
36  BOOST_CHECK_EQUAL(x.header.timestamp.ts.count(), expected_ts.count());
37  BOOST_CHECK_EQUAL(x.mpid, "LOOF");
38  BOOST_CHECK_EQUAL(x.stock, "HSART");
39  BOOST_CHECK_EQUAL(x.primary_market_maker, u'N');
40  BOOST_CHECK_EQUAL(x.market_maker_mode, u'N');
41  BOOST_CHECK_EQUAL(x.market_participant_state, u'A');
42 }
43 
44 /**
45  * @test Verify that jb::itch5::market_participant_position_message iostream
46  * operator works as expected.
47  */
48 BOOST_AUTO_TEST_CASE(stream_market_participant_position_message) {
49  using namespace std::chrono;
50  using namespace jb::itch5;
51 
54  buf.second, buf.first, 0);
55  std::ostringstream os;
56  os << tmp;
57  BOOST_CHECK_EQUAL(
58  os.str(), "message_type=L,stock_locate=0"
59  ",tracking_number=1,timestamp=113231.123456789"
60  ",mpid=LOOF"
61  ",stock=HSART"
62  ",primary_market_maker=N"
63  ",market_maker_mode=N"
64  ",market_participant_state=A");
65 }
66 
67 /**
68  * @test Verify that primary_market_maker_t works as expected.
69  */
70 BOOST_AUTO_TEST_CASE(simple_primary_market_maker) {
71  using namespace jb::itch5;
72  BOOST_CHECK_NO_THROW(primary_market_maker_t(u'Y'));
73  BOOST_CHECK_NO_THROW(primary_market_maker_t(u'N'));
74  BOOST_CHECK_THROW(primary_market_maker_t(u'*'), std::runtime_error);
75 }
76 
77 /**
78  * @test Verify that market_maker_mode_t works as expected.
79  */
80 BOOST_AUTO_TEST_CASE(simple_market_maker_mode) {
81  using namespace jb::itch5;
82  BOOST_CHECK_NO_THROW(market_maker_mode_t(u'N'));
83  BOOST_CHECK_NO_THROW(market_maker_mode_t(u'P'));
84  BOOST_CHECK_THROW(market_maker_mode_t(u'*'), std::runtime_error);
85 }
86 
87 /**
88  * @test Verify that market_participant_state_t works as expected.
89  */
90 BOOST_AUTO_TEST_CASE(simple_market_participant_state) {
91  using namespace jb::itch5;
92  BOOST_CHECK_NO_THROW(market_participant_state_t(u'A'));
93  BOOST_CHECK_NO_THROW(market_participant_state_t(u'E'));
94  BOOST_CHECK_THROW(market_participant_state_t(u'*'), std::runtime_error);
95 }
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...
char_list_field< u 'A', u 'E', u 'W', u 'S', u 'D' > market_participant_state_t
Represent the &#39;Market Participant State&#39; field in a &#39;Market Participant Position&#39; message...
char_list_field< u 'Y', u 'N'> primary_market_maker_t
Represent the &#39;Primary Market Maker&#39; field on a &#39;Market Participant Position&#39; message.
std::pair< char const *, std::size_t > market_participant_position()
Definition: data.cpp:100
BOOST_AUTO_TEST_CASE(decode_market_participant_position_message)
std::chrono::nanoseconds expected_ts()
Return the expected timestamp for all the test messages.
Definition: data.cpp:19
char_list_field< u 'N', u 'P', u 'S', u 'R', u 'L' > market_maker_mode_t
Represent the &#39;Market Maker Mode&#39; field in a &#39;Market Participant Position&#39; message.