| 1 | // Test parsing 8:366:*. |
| 2 | |
| 3 | #include <memory> |
| 4 | |
| 5 | #include "gmock/gmock.h" |
| 6 | #include "gmock/gmock-matchers.h" |
| 7 | #include "gtest/gtest.h" |
| 8 | #include "ais.h" |
| 9 | |
| 10 | namespace libais { |
| 11 | namespace { |
| 12 | |
| 13 | void Validate(const Ais8_366_56 *msg, const int repeat_indicator, |
| 14 | const int mmsi, const vector<unsigned char> &encrypted) { |
| 15 | ASSERT_NE(nullptr, msg); |
| 16 | EXPECT_FALSE(msg->had_error()); |
| 17 | |
| 18 | ASSERT_EQ(8, msg->message_id); |
| 19 | EXPECT_EQ(repeat_indicator, msg->repeat_indicator); |
| 20 | EXPECT_EQ(mmsi, msg->mmsi); |
| 21 | EXPECT_EQ(366, msg->dac); |
| 22 | ASSERT_EQ(56, msg->fi); |
| 23 | EXPECT_THAT(msg->encrypted, testing::ElementsAreArray(encrypted)); |
| 24 | } |
| 25 | |
| 26 | TEST(Ais8_366_56Test, DecodeAnything) { |
| 27 | // clang-format off |
| 28 | // !BSVDM,1,1,,B,853>IhQKf6EQFDdajT?AbaAVhHEWebddhqHC5@?=KwisgP00DWjE,0*6D,b003669701,1429315201 NOLINT |
| 29 | // clang-format on |
| 30 | |
| 31 | // TODO(schwehr): use make_unique. |
| 32 | std::unique_ptr<Ais8_366_56> msg(new Ais8_366_56( |
| 33 | "853>IhQKf6EQFDdajT?AbaAVhHEWebddhqHC5@?=KwisgP00DWjE", 0)); |
| 34 | |
| 35 | Validate(msg.get(), 0, 338926018, |
| 36 | {0x65, 0x61, 0x59, 0x4B, 0x29, 0xCA, 0x43, 0xD1, 0xAA, 0x94, 0x66, |
| 37 | 0xC1, 0x85, 0x67, 0xB6, 0xAB, 0x2C, 0xC3, 0x96, 0x13, 0x15, 0x03, |
| 38 | 0xCD, 0x6F, 0xFC, 0x7B, 0xBE, 0x00, 0x00, 0x52, 0x7C, 0x95}); |
| 39 | } |
| 40 | |
| 41 | } // namespace |
| 42 | } // namespace libais |