]> git.localhorst.tv Git - blank.git/blob - tst/net/PacketTest.hpp
transmit player input from client to server
[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(testControl);
25 CPPUNIT_TEST(testPing);
26 CPPUNIT_TEST(testLogin);
27 CPPUNIT_TEST(testJoin);
28 CPPUNIT_TEST(testPart);
29 CPPUNIT_TEST(testPlayerUpdate);
30 CPPUNIT_TEST(testSpawnEntity);
31 CPPUNIT_TEST(testDespawnEntity);
32 CPPUNIT_TEST(testEntityUpdate);
33 CPPUNIT_TEST(testPlayerCorrection);
34 CPPUNIT_TEST(testChunkBegin);
35 CPPUNIT_TEST(testChunkData);
36
37 CPPUNIT_TEST_SUITE_END();
38
39 public:
40         void setUp();
41         void tearDown();
42
43         void testControl();
44         void testPing();
45         void testLogin();
46         void testJoin();
47         void testPart();
48         void testPlayerUpdate();
49         void testSpawnEntity();
50         void testDespawnEntity();
51         void testEntityUpdate();
52         void testPlayerCorrection();
53         void testChunkBegin();
54         void testChunkData();
55
56 private:
57         static void AssertPacket(
58                 const std::string &name,
59                 std::uint8_t expected_type,
60                 std::size_t expected_length,
61                 const Packet::Payload &actual);
62         static void AssertPacket(
63                 const std::string &name,
64                 std::uint8_t expected_type,
65                 std::size_t min_length,
66                 std::size_t max_length,
67                 const Packet::Payload &actual);
68
69         static void AssertEqual(
70                 const std::string &message,
71                 const EntityState &expected,
72                 const EntityState &actual);
73         static void AssertEqual(
74                 const std::string &message,
75                 const AABB &expected,
76                 const AABB &actual);
77         static void AssertEqual(
78                 const std::string &message,
79                 const glm::ivec3 &expected,
80                 const glm::ivec3 &actual);
81         static void AssertEqual(
82                 const std::string &message,
83                 const glm::vec3 &expected,
84                 const glm::vec3 &actual,
85                 float epsilon = std::numeric_limits<float>::epsilon());
86         static void AssertEqual(
87                 const std::string &message,
88                 const glm::quat &expected,
89                 const glm::quat &actual);
90
91 private:
92         UDPpacket udp_pack;
93
94 };
95
96 }
97 }
98
99 #endif