chore: added config.h.in generated by CMake
[KDIS.git] / test / UnitTests / PDU_FactoryDecoder5.cpp
blob917a677398418ff87f4c6a33f558a89cd4593412
1 #include <iostream>
2 #include "gtest/gtest.h"
4 #include "KDIS/Extras/PDU_Factory.h"
6 #include "KDIS/PDU/Distributed_Emission_Regeneration/Designator_PDU.h"
7 #include "KDIS/PDU/Distributed_Emission_Regeneration/Electromagnetic_Emission_PDU.h"
9 #include "KDIS/PDU/Entity_Info_Interaction/Collision_PDU.h"
10 #include "KDIS/PDU/Entity_Info_Interaction/Entity_State_PDU.h"
12 #include "KDIS/PDU/Logistics/Repair_Complete_PDU.h"
13 #include "KDIS/PDU/Logistics/Repair_Response_PDU.h"
14 #include "KDIS/PDU/Logistics/Resupply_Cancel_PDU.h"
15 #include "KDIS/PDU/Logistics/Resupply_Offer_PDU.h"
16 #include "KDIS/PDU/Logistics/Resupply_Received_PDU.h"
17 #include "KDIS/PDU/Logistics/Service_Request_PDU.h"
19 #include "KDIS/PDU/Radio_Communications/Receiver_PDU.h"
20 #include "KDIS/PDU/Radio_Communications/Signal_PDU.h"
21 #include "KDIS/PDU/Radio_Communications/Transmitter_PDU.h"
23 #include "KDIS/PDU/Simulation_Management/Acknowledge_PDU.h"
24 #include "KDIS/PDU/Simulation_Management/Action_Request_PDU.h"
25 #include "KDIS/PDU/Simulation_Management/Action_Response_PDU.h"
26 #include "KDIS/PDU/Simulation_Management/Comment_PDU.h"
27 #include "KDIS/PDU/Simulation_Management/Create_Entity_PDU.h"
28 #include "KDIS/PDU/Simulation_Management/Data_PDU.h"
29 #include "KDIS/PDU/Simulation_Management/Data_Query_PDU.h"
30 #include "KDIS/PDU/Simulation_Management/Event_Report_PDU.h"
31 #include "KDIS/PDU/Simulation_Management/Remove_Entity_PDU.h"
32 #include "KDIS/PDU/Simulation_Management/Set_Data_PDU.h"
33 #include "KDIS/PDU/Simulation_Management/Start_Resume_PDU.h"
34 #include "KDIS/PDU/Simulation_Management/Stop_Freeze_PDU.h"
36 #include "KDIS/PDU/Warfare/Detonation_PDU.h"
37 #include "KDIS/PDU/Warfare/Fire_PDU.h"
39 using namespace KDIS;
40 using namespace PDU;
41 using namespace UTILS;
43 //////////////////////////////////////////////////////////////////////////
44 // Distributed Emission Regeneration
45 //////////////////////////////////////////////////////////////////////////
47 TEST(PDU_FactoryDecoder5, Designator_PDU)
49 Designator_PDU pduIn;
50 KDataStream stream = pduIn.Encode();
51 PDU_Factory factory;
52 std::unique_ptr<Header> pduOut = factory.Decode(stream);
53 EXPECT_EQ(pduIn, *(Designator_PDU*)pduOut.get());
54 EXPECT_EQ(0, stream.GetBufferSize());
57 TEST(PDU_FactoryDecoder5, Electromagnetic_Emission_PDU)
59 Electromagnetic_Emission_PDU pduIn;
60 KDataStream stream = pduIn.Encode();
61 PDU_Factory factory;
62 std::unique_ptr<Header> pduOut = factory.Decode(stream);
63 EXPECT_EQ(pduIn, *(Electromagnetic_Emission_PDU*)pduOut.get());
64 EXPECT_EQ(0, stream.GetBufferSize());
67 //////////////////////////////////////////////////////////////////////////
68 // Entity Info Interaction
69 //////////////////////////////////////////////////////////////////////////
71 TEST(PDU_FactoryDecoder5, Collision_PDU)
73 Collision_PDU pduIn;
74 KDataStream stream = pduIn.Encode();
75 PDU_Factory factory;
76 std::unique_ptr<Header> pduOut = factory.Decode(stream);
77 EXPECT_EQ(pduIn, *(Collision_PDU*)pduOut.get());
78 EXPECT_EQ(0, stream.GetBufferSize());
81 TEST(PDU_FactoryDecoder5, Entity_State_PDU)
83 Entity_State_PDU pduIn;
84 KDataStream stream = pduIn.Encode();
85 PDU_Factory factory;
86 std::unique_ptr<Header> pduOut = factory.Decode(stream);
87 EXPECT_EQ(pduIn, *(Entity_State_PDU*)pduOut.get());
88 EXPECT_EQ(0, stream.GetBufferSize());
91 //////////////////////////////////////////////////////////////////////////
92 // Logistics
93 //////////////////////////////////////////////////////////////////////////
95 TEST(PDU_FactoryDecoder5, Repair_Complete_PDU)
97 Repair_Complete_PDU pduIn;
98 KDataStream stream = pduIn.Encode();
99 PDU_Factory factory;
100 std::unique_ptr<Header> pduOut = factory.Decode(stream);
101 EXPECT_EQ(pduIn, *(Repair_Complete_PDU*)pduOut.get());
102 EXPECT_EQ(0, stream.GetBufferSize());
105 TEST(PDU_FactoryDecoder5, Repair_Response_PDU)
107 Repair_Response_PDU pduIn;
108 KDataStream stream = pduIn.Encode();
109 PDU_Factory factory;
110 std::unique_ptr<Header> pduOut = factory.Decode(stream);
111 EXPECT_EQ(pduIn, *(Repair_Response_PDU*)pduOut.get());
112 EXPECT_EQ(0, stream.GetBufferSize());
115 TEST(PDU_FactoryDecoder5, Resupply_Cancel_PDU)
117 Resupply_Cancel_PDU pduIn;
118 KDataStream stream = pduIn.Encode();
119 PDU_Factory factory;
120 std::unique_ptr<Header> pduOut = factory.Decode(stream);
121 EXPECT_EQ(pduIn, *(Resupply_Cancel_PDU*)pduOut.get());
122 EXPECT_EQ(0, stream.GetBufferSize());
125 TEST(PDU_FactoryDecoder5, Resupply_Offer_PDU)
127 Resupply_Offer_PDU pduIn;
128 KDataStream stream = pduIn.Encode();
129 PDU_Factory factory;
130 std::unique_ptr<Header> pduOut = factory.Decode(stream);
131 EXPECT_EQ(pduIn, *(Resupply_Offer_PDU*)pduOut.get());
132 EXPECT_EQ(0, stream.GetBufferSize());
135 TEST(PDU_FactoryDecoder5, Resupply_Received_PDU)
137 Resupply_Received_PDU pduIn;
138 KDataStream stream = pduIn.Encode();
139 PDU_Factory factory;
140 std::unique_ptr<Header> pduOut = factory.Decode(stream);
141 EXPECT_EQ(pduIn, *(Resupply_Received_PDU*)pduOut.get());
142 EXPECT_EQ(0, stream.GetBufferSize());
145 TEST(PDU_FactoryDecoder5, Service_Request_PDU)
147 Service_Request_PDU pduIn;
148 KDataStream stream = pduIn.Encode();
149 PDU_Factory factory;
150 std::unique_ptr<Header> pduOut = factory.Decode(stream);
151 EXPECT_EQ(pduIn, *(Service_Request_PDU*)pduOut.get());
152 EXPECT_EQ(0, stream.GetBufferSize());
155 //////////////////////////////////////////////////////////////////////////
156 // Radio Communications
157 //////////////////////////////////////////////////////////////////////////
159 TEST(PDU_FactoryDecoder5, Receiver_PDU)
161 Receiver_PDU pduIn;
162 KDataStream stream = pduIn.Encode();
163 PDU_Factory factory;
164 std::unique_ptr<Header> pduOut = factory.Decode(stream);
165 EXPECT_EQ(pduIn, *(Receiver_PDU*)pduOut.get());
166 EXPECT_EQ(0, stream.GetBufferSize());
169 TEST(PDU_FactoryDecoder5, Signal_PDU)
171 Signal_PDU pduIn;
172 KDataStream stream = pduIn.Encode();
173 PDU_Factory factory;
174 std::unique_ptr<Header> pduOut = factory.Decode(stream);
175 EXPECT_EQ(pduIn, *(Signal_PDU*)pduOut.get());
176 EXPECT_EQ(0, stream.GetBufferSize());
179 TEST(PDU_FactoryDecoder5, Transmitter_PDU)
181 Transmitter_PDU pduIn;
182 KDataStream stream = pduIn.Encode();
183 PDU_Factory factory;
184 std::unique_ptr<Header> pduOut = factory.Decode(stream);
185 EXPECT_EQ(pduIn, *(Transmitter_PDU*)pduOut.get());
186 EXPECT_EQ(0, stream.GetBufferSize());
189 //////////////////////////////////////////////////////////////////////////
190 // Simulation Management
191 //////////////////////////////////////////////////////////////////////////
193 TEST(PDU_FactoryDecoder5, Acknowledge_PDU)
195 Acknowledge_PDU pduIn;
196 KDataStream stream = pduIn.Encode();
197 PDU_Factory factory;
198 std::unique_ptr<Header> pduOut = factory.Decode(stream);
199 EXPECT_EQ(pduIn, *(Acknowledge_PDU*)pduOut.get());
200 EXPECT_EQ(0, stream.GetBufferSize());
203 TEST(PDU_FactoryDecoder5, Action_Request_PDU)
205 Action_Request_PDU pduIn;
206 KDataStream stream = pduIn.Encode();
207 PDU_Factory factory;
208 std::unique_ptr<Header> pduOut = factory.Decode(stream);
209 EXPECT_EQ(pduIn, *(Action_Request_PDU*)pduOut.get());
210 EXPECT_EQ(0, stream.GetBufferSize());
213 TEST(PDU_FactoryDecoder5, Action_Response_PDU)
215 Action_Response_PDU pduIn;
216 KDataStream stream = pduIn.Encode();
217 PDU_Factory factory;
218 std::unique_ptr<Header> pduOut = factory.Decode(stream);
219 EXPECT_EQ(pduIn, *(Action_Response_PDU*)pduOut.get());
220 EXPECT_EQ(0, stream.GetBufferSize());
223 TEST(PDU_FactoryDecoder5, Comment_PDU)
225 Comment_PDU pduIn;
226 KDataStream stream = pduIn.Encode();
227 PDU_Factory factory;
228 std::unique_ptr<Header> pduOut = factory.Decode(stream);
229 EXPECT_EQ(pduIn, *(Comment_PDU*)pduOut.get());
230 EXPECT_EQ(0, stream.GetBufferSize());
233 TEST(PDU_FactoryDecoder5, Create_Entity_PDU)
235 Create_Entity_PDU pduIn;
236 KDataStream stream = pduIn.Encode();
237 PDU_Factory factory;
238 std::unique_ptr<Header> pduOut = factory.Decode(stream);
239 EXPECT_EQ(pduIn, *(Create_Entity_PDU*)pduOut.get());
240 EXPECT_EQ(0, stream.GetBufferSize());
243 TEST(PDU_FactoryDecoder5, Data_PDU)
245 Data_PDU pduIn;
246 KDataStream stream = pduIn.Encode();
247 PDU_Factory factory;
248 std::unique_ptr<Header> pduOut = factory.Decode(stream);
249 EXPECT_EQ(pduIn, *(Data_PDU*)pduOut.get());
250 EXPECT_EQ(0, stream.GetBufferSize());
253 TEST(PDU_FactoryDecoder5, Data_Query_PDU)
255 Data_Query_PDU pduIn;
256 KDataStream stream = pduIn.Encode();
257 PDU_Factory factory;
258 std::unique_ptr<Header> pduOut = factory.Decode(stream);
259 EXPECT_EQ(pduIn, *(Data_Query_PDU*)pduOut.get());
260 EXPECT_EQ(0, stream.GetBufferSize());
263 TEST(PDU_FactoryDecoder5, Event_Report_PDU)
265 Event_Report_PDU pduIn;
266 KDataStream stream = pduIn.Encode();
267 PDU_Factory factory;
268 std::unique_ptr<Header> pduOut = factory.Decode(stream);
269 EXPECT_EQ(pduIn, *(Event_Report_PDU*)pduOut.get());
270 EXPECT_EQ(0, stream.GetBufferSize());
273 TEST(PDU_FactoryDecoder5, Remove_Entity_PDU)
275 Remove_Entity_PDU pduIn;
276 KDataStream stream = pduIn.Encode();
277 PDU_Factory factory;
278 std::unique_ptr<Header> pduOut = factory.Decode(stream);
279 EXPECT_EQ(pduIn, *(Remove_Entity_PDU*)pduOut.get());
280 EXPECT_EQ(0, stream.GetBufferSize());
283 TEST(PDU_FactoryDecoder5, Set_Data_PDU)
285 Set_Data_PDU pduIn;
286 KDataStream stream = pduIn.Encode();
287 PDU_Factory factory;
288 std::unique_ptr<Header> pduOut = factory.Decode(stream);
289 EXPECT_EQ(pduIn, *(Set_Data_PDU*)pduOut.get());
290 EXPECT_EQ(0, stream.GetBufferSize());
293 TEST(PDU_FactoryDecoder5, Start_Resume_PDU)
295 Start_Resume_PDU pduIn;
296 KDataStream stream = pduIn.Encode();
297 PDU_Factory factory;
298 std::unique_ptr<Header> pduOut = factory.Decode(stream);
299 EXPECT_EQ(pduIn, *(Start_Resume_PDU*)pduOut.get());
300 EXPECT_EQ(0, stream.GetBufferSize());
303 TEST(PDU_FactoryDecoder5, Stop_Freeze_PDU)
305 Stop_Freeze_PDU pduIn;
306 KDataStream stream = pduIn.Encode();
307 PDU_Factory factory;
308 std::unique_ptr<Header> pduOut = factory.Decode(stream);
309 EXPECT_EQ(pduIn, *(Stop_Freeze_PDU*)pduOut.get());
310 EXPECT_EQ(0, stream.GetBufferSize());
313 //////////////////////////////////////////////////////////////////////////
314 // Warfare
315 //////////////////////////////////////////////////////////////////////////
317 TEST(PDU_FactoryDecoder5, Detonation_PDU)
319 Detonation_PDU pduIn;
320 KDataStream stream = pduIn.Encode();
321 PDU_Factory factory;
322 std::unique_ptr<Header> pduOut = factory.Decode(stream);
323 EXPECT_EQ(pduIn, *(Detonation_PDU*)pduOut.get());
324 EXPECT_EQ(0, stream.GetBufferSize());
327 TEST(PDU_FactoryDecoder5, Fire_PDU)
329 Fire_PDU pduIn;
330 KDataStream stream = pduIn.Encode();
331 PDU_Factory factory;
332 std::unique_ptr<Header> pduOut = factory.Decode(stream);
333 EXPECT_EQ(pduIn, *(Fire_PDU*)pduOut.get());
334 EXPECT_EQ(0, stream.GetBufferSize());