1 #include <gtest/gtest.h>
2 #include <marnav/seatalk/message_6c.hpp>
6 using namespace marnav
;
7 using namespace marnav::seatalk
;
9 class Test_seatalk_message_6c
: public ::testing::Test
13 TEST_F(Test_seatalk_message_6c
, construction
)
18 TEST_F(Test_seatalk_message_6c
, parse_invalid_data_size
)
20 EXPECT_ANY_THROW(message_6c::parse({7, 0x00}));
21 EXPECT_ANY_THROW(message_6c::parse({9, 0x00}));
24 TEST_F(Test_seatalk_message_6c
, parse_invalid_length
)
26 EXPECT_ANY_THROW(message_6c::parse({0x6c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
27 EXPECT_ANY_THROW(message_6c::parse({0x6c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
30 TEST_F(Test_seatalk_message_6c
, parse
)
37 std::vector
<test_case
> cases
{
38 {{0x6C, 0x05, 0x04, 0xBA, 0x20, 0x28, 0x2D, 0x2D}, message_6c::st60_tridata
},
39 {{0x6C, 0x05, 0x05, 0x70, 0x99, 0x10, 0x28, 0x2D}, message_6c::st60_log
},
40 {{0x6C, 0x05, 0xF3, 0x18, 0x00, 0x26, 0x2D, 0x2D}, message_6c::st80_masterview
},
43 for (auto const & t
: cases
) {
44 auto generic_message
= message_6c::parse(t
.data
);
45 ASSERT_TRUE(generic_message
!= nullptr);
46 auto m
= message_cast
<message_6c
>(generic_message
);
47 ASSERT_TRUE(m
!= nullptr);
48 EXPECT_EQ(message_id::equipment_id_2
, m
->type());
49 EXPECT_EQ(t
.id
, m
->get_equipment_id());
53 TEST_F(Test_seatalk_message_6c
, write_default
)
55 const raw expected
{0x6c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
58 EXPECT_EQ(expected
, m
.get_data());
61 TEST_F(Test_seatalk_message_6c
, write
)
63 const raw expected
{0x6c, 0x05, 0x04, 0xBA, 0x20, 0x28, 0x2D, 0x2D};
65 m
.set_equipment_id(message_6c::st60_tridata
);
67 EXPECT_EQ(expected
, m
.get_data());