1 #include <gtest/gtest.h>
2 #include <marnav/seatalk/message_52.hpp>
7 using namespace marnav::seatalk
;
9 class Test_seatalk_message_52
: public ::testing::Test
13 TEST_F(Test_seatalk_message_52
, construction
)
15 EXPECT_NO_THROW(message_52 m
);
18 TEST_F(Test_seatalk_message_52
, parse_invalid_data_size
)
20 EXPECT_ANY_THROW(message_52::parse({3, 0x00}));
21 EXPECT_ANY_THROW(message_52::parse({5, 0x00}));
24 TEST_F(Test_seatalk_message_52
, parse_invalid_length
)
26 EXPECT_ANY_THROW(message_52::parse({0x52, 0x00, 0x00, 0x00}));
27 EXPECT_ANY_THROW(message_52::parse({0x52, 0x02, 0x00, 0x00}));
30 TEST_F(Test_seatalk_message_52
, parse
)
37 const std::vector
<test_case
> cases
{
38 {{0x52, 0x01, 0x00, 0x01}, 0.1}, {{0x52, 0x01, 0x00, 0x10}, 1.6},
39 {{0x52, 0x01, 0x01, 0x00}, 25.6}, {{0x52, 0x01, 0x10, 0x00}, 409.6},
42 for (auto const & t
: cases
) {
43 auto generic_message
= message_52::parse(t
.data
);
44 EXPECT_TRUE(generic_message
!= nullptr);
47 auto m
= message_cast
<message_52
>(generic_message
);
48 EXPECT_TRUE(m
!= nullptr);
51 EXPECT_NEAR(t
.sog
, m
->get_sog(), 1e-5);
55 TEST_F(Test_seatalk_message_52
, write_default
)
57 const raw expected
{0x52, 0x01, 0x00, 0x00};
60 EXPECT_EQ(expected
, m
.get_data());