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