Debian Codegraph @

src/test/ais21_test.cc

raw symbols SCIP
1 // Test parsing message 21 - ATON Status.
2
3 #include <memory>
4
5 #include "gtest/gtest.h"
6 #include "ais.h"
7
8 namespace libais {
9 namespace {
10
11 void Validate(
12 const Ais21 *msg,
13 const int repeat_indicator,
14 const int mmsi,
15 const int aton_type,
16 const string name,
17 const int position_accuracy,
18 const double x,
19 const double y,
20 const int dim_a,
21 const int dim_b,
22 const int dim_c,
23 const int dim_d,
24 const int fix_type,
25 const int timestamp,
26 const bool off_pos,
27 const int aton_status,
28 const bool raim,
29 const bool virtual_aton,
30 const bool assigned_mode,
31 const int spare,
32 const int spare2) {
33 ASSERT_NE(nullptr, msg);
34 EXPECT_FALSE(msg->had_error());
35
36 ASSERT_EQ(21, msg->message_id);
37 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
38 EXPECT_EQ(mmsi, msg->mmsi);
39 EXPECT_EQ(aton_type, msg->aton_type);
40 EXPECT_EQ(name, msg->name);
41 EXPECT_EQ(position_accuracy, msg->position_accuracy);
42 EXPECT_DOUBLE_EQ(x, msg->position.lng_deg);
43 EXPECT_DOUBLE_EQ(y, msg->position.lat_deg);
44 EXPECT_EQ(dim_a, msg->dim_a);
45 EXPECT_EQ(dim_b, msg->dim_b);
46 EXPECT_EQ(dim_c, msg->dim_c);
47 EXPECT_EQ(dim_d, msg->dim_d);
48 EXPECT_EQ(fix_type, msg->fix_type);
49 EXPECT_EQ(timestamp, msg->timestamp);
50 EXPECT_EQ(off_pos, msg->off_pos);
51 EXPECT_EQ(aton_status, msg->aton_status);
52 EXPECT_EQ(raim, msg->raim);
53 EXPECT_EQ(virtual_aton, msg->virtual_aton);
54 EXPECT_EQ(assigned_mode, msg->assigned_mode);
55 EXPECT_EQ(spare, msg->spare);
56 EXPECT_EQ(spare2, msg->spare2);
57 }
58
59 TEST(Ais21Test, DecodeAnything) {
60 // !SAVDM,1,1,0,B,Evkb9Mq1WV:VQ4Ph94c@6;Q@1a@;ShvA==bd`00003vP000,2*65
61 std::unique_ptr<Ais21> msg(new Ais21(
62 "Evkb9Mq1WV:VQ4Ph94c@6;Q@1a@;ShvA==bd`00003vP000", 2));
63
64 Validate(
65 msg.get(), 3, 993692023, 18, "COLUMBIA RIV LWB CR @", 0,
66 -124.18407833333333, 46.184701666666669, 0, 0, 0, 0, 7, 61, false,
67 0, false, false, false, 0, 0);
68 }
69
70 TEST(Ais21Test, TwoLine) {
71 // !AIVDM,2,1,9,A,ENk`sO70VQ97aRh1T0W72V@611@=FVj<;V5d@00003v,0*50
72 // !AIVDM,2,2,9,A,P0<M0,0*3E
73 std::unique_ptr<Ais21> msg(new Ais21(
74 "ENk`sO70VQ97aRh1T0W72V@611@=FVj<;V5d@00003vP0<M0", 0));
75
76 Validate(
77 msg.get(), 1, 993672060, 14, "AMBROSE CHANNEL LBB 14", 0,
78 -74.009366666666665, 40.527949999999997, 0, 0, 0, 0, 7, 61, false,
79 0, false, false, false, 0, 0);
80 }
81
82 TEST(Ais21Test, Short268BitMessage) {
83 // !AIVDM,1,1,,,ENjV2Bw0`bPQbV::a2hJ00000000L7kPBmfv@1088;v0@,2*20
84 std::unique_ptr<Ais21> msg(new Ais21(
85 "ENjV2Bw0`bPQbV::a2hJ00000000L7kPBmfv@1088;v0@", 2));
86 Validate(
87 msg.get(), 1, 992576075, 30, "AQUACULTURE 4@@@@@@@", 0,
88 12.286666666666667, 65.849149999999995, 1, 1, 1, 1, 7, 60, false,
89 4, false, false, false, 0, 0);
90 }
91
92 } // namespace
93 } // namespace libais