General: separation of marav-io as a library
[marnav.git] / test / marnav / ais / Test_ais.cpp
blobdd56af2e8a59ace5a060bfa1018ed4bb62b9d3ef
1 #include <marnav/ais/ais.hpp>
2 #include <gtest/gtest.h>
4 namespace
7 using namespace marnav;
9 class Test_ais : public ::testing::Test
11 public:
12 struct entry {
13 uint8_t value;
14 char c;
17 static const std::vector<entry> ARMORING_ENTRIES;
20 const std::vector<Test_ais::entry> Test_ais::ARMORING_ENTRIES = {
21 {0, '0'},
22 {1, '1'},
23 {2, '2'},
24 {3, '3'},
25 {4, '4'},
26 {5, '5'},
27 {6, '6'},
28 {7, '7'},
29 {8, '8'},
30 {9, '9'},
31 {10, ':'},
32 {11, ';'},
33 {12, '<'},
34 {13, '='},
35 {14, '>'},
36 {15, '?'},
37 {16, '@'},
38 {17, 'A'},
39 {18, 'B'},
40 {19, 'C'},
41 {20, 'D'},
42 {21, 'E'},
43 {22, 'F'},
44 {23, 'G'},
45 {24, 'H'},
46 {25, 'I'},
47 {26, 'J'},
48 {27, 'K'},
49 {28, 'L'},
50 {29, 'M'},
51 {30, 'N'},
52 {31, 'O'},
53 {32, 'P'},
54 {33, 'Q'},
55 {34, 'R'},
56 {35, 'S'},
57 {36, 'T'},
58 {37, 'U'},
59 {38, 'V'},
60 {39, 'W'},
61 {40, '`'},
62 {41, 'a'},
63 {42, 'b'},
64 {43, 'c'},
65 {44, 'd'},
66 {45, 'e'},
67 {46, 'f'},
68 {47, 'g'},
69 {48, 'h'},
70 {49, 'i'},
71 {50, 'j'},
72 {51, 'k'},
73 {52, 'l'},
74 {53, 'm'},
75 {54, 'n'},
76 {55, 'o'},
77 {56, 'p'},
78 {57, 'q'},
79 {58, 'r'},
80 {59, 's'},
81 {60, 't'},
82 {61, 'u'},
83 {62, 'v'},
84 {63, 'w'},
87 class message_zero_bits : public ais::message
89 public:
90 message_zero_bits()
91 : message(ais::message_id::NONE)
95 virtual ais::raw get_data() const override { return ais::raw{}; }
98 TEST_F(Test_ais, make_message)
100 using namespace std;
102 vector<pair<string, uint32_t>> v;
104 // v.push_back(make_pair("55P5TL01VIaAL@7WKO@mBplU@<PDhh000000001S;AJ::4A80?4i@E53", 0));
105 // v.push_back(make_pair("1@0000000000000", 2));
107 // v.push_back(make_pair("177KQJ5000G?tO`K>RA1wUbN0TKH", 0));
109 v.push_back(make_pair("133m@ogP00PD;88MD5MTDww@2D7k", 0));
111 auto result = ais::make_message(v);
114 TEST_F(Test_ais, encode_message_zero_sized_bits)
116 message_zero_bits m;
117 EXPECT_ANY_THROW(ais::encode_message(m));
120 TEST_F(Test_ais, decode_armoring)
122 for (auto const & e : ARMORING_ENTRIES) {
123 EXPECT_EQ(e.value, ais::decode_armoring(e.c));
127 TEST_F(Test_ais, encode_armoring)
129 for (auto const & e : ARMORING_ENTRIES) {
130 EXPECT_EQ(e.c, ais::encode_armoring(e.value));