Version 0.8.0
[marnav.git] / test / seatalk / Test_seatalk_message_36.cpp
blob0c527ea20e6a38c574ec9b0a13052d67122af3d5
1 #include <gtest/gtest.h>
2 #include <marnav/seatalk/message_36.hpp>
4 namespace
7 using namespace marnav::seatalk;
9 class Test_seatalk_message_36 : public ::testing::Test
13 TEST_F(Test_seatalk_message_36, construction)
15 message_36 m;
18 TEST_F(Test_seatalk_message_36, parse_invalid_data_size)
20 EXPECT_ANY_THROW(message_36::parse({1, 0x00}));
21 EXPECT_ANY_THROW(message_36::parse({2, 0x00}));
24 TEST_F(Test_seatalk_message_36, parse_invalid_length)
26 EXPECT_ANY_THROW(message_36::parse({0x36, 0x01, 0x01}));
27 EXPECT_ANY_THROW(message_36::parse({0x36, 0x02, 0x01}));
30 TEST_F(Test_seatalk_message_36, parse)
32 struct test_case {
33 raw data;
36 std::vector<test_case> cases{
37 {{0x36, 0x00, 0x01}},
40 for (auto const & t : cases) {
41 auto generic_message = message_36::parse(t.data);
42 EXPECT_TRUE(generic_message != nullptr);
43 if (!generic_message)
44 continue;
45 auto m = message_cast<message_36>(generic_message);
46 EXPECT_TRUE(m != nullptr);
47 if (!m)
48 continue;
49 EXPECT_EQ(message_id::cancel_mob_condition, m->type());
53 TEST_F(Test_seatalk_message_36, write_default)
55 const raw expected{0x36, 0x00, 0x01};
56 message_36 m;
58 EXPECT_EQ(expected, m.get_data());