1 #include <marnav/seatalk/message_53.hpp>
2 #include <gtest/gtest.h>
7 using namespace marnav::seatalk
;
9 class test_seatalk_message_53
: public ::testing::Test
17 const std::vector
<test_case
> cases
{
18 {{0x53, 0x00, 0x00}, 0.0},
19 {{0x53, 0x00, 0x01}, 2.0},
20 {{0x53, 0x00, 0x02}, 4.0},
21 {{0x53, 0x00, 0x04}, 8.0},
22 {{0x53, 0x00, 0x08}, 16.0},
23 {{0x53, 0x00, 0x10}, 32.0},
24 {{0x53, 0x00, 0x20}, 64.0},
25 {{0x53, 0x10, 0x00}, 90.0},
26 {{0x53, 0x20, 0x00}, 180.0},
27 {{0x53, 0x30, 0x00}, 270.0},
28 {{0x53, 0x40, 0x00}, 0.5},
29 {{0x53, 0x80, 0x00}, 1.0},
30 {{0x53, 0xc0, 0x00}, 1.5},
34 TEST_F(test_seatalk_message_53
, construction
)
36 EXPECT_NO_THROW(message_53 m
);
39 TEST_F(test_seatalk_message_53
, parse_invalid_data_size
)
41 EXPECT_ANY_THROW(message_53::parse({2, 0x00}));
42 EXPECT_ANY_THROW(message_53::parse({4, 0x00}));
45 TEST_F(test_seatalk_message_53
, parse_invalid_length
)
47 EXPECT_ANY_THROW(message_53::parse({0x53, 0x01, 0x00}));
48 EXPECT_ANY_THROW(message_53::parse({0x53, 0x02, 0x00}));
51 TEST_F(test_seatalk_message_53
, parse
)
53 for (auto const & t
: cases
) {
54 auto generic_message
= message_53::parse(t
.data
);
55 EXPECT_TRUE(generic_message
!= nullptr);
58 auto m
= message_cast
<message_53
>(generic_message
);
59 EXPECT_TRUE(m
!= nullptr);
65 TEST_F(test_seatalk_message_53
, write_default
)
67 const raw expected
{0x53, 0x00, 0x00};
70 EXPECT_EQ(expected
, m
.get_data());
73 TEST_F(test_seatalk_message_53
, set_cog
)
75 for (auto const & t
: cases
) {
78 const auto raw
= m
.get_data();
79 EXPECT_EQ(t
.data
, raw
) << "cog=" << t
.cog
;