1 #include <marnav/seatalk/message_86.hpp>
2 #include <gtest/gtest.h>
6 using namespace marnav::seatalk
;
8 class Test_seatalk_message_86
: public ::testing::Test
13 message_86::origin org
;
17 const std::vector
<test_case
> cases
{
18 {{0x86, 0x01, 0x02, 0xfd}, message_86::origin::st1000
, key::key_standby
},
19 {{0x86, 0x01, 0x05, 0xfa}, message_86::origin::st1000
, key::key_m1
},
20 {{0x86, 0x01, 0x06, 0xf9}, message_86::origin::st1000
, key::key_m10
},
21 {{0x86, 0x01, 0x07, 0xf8}, message_86::origin::st1000
, key::key_p1
},
22 {{0x86, 0x01, 0x08, 0xf7}, message_86::origin::st1000
, key::key_p10
},
26 TEST_F(Test_seatalk_message_86
, construction
)
28 EXPECT_NO_THROW(message_86 m
);
31 TEST_F(Test_seatalk_message_86
, parse_invalid_data_size
)
33 EXPECT_ANY_THROW(message_86::parse({3, 0x00}));
34 EXPECT_ANY_THROW(message_86::parse({5, 0x00}));
37 TEST_F(Test_seatalk_message_86
, parse_invalid_length
)
39 EXPECT_ANY_THROW(message_86::parse({0x86, 0x00, 0x00, 0x00}));
40 EXPECT_ANY_THROW(message_86::parse({0x86, 0x02, 0x00, 0x00}));
43 TEST_F(Test_seatalk_message_86
, parse
)
45 for (auto const & t
: cases
) {
46 auto generic_message
= message_86::parse(t
.data
);
47 EXPECT_TRUE(generic_message
!= nullptr);
50 auto m
= message_cast
<message_86
>(generic_message
);
51 EXPECT_TRUE(m
!= nullptr);
54 EXPECT_EQ(t
.org
, m
->get_org());
55 EXPECT_EQ(t
.k
, m
->get_key());
59 TEST_F(Test_seatalk_message_86
, parse_invalid_code
)
61 const raw data
{0x86, 0x01, 0x02, 0xfc};
63 EXPECT_ANY_THROW(message_86::parse(data
));
66 TEST_F(Test_seatalk_message_86
, write_default
)
68 const raw expected
{0x86, 0x01, 0x02, 0xfd};
71 EXPECT_EQ(expected
, m
.get_data());