Debian Codegraph @

src/test/ais15_test.cc

raw symbols SCIP
1 // Test parsing message 15 - interrogation.
2
3 // TODO(schwehr): Decode these. They might not be valid, but they were
4 // received in the wild.
5
6 // !AIVDM,1,1,,A,?WR1>7k9avqh,2*7A - Undersized.
7 // !AIVDM,1,1,,A,?h3OwoiG`<q8D00,4*6E
8 // !AIVDM,1,1,,B,?8b=jTdUnktVmJL:,0*04
9 // !AIVDM,1,1,,B,?W4ekcOPOto8F;DP,2*0C
10 // !AIVDM,1,1,,B,?nvVNUjhG7cJo7vur0,4*09
11 // !AIVDM,1,1,,A,?>G3PvUawgnkbBgMvv0,2*6C
12 // !AIVDM,1,1,,B,?lGvAlVFCftW>GaG@eUi,0*3A
13 // !AIVDM,1,1,,A,?NcwsQvf7dnuQDM9m=vM<0,4*3B
14 // !AIVDM,1,1,,B,?7e4=glwoQvwR;o48vSOOk<,2*78
15 // !AIVDM,1,1,,A,?v;uNnv4urLSN=kKOrNVHmm?,0*5A
16 // !AIVDM,1,1,,A,?7VN8RKqwwTo=foWV7iwt?vLp,4*44
17 // !AIVDM,1,1,,A,?o999?O>k`W;WJladb?LowMba0,4*61
18 // !AIVDM,1,1,,A,?uUkOnmBwhJUwMM4<q7EK?tEdP0,2*63
19 // !AIVDM,1,1,,A,?CAgsD0024s9nQN:iati9Pth0D05,0*5D
20
21 #include <memory>
22
23 #include "gtest/gtest.h"
24 #include "ais.h"
25
26 namespace libais {
27 namespace {
28
29 std::unique_ptr<Ais15> Init(const string &nmea_string) {
30 const string body(GetBody(nmea_string));
31 const int pad = GetPad(nmea_string);
32
33 // TODO(schwehr): Switch to c++14 make_unique.
34 std::unique_ptr<Ais15> msg(new Ais15(body.c_str(), pad));
35 if (!msg || msg->had_error()) {
36 return nullptr;
37 }
38 return msg;
39 }
40
41 void Validate(
42 const Ais15 *msg,
43 const int repeat_indicator,
44 const int mmsi,
45 const int spare,
46 const int mmsi_1,
47 const int msg_1_1,
48 const int slot_offset_1_1,
49 const int spare2,
50 const int dest_msg_1_2,
51 const int slot_offset_1_2,
52 const int spare3,
53 const int mmsi_2,
54 const int msg_2,
55 const int slot_offset_2,
56 const int spare4) {
57 ASSERT_NE(nullptr, msg);
58 EXPECT_FALSE(msg->had_error());
59
60 ASSERT_EQ(15, msg->message_id);
61 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
62 EXPECT_EQ(mmsi, msg->mmsi);
63 EXPECT_EQ(spare, msg->spare);
64 EXPECT_EQ(mmsi_1, msg->mmsi_1);
65 EXPECT_EQ(msg_1_1, msg->msg_1_1);
66 EXPECT_EQ(slot_offset_1_1, msg->slot_offset_1_1);
67 EXPECT_EQ(spare2, msg->spare2);
68 EXPECT_EQ(dest_msg_1_2, msg->dest_msg_1_2);
69 EXPECT_EQ(slot_offset_1_2, msg->slot_offset_1_2);
70 EXPECT_EQ(spare3, msg->spare3);
71 EXPECT_EQ(mmsi_2, msg->mmsi_2);
72 EXPECT_EQ(msg_2, msg->msg_2);
73 EXPECT_EQ(slot_offset_2, msg->slot_offset_2);
74 EXPECT_EQ(spare4, msg->spare4);
75 }
76
77
78 TEST(Ais15Test, DecodeAnything) {
79 std::unique_ptr<Ais15> msg = Init(
80 "!SAVDM,1,1,,B,?03OwnB0ACVlD00,2*59");
81
82 Validate(
83 msg.get(), 0, 3669977, 0, 538005101, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0);
84 }
85
86 } // namespace
87 } // namespace libais