Version 0.8.0
[marnav.git] / test / seatalk / Test_seatalk_message_87.cpp
blobac0b3f99e07f8392b705f7b681f52a22dbeb2413
1 #include <gtest/gtest.h>
2 #include <marnav/seatalk/message_87.hpp>
4 namespace
6 using namespace marnav::seatalk;
8 class Test_seatalk_message_87 : public ::testing::Test
10 public:
11 struct test_case {
12 raw data;
13 message_87::response_level level;
16 const std::vector<test_case> cases{
17 {{0x86, 0x00, 0x00}, message_87::response_level::invalid},
18 {{0x86, 0x00, 0x01}, message_87::response_level::automatic},
19 {{0x86, 0x00, 0x02}, message_87::response_level::minimum},
23 TEST_F(Test_seatalk_message_87, construction)
25 EXPECT_NO_THROW(message_87 m);
28 TEST_F(Test_seatalk_message_87, parse_invalid_data_size)
30 EXPECT_ANY_THROW(message_87::parse({1, 0x00}));
33 TEST_F(Test_seatalk_message_87, parse_invalid_length)
35 EXPECT_ANY_THROW(message_87::parse({0x87, 0x01, 0x00}));
38 TEST_F(Test_seatalk_message_87, parse)
40 for (auto const & t : cases) {
41 auto generic_message = message_87::parse(t.data);
42 EXPECT_TRUE(generic_message != nullptr);
43 if (!generic_message)
44 continue;
45 auto m = message_cast<message_87>(generic_message);
46 EXPECT_TRUE(m != nullptr);
47 if (!m)
48 continue;
49 EXPECT_EQ(t.level, m->get_level());
53 TEST_F(Test_seatalk_message_87, write_default)
55 const raw expected{0x87, 0x00, 0x01};
56 message_87 m;
58 EXPECT_EQ(expected, m.get_data());