Debian Codegraph @

src/test/ais5_test.cc

raw symbols SCIP
1 // Test parsing message 5 - Class A static data.
2
3 #include <memory>
4
5 #include "gtest/gtest.h"
6 #include "ais.h"
7
8 namespace libais {
9 namespace {
10
11 void Validate(const Ais5 *msg, const int repeat_indicator, const int mmsi,
12 const int ais_version, const int imo_num, const string callsign,
13 const string name, const int type_and_cargo, const int dim_a,
14 const int dim_b, const int dim_c, const int dim_d,
15 const int fix_type, const int eta_month, const int eta_day,
16 const int eta_hour, const int eta_minute, const float draught,
17 const string destination, const int dte, const int spare) {
18 ASSERT_NE(nullptr, msg);
19 EXPECT_FALSE(msg->had_error());
20
21 ASSERT_EQ(5, msg->message_id);
22 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
23 EXPECT_EQ(mmsi, msg->mmsi);
24 EXPECT_EQ(ais_version, msg->ais_version);
25 EXPECT_EQ(imo_num, msg->imo_num);
26 EXPECT_EQ(callsign, msg->callsign);
27 EXPECT_EQ(name, msg->name);
28 EXPECT_EQ(type_and_cargo, msg->type_and_cargo);
29 EXPECT_EQ(dim_a, msg->dim_a);
30 EXPECT_EQ(dim_b, msg->dim_b);
31 EXPECT_EQ(dim_c, msg->dim_c);
32 EXPECT_EQ(dim_d, msg->dim_d);
33 EXPECT_EQ(fix_type, msg->fix_type);
34 EXPECT_EQ(eta_month, msg->eta_month);
35 EXPECT_EQ(eta_day, msg->eta_day);
36 EXPECT_EQ(eta_hour, msg->eta_hour);
37 EXPECT_EQ(eta_minute, msg->eta_minute);
38 EXPECT_FLOAT_EQ(draught, msg->draught);
39 EXPECT_EQ(destination, msg->destination);
40 EXPECT_EQ(dte, msg->dte);
41 EXPECT_EQ(spare, msg->spare);
42 }
43
44 TEST(Ais5Test, DecodeAnything) {
45 // clang-format off
46 // !SAVDM,2,1,6,A,55NOvQP1u>QIL@O??SL985`u>0EQ18E=>222221J1p`884i6N344Sll1@m80,0*0C,b003669956,1426118503 NOLINT
47 // !SAVDM,2,2,6,A,TRA1iH88880,2*6F,b003669956,1426118503
48 // clang-format on
49
50 std::unique_ptr<Ais5> msg(new Ais5(
51 "55NOvQP1u>QIL@O??SL985`u>0EQ18E=>222221J1p`884i6N344Sll1@m80"
52 "TRA1iH88880",
53 2));
54 Validate(msg.get(), 0, 367525510, 0, 8206870, "WDG3387",
55 "BRAZOS EXPRESS ", 90, 15, 40, 8, 8, 1, 3, 2, 6, 30, 1.2,
56 "PROSPECT BRIDGE ", 0, 0);
57 }
58
59 } // namespace
60 } // namespace libais