1 #include <gtest/gtest.h>
2 #include <marnav/seatalk/message_01.hpp>
6 using namespace marnav
;
7 using namespace marnav::seatalk
;
9 class Test_seatalk_message_01
: public ::testing::Test
13 TEST_F(Test_seatalk_message_01
, construction
)
18 TEST_F(Test_seatalk_message_01
, parse_invalid_data_size
)
20 EXPECT_ANY_THROW(message_01::parse({7, 0x00}));
21 EXPECT_ANY_THROW(message_01::parse({9, 0x00}));
24 TEST_F(Test_seatalk_message_01
, parse_invalid_length
)
26 EXPECT_ANY_THROW(message_01::parse({0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
27 EXPECT_ANY_THROW(message_01::parse({0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}));
30 TEST_F(Test_seatalk_message_01
, parse
)
37 std::vector
<test_case
> cases
{
38 {{0x01, 0x05, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00}, message_01::course_computer_400g
},
39 {{0x01, 0x05, 0x04, 0xBA, 0x20, 0x28, 0x01, 0x00}, message_01::st60_tridata
},
40 {{0x01, 0x05, 0x70, 0x99, 0x10, 0x28, 0x01, 0x00}, message_01::st60_log
},
41 {{0x01, 0x05, 0xF3, 0x18, 0x00, 0x26, 0x0F, 0x06}, message_01::st80_masterview
},
42 {{0x01, 0x05, 0xFA, 0x03, 0x00, 0x30, 0x07, 0x03}, message_01::st80_maxi_display
},
43 {{0x01, 0x05, 0xFF, 0xFF, 0xFF, 0xD0, 0x00, 0x00},
44 message_01::smart_controller_remote_control_handset
},
47 for (auto const & t
: cases
) {
48 auto generic_message
= message_01::parse(t
.data
);
49 ASSERT_TRUE(generic_message
!= nullptr);
50 auto m
= message_cast
<message_01
>(generic_message
);
51 ASSERT_TRUE(m
!= nullptr);
52 EXPECT_EQ(message_id::equipment_id
, m
->type());
53 EXPECT_EQ(t
.id
, m
->get_equipment_id());
57 TEST_F(Test_seatalk_message_01
, write_default
)
59 const seatalk::raw expected
{0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
62 EXPECT_EQ(expected
, m
.get_data());
65 TEST_F(Test_seatalk_message_01
, write
)
67 const seatalk::raw expected
{0x01, 0x05, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00};
69 m
.set_equipment_id(message_01::course_computer_400g
);
71 EXPECT_EQ(expected
, m
.get_data());