Debian Codegraph @

src/test/ais10_test.cc

raw symbols SCIP
1 // Test parsing message 10 ":" - UTC and date inquiry.
2
3 // TODO(schwehr): Decode these. They might not be valid, but they were
4 // received in the wild.
5
6 // !AIVDM,1,1,,B,:T0Vd`,3*2A
7 // !AIVDM,1,1,,B,:1pwe20<m>FB,0*25
8 // !AIVDM,1,1,,B,:A6P?cNiukR`,0*6F
9 // !AIVDM,1,1,,B,:WHeWAEwGWgw,0*41
10 // !AIVDM,1,1,,B,:iCn44crw>GI,0*0D
11 // !AIVDM,1,1,,B,:lM>=N?JwNM?,0*4D
12 // !SAVDM,1,1,,B,:5@SW:19pedP,0*67
13 // !AIVDM,1,1,,B,:8MEJAmIknK;5cm5:ogsp,3*49
14 // !AIVDM,1,1,,A,:RFLT2OO>ITV@VUC4IRHpavl,5*3E
15 // !AIVDM,1,1,,A,:J`=1W5qKhACoa<7:hhk<k=wP,5*14
16 // !AIVDM,1,1,,B,:CFlQi3vqjM8;W98tPnSK`g<W9cqE;h<tP,1*12
17
18 #include <memory>
19
20 #include "gtest/gtest.h"
21 #include "ais.h"
22
23 namespace libais {
24 namespace {
25
26 std::unique_ptr<Ais10> Init(const string &nmea_string) {
27 const string body(GetBody(nmea_string));
28 const int pad = GetPad(nmea_string);
29
30 // TODO(schwehr): Switch to c++14 make_unique.
31 std::unique_ptr<Ais10> msg(new Ais10(body.c_str(), pad));
32 if (!msg || msg->had_error()) {
33 return nullptr;
34 }
35 return msg;
36 }
37
38 void Validate(
39 const Ais10 *msg,
40 const int message_id,
41 const int repeat_indicator,
42 const int mmsi,
43 const int spare,
44 const int dest_mmsi,
45 const int spare2) {
46 ASSERT_NE(nullptr, msg);
47 EXPECT_FALSE(msg->had_error());
48
49 ASSERT_EQ(message_id, msg->message_id);
50 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
51 EXPECT_EQ(mmsi, msg->mmsi);
52 EXPECT_EQ(spare, msg->spare);
53 EXPECT_EQ(dest_mmsi, msg->dest_mmsi);
54 EXPECT_EQ(spare2, msg->spare2);
55 }
56
57 TEST(Ais10Test, DecodeAnything) {
58 std::unique_ptr<Ais10> msg = Init("!AIVDM,1,1,,A,:5Ovc200B=5H,0*43");
59 Validate(msg.get(), 10, 0, 369077000, 0, 1193046, 0);
60 }
61
62 } // namespace
63 } // namespace libais