NMEA: make nmeatool available with/without ENABLE_IO
[marnav.git] / test / seatalk / Test_seatalk_message_38.cpp
blobaa7ab0cf5dd9dd4edaad013656a4abc52e1e6fd3
1 #include <marnav/seatalk/message_38.hpp>
2 #include <gtest/gtest.h>
4 namespace
7 using namespace marnav::seatalk;
9 class Test_seatalk_message_38 : public ::testing::Test
13 TEST_F(Test_seatalk_message_38, construction)
15 message_38 m;
18 TEST_F(Test_seatalk_message_38, parse_invalid_data_size)
20 EXPECT_ANY_THROW(message_38::parse({3, 0x00}));
21 EXPECT_ANY_THROW(message_38::parse({5, 0x00}));
24 TEST_F(Test_seatalk_message_38, parse_invalid_length)
26 EXPECT_ANY_THROW(message_38::parse({0x38, 0x00, 0x00, 0x01}));
27 EXPECT_ANY_THROW(message_38::parse({0x38, 0x02, 0x00, 0x01}));
30 TEST_F(Test_seatalk_message_38, parse)
32 struct test_case {
33 raw data;
36 std::vector<test_case> cases{
37 {{0x38, 0x01, 0x00, 0x00}},
40 for (auto const & t : cases) {
41 auto generic_message = message_38::parse(t.data);
42 EXPECT_TRUE(generic_message != nullptr);
43 if (!generic_message)
44 continue;
45 auto m = message_cast<message_38>(generic_message);
46 EXPECT_TRUE(m != nullptr);
47 if (!m)
48 continue;
52 TEST_F(Test_seatalk_message_38, write_default)
54 const raw expected{0x38, 0x01, 0x00, 0x00};
55 message_38 m;
57 EXPECT_EQ(expected, m.get_data());