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