JayBeams  0.1
Another project to have fun coding.
ut_reg_sho_restriction_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::reg_sho_restriction_message decoder works
8  * as expected.
9  */
10 BOOST_AUTO_TEST_CASE(decode_reg_sho_restriction_message) {
11  using namespace jb::itch5;
12  using namespace std::chrono;
13 
16 
17  auto x =
18  decoder<true, reg_sho_restriction_message>::r(buf.second, buf.first, 0);
19  BOOST_CHECK_EQUAL(
20  x.header.message_type, reg_sho_restriction_message::message_type);
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.stock, "HSART");
25  BOOST_CHECK_EQUAL(x.reg_sho_action, u'0');
26 
27  x = decoder<false, reg_sho_restriction_message>::r(buf.second, buf.first, 0);
28  BOOST_CHECK_EQUAL(
29  x.header.message_type, reg_sho_restriction_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.stock, "HSART");
34  BOOST_CHECK_EQUAL(x.reg_sho_action, u'0');
35 }
36 
37 /**
38  * @test Verify that jb::itch5::reg_sho_restriction_message iostream
39  * operator works as expected.
40  */
41 BOOST_AUTO_TEST_CASE(stream_reg_sho_restriction_message) {
42  using namespace std::chrono;
43  using namespace jb::itch5;
44 
46  auto tmp =
47  decoder<false, reg_sho_restriction_message>::r(buf.second, buf.first, 0);
48  std::ostringstream os;
49  os << tmp;
50  BOOST_CHECK_EQUAL(
51  os.str(), "message_type=Y,stock_locate=0"
52  ",tracking_number=1,timestamp=113231.123456789"
53  ",stock=HSART"
54  ",reg_sho_action=0");
55 }
56 
57 /**
58  * @test Verify that reg_sho_action_t works as expected.
59  */
60 BOOST_AUTO_TEST_CASE(simple_reg_sho_action) {
61  using namespace jb::itch5;
62  BOOST_CHECK_NO_THROW(reg_sho_action_t(u'0'));
63  BOOST_CHECK_NO_THROW(reg_sho_action_t(u'1'));
64  BOOST_CHECK_NO_THROW(reg_sho_action_t(u'2'));
65  BOOST_CHECK_THROW(reg_sho_action_t(u'*'), std::runtime_error);
66 }
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_reg_sho_restriction_message)
char_list_field< u '0', u '1', u '2'> reg_sho_action_t
Represent the &#39;Reg SHO Action&#39; field of the &#39;Reg SHO Restriction&#39; message.
std::chrono::nanoseconds expected_ts()
Return the expected timestamp for all the test messages.
Definition: data.cpp:19
std::pair< char const *, std::size_t > reg_sho_restriction()
Definition: data.cpp:218