Debian Codegraph @

src/test/ais7_13_test.cc

raw symbols SCIP
1 // Test parsing messages 7 and 13.
2
3 #include <memory>
4
5 #include "gtest/gtest.h"
6 #include "ais.h"
7
8 namespace libais {
9 namespace {
10
11 std::unique_ptr<Ais7_13> Init(const string &nmea_string) {
12 const string body(GetBody(nmea_string));
13 const int pad = GetPad(nmea_string);
14
15 // TODO(schwehr): Switch to c++14 make_unique.
16 std::unique_ptr<Ais7_13> msg(new Ais7_13(body.c_str(), pad));
17 if (!msg || msg->had_error()) {
18 return nullptr;
19 }
20 return msg;
21 }
22
23 void Validate(
24 const Ais7_13 *msg,
25 const int message_id,
26 const int repeat_indicator,
27 const int mmsi,
28 const int spare,
29 const vector<int> dest_mmsi,
30 const vector<int> seq_num) {
31 ASSERT_NE(nullptr, msg);
32 EXPECT_FALSE(msg->had_error());
33
34 ASSERT_EQ(message_id, msg->message_id);
35 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
36 EXPECT_EQ(mmsi, msg->mmsi);
37 EXPECT_EQ(spare, msg->spare);
38 EXPECT_EQ(dest_mmsi, msg->dest_mmsi);
39 EXPECT_EQ(seq_num, msg->seq_num);
40 }
41
42 TEST(Ais713Test, Msg7Length1) {
43 // Tests decoding a length 1 ack.
44 std::unique_ptr<Ais7_13> msg = Init("!AIVDM,1,1,,A,7jvPoD@mMq;U,0*09");
45 ASSERT_NE(nullptr, msg);
46 const vector<int> dest_mmsi = {224257209};
47 const vector<int> seq_num = {1};
48 Validate(msg.get(), 7, 3, 199767889, 0, dest_mmsi, seq_num);
49 }
50
51 } // namespace
52 } // namespace libais