Debian Codegraph @

src/test/ais25_test.cc

raw symbols SCIP
1 // Test parsing message 25 - Single slot binary message.
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<Ais25> 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<Ais25> msg(new Ais25(body.c_str(), pad));
17 if (!msg || msg->had_error()) {
18 return nullptr;
19 }
20 return msg;
21 }
22
23 void Validate(
24 const Ais25 *msg,
25 const int repeat_indicator,
26 const int mmsi,
27 const bool use_app_id,
28 const bool dest_mmsi_valid,
29 const int dest_mmsi,
30 const int dac,
31 const int fi) {
32 ASSERT_NE(nullptr, msg);
33 EXPECT_FALSE(msg->had_error());
34
35 ASSERT_EQ(25, msg->message_id);
36 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
37 EXPECT_EQ(mmsi, msg->mmsi);
38 EXPECT_EQ(use_app_id, msg->use_app_id);
39 EXPECT_EQ(dest_mmsi_valid, msg->dest_mmsi_valid);
40 EXPECT_EQ(dest_mmsi, msg->dest_mmsi);
41 EXPECT_EQ(dac, msg->dac);
42 EXPECT_EQ(fi, msg->fi);
43 }
44
45 TEST(Ais25Test, DecodeAnything) {
46 std::unique_ptr<Ais25> msg = Init(
47 "!AIVDM,1,1,,B,I6S`3Tg@T0a3REBEsjJcT?wSi0fM,0*02");
48
49 Validate(
50 msg.get(), 0, 440009618, true, true, 874775184, 905, 21);
51 }
52
53 } // namespace
54 } // namespace libais