Debian Codegraph @

src/test/ais26_test.cc

raw symbols SCIP
1 // Test parsing message 26 - .
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 Ais26 *msg,
13 const int repeat_indicator,
14 const int mmsi,
15 const bool use_app_id,
16 const bool dest_mmsi_valid,
17 const int dest_mmsi,
18 const int dac,
19 const int fi) {
20 ASSERT_NE(nullptr, msg);
21 EXPECT_FALSE(msg->had_error());
22
23 ASSERT_EQ(26, msg->message_id);
24 EXPECT_EQ(repeat_indicator, msg->repeat_indicator);
25 EXPECT_EQ(mmsi, msg->mmsi);
26 EXPECT_EQ(use_app_id, msg->use_app_id);
27 EXPECT_EQ(dest_mmsi_valid, msg->dest_mmsi_valid);
28 EXPECT_EQ(dest_mmsi, msg->dest_mmsi);
29 EXPECT_EQ(dac, msg->dac);
30 EXPECT_EQ(fi, msg->fi);
31 }
32
33 TEST(Ais26Test, DecodeAnything) {
34 // !AIVDM,2,1,2,B,JfgwlGvNwts9?wUfQswQ<gv9Ow7wCl?nwv0wOi=mwd?,0*03
35 // !AIVDM,2,2,2,B,oW8uwNg3wNS3tV,5*71
36 std::unique_ptr<Ais26> msg(new Ais26(
37 "JfgwlGvNwts9?wUfQswQ<gv9Ow7wCl?nwv0wOi=mwd?oW8uwNg3wNS3tV", 5));
38
39 Validate(
40 msg.get(), 2, 989852767, true, true, 666891186, 319, 62);
41
42 // TODO(schwehr): Validate commstate.
43 }
44
45 TEST(Ais26Test, b69511642_TooFewBits_Addressed_UseAppId) {
46 // An addressed message with the use app id flag set, but too few bits
47 // so it does not have the space required for the dac and fi.
48 std::unique_ptr<Ais26> msg(new Ais26("JCwwwJwtbwwwww", 3));
49 EXPECT_TRUE(msg->use_app_id);
50 EXPECT_TRUE(msg->had_error());
51 }
52
53 } // namespace
54 } // namespace libais