1 #include <marnav/ais/message_07.hpp>
2 #include <marnav/ais/ais.hpp>
3 #include <gtest/gtest.h>
7 using namespace marnav
;
9 class Test_ais_message_07
: public ::testing::Test
13 TEST_F(Test_ais_message_07
, parse
)
15 std::vector
<std::pair
<std::string
, uint32_t>> v
;
16 v
.push_back(std::make_pair("702R5`hwCjq8", 0));
18 auto result
= ais::make_message(v
);
19 ASSERT_TRUE(result
!= nullptr);
21 auto m
= ais::message_cast
<ais::message_07
>(result
);
22 ASSERT_TRUE(m
!= nullptr);
25 TEST_F(Test_ais_message_07
, wrong_number_of_bits
)
27 EXPECT_ANY_THROW(ais::message_parse
<ais::message_07
>(ais::raw(71)));
28 EXPECT_ANY_THROW(ais::message_parse
<ais::message_07
>(ais::raw(169)));
31 TEST_F(Test_ais_message_07
, test_data_from_kurt_schwer
)
33 // see: https://fossies.org/linux/gpsd/test/sample.aivdm
35 std::vector
<std::pair
<std::string
, uint32_t>> v
;
36 v
.push_back(std::make_pair("7IiQ4T`UjA9lC;b:M<MWE@", 4));
38 auto result
= ais::make_message(v
);
39 ASSERT_TRUE(result
!= nullptr);
41 auto m
= ais::message_cast
<ais::message_07
>(result
);
42 ASSERT_TRUE(m
!= nullptr);
44 EXPECT_EQ(655901842u, m
->get_mmsi());
45 EXPECT_EQ(158483613u, m
->get_mmsi_1());
46 EXPECT_EQ(321823389u, m
->get_mmsi_2());
47 // @todo Investigate this, it cannot be because raw data is 128 bits, which cuts MMSI_3
48 // EXPECT_EQ(836359488u, m->get_mmsi_3());
49 EXPECT_EQ(0u, m
->get_mmsi_4());
52 TEST_F(Test_ais_message_07
, test_data_from_mike_green
)
54 // see: https://fossies.org/linux/gpsd/test/sample.aivdm
56 std::vector
<std::pair
<std::string
, uint32_t>> v
;
57 v
.push_back(std::make_pair("7`0Pv1L:Ac8rbgPKHA8`P", 2));
59 auto result
= ais::make_message(v
);
60 ASSERT_TRUE(result
!= nullptr);
62 auto m
= ais::message_cast
<ais::message_07
>(result
);
63 ASSERT_TRUE(m
!= nullptr);
65 EXPECT_EQ(2u, m
->get_repeat_indicator());
66 EXPECT_EQ(537411077u, m
->get_mmsi());
67 EXPECT_EQ(43101326u, m
->get_mmsi_1());
68 EXPECT_EQ(717096664u, m
->get_mmsi_2());
69 // @todo Investigate this, it cannot be because raw data is 124 bits, which cuts MMSI_3
70 // EXPECT_EQ(76161024u, m->get_mmsi_3());
71 EXPECT_EQ(0u, m
->get_mmsi_4());