]> git.localhorst.tv Git - blank.git/blob - tst/net/PacketTest.cpp
update entity model on state change
[blank.git] / tst / net / PacketTest.cpp
1 #include "PacketTest.hpp"
2
3 #include "model/Model.hpp"
4 #include "world/Entity.hpp"
5
6 CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::PacketTest);
7
8 using namespace std;
9
10 namespace blank {
11 namespace test {
12
13 void PacketTest::setUp() {
14         udp_pack.data = new Uint8[sizeof(Packet)];
15         udp_pack.maxlen = sizeof(Packet);
16 }
17
18 void PacketTest::tearDown() {
19         delete[] udp_pack.data;
20 }
21
22 namespace {
23
24 static constexpr uint32_t TEST_TAG = 0xFB1AB1AF;
25
26 }
27
28 void PacketTest::testSizes() {
29         CPPUNIT_ASSERT_EQUAL_MESSAGE(
30                 "unexpected size of vec3",
31                 size_t(12), sizeof(glm::vec3)
32         );
33         CPPUNIT_ASSERT_EQUAL_MESSAGE(
34                 "unexpected size of vec3i",
35                 size_t(12), sizeof(glm::ivec3)
36         );
37 }
38
39 void PacketTest::testControl() {
40         Packet::TControl ctrl{ 0, 10, 0 };
41
42         CPPUNIT_ASSERT_MESSAGE(
43                 "TControl should ack the packet in the ack field",
44                 ctrl.Acks(10)
45         );
46         CPPUNIT_ASSERT_MESSAGE(
47                 "TControl should ack the packet in the future",
48                 !ctrl.Acks(11)
49         );
50         CPPUNIT_ASSERT_MESSAGE(
51                 "TControl should not ack a packet in the distant past",
52                 !ctrl.Acks(-30)
53         );
54         CPPUNIT_ASSERT_MESSAGE(
55                 "TControl should not ack the previous packet if the bitfield is 0",
56                 !ctrl.Acks(9)
57         );
58         CPPUNIT_ASSERT_EQUAL_MESSAGE(
59                 "TControl's acks should begin at the packet in the ack field",
60                 uint16_t(10), ctrl.AckBegin()
61         );
62         CPPUNIT_ASSERT_EQUAL_MESSAGE(
63                 "TControl's acks should end 33 packets before the one in the ack field",
64                 uint16_t(-23), ctrl.AckEnd()
65         );
66         ctrl.hist = 1;
67         CPPUNIT_ASSERT_MESSAGE(
68                 "TControl should ack the previous packet if the bitfield is 1",
69                 ctrl.Acks(9)
70         );
71         ctrl.hist = 2;
72         CPPUNIT_ASSERT_MESSAGE(
73                 "TControl should not ack the previous packet if the bitfield is 2",
74                 !ctrl.Acks(9)
75         );
76         CPPUNIT_ASSERT_MESSAGE(
77                 "TControl should ack the packet before the previous one if the bitfield is 2",
78                 ctrl.Acks(8)
79         );
80 }
81
82 void PacketTest::testPing() {
83         auto pack = Packet::Make<Packet::Ping>(udp_pack);
84         AssertPacket("Ping", 0, 0, pack);
85 }
86
87 void PacketTest::testLogin() {
88         auto pack = Packet::Make<Packet::Login>(udp_pack);
89         AssertPacket("Login", 1, 0, 32, pack);
90
91         string write_name = "test";
92         string read_name;
93         pack.WritePlayerName(write_name);
94         pack.ReadPlayerName(read_name);
95         CPPUNIT_ASSERT_EQUAL_MESSAGE(
96                 "player name not correctly transported in Login packet",
97                 write_name, read_name
98         );
99
100         write_name = "0123456789012345678901234567890123456789";
101         pack.WritePlayerName(write_name);
102         pack.ReadPlayerName(read_name);
103         CPPUNIT_ASSERT_EQUAL_MESSAGE(
104                 "player name not correctly truncated in Login packet",
105                 write_name.substr(0, 32), read_name
106         );
107 }
108
109 void PacketTest::testJoin() {
110         auto pack = Packet::Make<Packet::Join>(udp_pack);
111         AssertPacket("Join", 2, 47, 78, pack);
112
113         Entity write_entity;
114         write_entity.ID(534574);
115         EntityState write_state;
116         write_state.chunk_pos = { 7, 2, -3 };
117         write_state.block_pos = { 1.5f, 0.9f, 12.0f };
118         write_state.velocity = { 0.025f, 0.001f, 0.0f };
119         write_state.orient = { 1.0f, 0.0f, 0.0f, 0.0f };
120         write_state.pitch = 0.3f;
121         write_state.yaw = -2.3f;
122         write_entity.SetState(write_state);
123         uint32_t read_id = 0;
124         EntityState read_state;
125         pack.WritePlayer(write_entity);
126
127         pack.ReadPlayerID(read_id);
128         CPPUNIT_ASSERT_EQUAL_MESSAGE(
129                 "player entity ID not correctly transported in Join packet",
130                 write_entity.ID(), read_id
131         );
132         pack.ReadPlayerState(read_state);
133         AssertEqual(
134                 "player entity state not correctly transported in Join packet",
135                 write_entity.GetState(), read_state
136         );
137
138         string write_name = "test";
139         string read_name;
140         pack.WriteWorldName(write_name);
141         pack.ReadWorldName(read_name);
142         CPPUNIT_ASSERT_EQUAL_MESSAGE(
143                 "world name not correctly transported in Join packet",
144                 write_name, read_name
145         );
146
147         write_name = "0123456789012345678901234567890123456789";
148         pack.WriteWorldName(write_name);
149         pack.ReadWorldName(read_name);
150         CPPUNIT_ASSERT_EQUAL_MESSAGE(
151                 "world name not correctly truncated in Join packet",
152                 write_name.substr(0, 32), read_name
153         );
154 }
155
156 void PacketTest::testPart() {
157         auto pack = Packet::Make<Packet::Part>(udp_pack);
158         AssertPacket("Part", 3, 0, pack);
159 }
160
161 void PacketTest::testPlayerUpdate() {
162         auto pack = Packet::Make<Packet::PlayerUpdate>(udp_pack);
163         AssertPacket("PlayerUpdate", 4, 50, pack);
164
165         EntityState write_state;
166         write_state.chunk_pos = { 7, 2, -3 };
167         write_state.block_pos = { 1.5f, 0.9f, 12.0f };
168         write_state.velocity = { 0.025f, 0.001f, 0.0f };
169         write_state.orient = { 1.0f, 0.0f, 0.0f, 0.0f };
170         glm::vec3 write_movement(0.5f, -1.0f, 1.0f);
171         uint8_t write_actions = 0x05;
172         uint8_t write_slot = 3;
173         pack.WritePredictedState(write_state);
174         pack.WriteMovement(write_movement);
175         pack.WriteActions(write_actions);
176         pack.WriteSlot(write_slot);
177
178         EntityState read_state;
179         glm::vec3 read_movement;
180         uint8_t read_actions;
181         uint8_t read_slot;
182         pack.ReadPredictedState(read_state);
183         pack.ReadMovement(read_movement);
184         pack.ReadActions(read_actions);
185         pack.ReadSlot(read_slot);
186         AssertEqual(
187                 "player predicted entity state not correctly transported in PlayerUpdate packet",
188                 write_state, read_state
189         );
190         AssertEqual(
191                 "player movement input not correctly transported in PlayerUpdate packet",
192                 write_movement, read_movement, 0.0001f
193         );
194         CPPUNIT_ASSERT_EQUAL_MESSAGE(
195                 "player actions not correctly transported in PlayerUpdate packet",
196                 int(write_actions), int(read_actions)
197         );
198         CPPUNIT_ASSERT_EQUAL_MESSAGE(
199                 "player inventory slot not correctly transported in PlayerUpdate packet",
200                 int(write_slot), int(read_slot)
201         );
202 }
203
204 void PacketTest::testSpawnEntity() {
205         auto pack = Packet::Make<Packet::SpawnEntity>(udp_pack);
206         AssertPacket("SpawnEntity", 5, 79, 110, pack);
207
208         Entity write_entity;
209         write_entity.ID(534574);
210         Model model;
211         model.ID(23);
212         model.Enumerate();
213         model.Instantiate(write_entity.GetModel());
214         EntityState write_state;
215         write_state.chunk_pos = { 7, 2, -3 };
216         write_state.block_pos = { 1.5f, 0.9f, 12.0f };
217         write_state.velocity = { 0.025f, 0.001f, 0.0f };
218         write_state.orient = { 1.0f, 0.0f, 0.0f, 0.0f };
219         write_state.pitch = 0.3f;
220         write_state.yaw = -2.3f;
221         write_entity.SetState(write_state);
222         write_entity.Bounds({{ -1, -1, -1 }, { 1, 1, 1 }});
223         write_entity.WorldCollidable(true);
224         write_entity.Name("blah");
225         pack.WriteEntity(write_entity);
226
227         uint32_t entity_id;
228         uint32_t model_id;
229         Entity read_entity;
230         pack.ReadEntityID(entity_id);
231         pack.ReadModelID(model_id);
232         pack.ReadEntity(read_entity);
233
234         CPPUNIT_ASSERT_EQUAL_MESSAGE(
235                 "entity ID not correctly transported in SpawnEntity packet",
236                 write_entity.ID(), entity_id
237         );
238         CPPUNIT_ASSERT_EQUAL_MESSAGE(
239                 "model ID not correctly transported in SpawnEntity packet",
240                 write_entity.GetModel().GetModel().ID(), model_id
241         );
242         AssertEqual(
243                 "entity state not correctly transported in PlayerUpdate packet",
244                 write_entity.GetState(), read_entity.GetState()
245         );
246         AssertEqual(
247                 "entity bounds not correctly transported in PlayerUpdate packet",
248                 write_entity.Bounds(), read_entity.Bounds()
249         );
250         CPPUNIT_ASSERT_MESSAGE(
251                 "entity flags not correctly transported in SpawnEntity packet",
252                 read_entity.WorldCollidable()
253         );
254         CPPUNIT_ASSERT_EQUAL_MESSAGE(
255                 "entity name not correctly transported in SpawnEntity packet",
256                 write_entity.Name(), read_entity.Name()
257         );
258 }
259
260 void PacketTest::testDespawnEntity() {
261         auto pack = Packet::Make<Packet::DespawnEntity>(udp_pack);
262         AssertPacket("DespawnEntity", 6, 4, pack);
263
264         uint32_t write_id = 5437;
265         uint32_t read_id;
266         pack.WriteEntityID(write_id);
267         pack.ReadEntityID(read_id);
268
269         CPPUNIT_ASSERT_EQUAL_MESSAGE(
270                 "entity ID not correctly transported in DespawnEntity packet",
271                 write_id, read_id
272         );
273 }
274
275 void PacketTest::testEntityUpdate() {
276         auto pack = Packet::Make<Packet::EntityUpdate>(udp_pack);
277         AssertPacket("EntityUpdate", 7, 16, 460, pack);
278
279         pack.length = Packet::EntityUpdate::GetSize(3);
280         CPPUNIT_ASSERT_EQUAL_MESSAGE(
281                 "length not correctly set in EntityUpdate packet",
282                 size_t(16 + 3 * 37), pack.length
283         );
284
285         uint32_t write_count = 3;
286         glm::ivec3 write_base(8, -15, 1);
287         pack.WriteEntityCount(write_count);
288         pack.WriteChunkBase(write_base);
289
290         uint32_t read_count;
291         glm::ivec3 read_base;
292         pack.ReadEntityCount(read_count);
293         pack.ReadChunkBase(read_base);
294
295         CPPUNIT_ASSERT_EQUAL_MESSAGE(
296                 "entity count not correctly transported in EntityUpdate packet",
297                 write_count, read_count
298         );
299         AssertEqual(
300                 "chunk base not correctly transported in EntityUpdate packet",
301                 write_base, read_base
302         );
303
304         Entity write_entity;
305         write_entity.ID(8567234);
306         EntityState write_state;
307         write_state.chunk_pos = { 7, 2, -3 };
308         write_state.block_pos = { 1.5f, 0.9f, 12.0f };
309         write_state.velocity = { 0.025f, 0.001f, 0.0f };
310         write_state.orient = { 1.0f, 0.0f, 0.0f, 0.0f };
311         write_state.pitch = 0.3f;
312         write_state.yaw = -2.3f;
313         write_entity.SetState(write_state);
314         pack.WriteEntity(write_entity, write_base, 1);
315         pack.WriteEntity(write_entity, write_base, 0);
316         pack.WriteEntity(write_entity, write_base, 2);
317
318         uint32_t read_id;
319         EntityState read_state;
320         pack.ReadEntityID(read_id, 1);
321         pack.ReadEntityState(read_state, write_base, 1);
322         CPPUNIT_ASSERT_EQUAL_MESSAGE(
323                 "entity ID not correctly transported in EntityUpdate packet",
324                 write_entity.ID(), read_id
325         );
326         AssertEqual(
327                 "entity state not correctly transported in EntityUpdate packet",
328                 write_entity.GetState(), read_state
329         );
330 }
331
332 void PacketTest::testPlayerCorrection() {
333         auto pack = Packet::Make<Packet::PlayerCorrection>(udp_pack);
334         AssertPacket("PlayerCorrection", 8, 44, pack);
335
336         uint16_t write_seq = 50050;
337         uint16_t read_seq;
338         pack.WritePacketSeq(write_seq);
339         pack.ReadPacketSeq(read_seq);
340         CPPUNIT_ASSERT_EQUAL_MESSAGE(
341                 "packet sequence not correctly transported in PlayerCorrection packet",
342                 write_seq, read_seq
343         );
344
345         Entity write_entity;
346         EntityState write_state;
347         write_state.chunk_pos = { 7, 2, -3 };
348         write_state.block_pos = { 1.5f, 0.9f, 12.0f };
349         write_state.velocity = { 0.025f, 0.001f, 0.0f };
350         write_state.orient = { 1.0f, 0.0f, 0.0f, 0.0f };
351         write_state.pitch = 0.3f;
352         write_state.yaw = -2.3f;
353         write_entity.SetState(write_state);
354         pack.WritePlayer(write_entity);
355
356         EntityState read_state;
357         pack.ReadPlayerState(read_state);
358         AssertEqual(
359                 "entity state not correctly transported in PlayerCorrection packet",
360                 write_entity.GetState(), read_state
361         );
362 }
363
364 void PacketTest::testChunkBegin() {
365         auto pack = Packet::Make<Packet::ChunkBegin>(udp_pack);
366         AssertPacket("ChunkBegin", 9, 24, pack);
367
368         uint32_t write_id = 532;
369         uint32_t write_flags = 9864328;
370         glm::ivec3 write_pos = { -6, 15, 38 };
371         uint32_t write_size = 4097;
372
373         pack.WriteTransmissionId(write_id);
374         pack.WriteFlags(write_flags);
375         pack.WriteChunkCoords(write_pos);
376         pack.WriteDataSize(write_size);
377
378         uint32_t read_id;
379         uint32_t read_flags;
380         glm::ivec3 read_pos;
381         uint32_t read_size;
382
383         pack.ReadTransmissionId(read_id);
384         pack.ReadFlags(read_flags);
385         pack.ReadChunkCoords(read_pos);
386         pack.ReadDataSize(read_size);
387
388         CPPUNIT_ASSERT_EQUAL_MESSAGE(
389                 "transmission ID not correctly transported in ChunkBegin packet",
390                 write_id, read_id
391         );
392         CPPUNIT_ASSERT_EQUAL_MESSAGE(
393                 "flags not correctly transported in ChunkBegin packet",
394                 write_flags, read_flags
395         );
396         AssertEqual(
397                 "chunk coordinates not correctly transported in ChunkBegin packet",
398                 write_pos, read_pos
399         );
400         CPPUNIT_ASSERT_EQUAL_MESSAGE(
401                 "data size not correctly transported in ChunkBegin packet",
402                 write_size, read_size
403         );
404 }
405
406 void PacketTest::testChunkData() {
407         auto pack = Packet::Make<Packet::ChunkData>(udp_pack);
408         AssertPacket("ChunkData", 10, 12, 484, pack);
409
410         constexpr size_t block_size = 97;
411
412         uint32_t write_id = 6743124;
413         uint32_t write_offset = 8583;
414         uint32_t write_size = block_size;
415         uint8_t write_data[block_size];
416         memset(write_data, 'X', block_size);
417
418         pack.WriteTransmissionId(write_id);
419         pack.WriteDataOffset(write_offset);
420         pack.WriteDataSize(write_size);
421         pack.WriteData(write_data, write_size);
422
423         uint32_t read_id;
424         uint32_t read_offset;
425         uint32_t read_size;
426         uint8_t read_data[block_size];
427
428         pack.ReadTransmissionId(read_id);
429         pack.ReadDataOffset(read_offset);
430         pack.ReadDataSize(read_size);
431         pack.ReadData(read_data, read_size);
432
433         CPPUNIT_ASSERT_EQUAL_MESSAGE(
434                 "transmission ID not correctly transported in ChunkData packet",
435                 write_id, read_id
436         );
437         CPPUNIT_ASSERT_EQUAL_MESSAGE(
438                 "data offset not correctly transported in ChunkData packet",
439                 write_offset, read_offset
440         );
441         CPPUNIT_ASSERT_EQUAL_MESSAGE(
442                 "data size not correctly transported in ChunkData packet",
443                 write_size, read_size
444         );
445         CPPUNIT_ASSERT_EQUAL_MESSAGE(
446                 "raw data not correctly transported in ChunkData packet",
447                 string(write_data, write_data + write_size), string(read_data, read_data + read_size)
448         );
449 }
450
451 void PacketTest::testBlockUpdate() {
452         auto pack = Packet::Make<Packet::BlockUpdate>(udp_pack);
453         AssertPacket("BlockUpdate", 11, 16, 484, pack);
454
455         pack.length = Packet::BlockUpdate::GetSize(3);
456         CPPUNIT_ASSERT_EQUAL_MESSAGE(
457                 "length not correctly set in BlockUpdate packet",
458                 size_t(16 + 3 * 6), pack.length
459         );
460
461         glm::ivec3 write_coords(432, -325, 99998);
462         uint32_t write_count = 3;
463         uint16_t write_index = 432;
464         Block write_block(324, Block::FACE_DOWN, Block::TURN_AROUND);
465
466         pack.WriteChunkCoords(write_coords);
467         pack.WriteBlockCount(write_count);
468         pack.WriteIndex(write_index, 1);
469         pack.WriteBlock(write_block, 1);
470         pack.WriteIndex(write_index, 0);
471         pack.WriteBlock(write_block, 0);
472         pack.WriteIndex(write_index, 2);
473         pack.WriteBlock(write_block, 2);
474
475         glm::ivec3 read_coords;
476         uint32_t read_count;
477         uint16_t read_index;
478         Block read_block;
479
480         pack.ReadChunkCoords(read_coords);
481         pack.ReadBlockCount(read_count);
482         pack.ReadIndex(read_index, 1);
483         pack.ReadBlock(read_block, 1);
484
485         AssertEqual(
486                 "chunk coordinates not correctly transported in BlockUpdate packet",
487                 write_coords, read_coords
488         );
489         CPPUNIT_ASSERT_EQUAL_MESSAGE(
490                 "block count not correctly transported in BlockUpdate packet",
491                 write_count, read_count
492         );
493         CPPUNIT_ASSERT_EQUAL_MESSAGE(
494                 "block index not correctly transported in BlockUpdate packet",
495                 write_index, read_index
496         );
497         CPPUNIT_ASSERT_EQUAL_MESSAGE(
498                 "block type not correctly transported in BlockUpdate packet",
499                 write_block.type, read_block.type
500         );
501         CPPUNIT_ASSERT_EQUAL_MESSAGE(
502                 "block face not correctly transported in BlockUpdate packet",
503                 write_block.GetFace(), read_block.GetFace()
504         );
505         CPPUNIT_ASSERT_EQUAL_MESSAGE(
506                 "block turn not correctly transported in BlockUpdate packet",
507                 write_block.GetTurn(), read_block.GetTurn()
508         );
509 }
510
511 void PacketTest::testMessage() {
512         auto pack = Packet::Make<Packet::Message>(udp_pack);
513         AssertPacket("Message", 12, 6, 455, pack);
514
515         const uint8_t write_type = 1;
516         const uint32_t write_ref = 6433235;
517         const string write_msg("hello, world");
518
519         pack.length = Packet::Message::GetSize(write_msg);
520         CPPUNIT_ASSERT_EQUAL_MESSAGE(
521                 "length not correctly set in BlockUpdate packet",
522                 size_t(5 + write_msg.size() + 1), pack.length
523         );
524
525         pack.WriteType(write_type);
526         pack.WriteReferral(write_ref);
527         pack.WriteMessage(write_msg);
528
529         uint8_t read_type = 5;
530         uint32_t read_ref = 884373;
531         string read_msg;
532
533         pack.ReadType(read_type);
534         pack.ReadReferral(read_ref);
535         pack.ReadMessage(read_msg);
536
537         CPPUNIT_ASSERT_EQUAL_MESSAGE(
538                 "type not correctly transported in Message packet",
539                 write_type, read_type
540         );
541         CPPUNIT_ASSERT_EQUAL_MESSAGE(
542                 "referral not correctly transported in Message packet",
543                 write_ref, read_ref
544         );
545         CPPUNIT_ASSERT_EQUAL_MESSAGE(
546                 "message not correctly transported in Message packet",
547                 write_msg, read_msg
548         );
549 }
550
551
552 void PacketTest::AssertPacket(
553         const string &name,
554         uint8_t expected_type,
555         size_t expected_length,
556         const Packet::Payload &actual
557 ) {
558         CPPUNIT_ASSERT_EQUAL_MESSAGE(
559                 name + " packet not correctly tagged",
560                 TEST_TAG, actual.GetHeader().tag
561         );
562         CPPUNIT_ASSERT_EQUAL_MESSAGE(
563                 "wrong type code for " + name + " packet",
564                 int(expected_type), int(actual.GetHeader().type)
565         );
566         CPPUNIT_ASSERT_EQUAL_MESSAGE(
567                 "bad payload length for " + name + " packet",
568                 expected_length, actual.length
569         );
570 }
571
572 void PacketTest::AssertPacket(
573         const string &name,
574         uint8_t expected_type,
575         size_t min_length,
576         size_t max_length,
577         const Packet::Payload &actual
578 ) {
579         CPPUNIT_ASSERT_EQUAL_MESSAGE(
580                 name + " packet not correctly tagged",
581                 TEST_TAG, actual.GetHeader().tag
582         );
583         CPPUNIT_ASSERT_EQUAL_MESSAGE(
584                 "wrong type code for " + name + " packet",
585                 expected_type, actual.GetHeader().type
586         );
587         CPPUNIT_ASSERT_MESSAGE(
588                 "bad payload length for " + name + " packet",
589                 actual.length >= min_length && actual.length <= max_length
590         );
591 }
592
593 void PacketTest::AssertEqual(
594         const string &message,
595         const EntityState &expected,
596         const EntityState &actual
597 ) {
598         AssertEqual(
599                 message + ": bad chunk position",
600                 expected.chunk_pos, actual.chunk_pos
601         );
602         AssertEqual(
603                 message + ": bad block position",
604                 expected.block_pos, actual.block_pos, 16.0f/65535.0f // that's about the max accuracy that packing's going to give us
605         );
606         AssertEqual(
607                 message + ": bad velocity",
608                 expected.velocity, actual.velocity
609         );
610         AssertEqual(
611                 message + ": bad orientation",
612                 expected.orient, actual.orient
613         );
614         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
615                 message + ": bad pitch",
616                 expected.pitch, actual.pitch, PI/65534.0f
617         );
618         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
619                 message + ": bad yaw",
620                 expected.yaw, actual.yaw, PI/32767.0f
621         );
622 }
623
624 void PacketTest::AssertEqual(
625         const string &message,
626         const AABB &expected,
627         const AABB &actual
628 ) {
629         AssertEqual(
630                 message + ": bad lower bound",
631                 expected.min, actual.min
632         );
633         AssertEqual(
634                 message + ": bad upper bound",
635                 expected.max, actual.max
636         );
637 }
638
639 void PacketTest::AssertEqual(
640         const string &message,
641         const glm::ivec3 &expected,
642         const glm::ivec3 &actual
643 ) {
644         CPPUNIT_ASSERT_EQUAL_MESSAGE(
645                 message + " (X component)",
646                 expected.x, actual.x
647         );
648         CPPUNIT_ASSERT_EQUAL_MESSAGE(
649                 message + " (Y component)",
650                 expected.y, actual.y
651         );
652         CPPUNIT_ASSERT_EQUAL_MESSAGE(
653                 message + " (Z component)",
654                 expected.z, actual.z
655         );
656 }
657
658 void PacketTest::AssertEqual(
659         const string &message,
660         const glm::vec3 &expected,
661         const glm::vec3 &actual,
662         float epsilon
663 ) {
664         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
665                 message + " (X component)",
666                 expected.x, actual.x, epsilon
667         );
668         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
669                 message + " (Y component)",
670                 expected.y, actual.y, epsilon
671         );
672         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
673                 message + " (Z component)",
674                 expected.z, actual.z, epsilon
675         );
676 }
677
678 void PacketTest::AssertEqual(
679         const string &message,
680         const glm::quat &expected,
681         const glm::quat &actual
682 ) {
683         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
684                 message + " (W component)",
685                 expected.w, actual.w, numeric_limits<float>::epsilon()
686         );
687         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
688                 message + " (X component)",
689                 expected.x, actual.x, numeric_limits<float>::epsilon()
690         );
691         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
692                 message + " (Y component)",
693                 expected.y, actual.y, numeric_limits<float>::epsilon()
694         );
695         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
696                 message + " (Z component)",
697                 expected.z, actual.z, numeric_limits<float>::epsilon()
698         );
699 }
700
701 }
702 }