]> git.localhorst.tv Git - blank.git/blob - tst/net/PacketTest.hpp
(shabby) client side handling of messages
[blank.git] / tst / net / PacketTest.hpp
1 #ifndef BLANK_TEST_NET_PACKETTEST_HPP_
2 #define BLANK_TEST_NET_PACKETTEST_HPP_
3
4 #include "model/geometry.hpp"
5 #include "net/Packet.hpp"
6 #include "world/EntityState.hpp"
7
8 #include <cstdint>
9 #include <limits>
10 #include <string>
11 #include <SDL_net.h>
12 #include <glm/glm.hpp>
13 #include <cppunit/extensions/HelperMacros.h>
14
15
16 namespace blank {
17 namespace test {
18
19 class PacketTest
20 : public CppUnit::TestFixture {
21
22 CPPUNIT_TEST_SUITE(PacketTest);
23
24 CPPUNIT_TEST(testSizes);
25 CPPUNIT_TEST(testControl);
26 CPPUNIT_TEST(testPing);
27 CPPUNIT_TEST(testLogin);
28 CPPUNIT_TEST(testJoin);
29 CPPUNIT_TEST(testPart);
30 CPPUNIT_TEST(testPlayerUpdate);
31 CPPUNIT_TEST(testSpawnEntity);
32 CPPUNIT_TEST(testDespawnEntity);
33 CPPUNIT_TEST(testEntityUpdate);
34 CPPUNIT_TEST(testPlayerCorrection);
35 CPPUNIT_TEST(testChunkBegin);
36 CPPUNIT_TEST(testChunkData);
37 CPPUNIT_TEST(testBlockUpdate);
38 CPPUNIT_TEST(testMessage);
39
40 CPPUNIT_TEST_SUITE_END();
41
42 public:
43         void setUp();
44         void tearDown();
45
46         void testSizes();
47         void testControl();
48         void testPing();
49         void testLogin();
50         void testJoin();
51         void testPart();
52         void testPlayerUpdate();
53         void testSpawnEntity();
54         void testDespawnEntity();
55         void testEntityUpdate();
56         void testPlayerCorrection();
57         void testChunkBegin();
58         void testChunkData();
59         void testBlockUpdate();
60         void testMessage();
61
62 private:
63         static void AssertPacket(
64                 const std::string &name,
65                 std::uint8_t expected_type,
66                 std::size_t expected_length,
67                 const Packet::Payload &actual);
68         static void AssertPacket(
69                 const std::string &name,
70                 std::uint8_t expected_type,
71                 std::size_t min_length,
72                 std::size_t max_length,
73                 const Packet::Payload &actual);
74
75         static void AssertEqual(
76                 const std::string &message,
77                 const EntityState &expected,
78                 const EntityState &actual);
79         static void AssertEqual(
80                 const std::string &message,
81                 const AABB &expected,
82                 const AABB &actual);
83         static void AssertEqual(
84                 const std::string &message,
85                 const glm::ivec3 &expected,
86                 const glm::ivec3 &actual);
87         static void AssertEqual(
88                 const std::string &message,
89                 const glm::vec3 &expected,
90                 const glm::vec3 &actual,
91                 float epsilon = std::numeric_limits<float>::epsilon());
92         static void AssertEqual(
93                 const std::string &message,
94                 const glm::quat &expected,
95                 const glm::quat &actual);
96
97 private:
98         UDPpacket udp_pack;
99
100 };
101
102 }
103 }
104
105 #endif