]> git.localhorst.tv Git - blank.git/blob - tst/net/PacketTest.hpp
even more packet tests
[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 <string>
10 #include <SDL_net.h>
11 #include <glm/glm.hpp>
12 #include <cppunit/extensions/HelperMacros.h>
13
14
15 namespace blank {
16 namespace test {
17
18 class PacketTest
19 : public CppUnit::TestFixture {
20
21 CPPUNIT_TEST_SUITE(PacketTest);
22
23 CPPUNIT_TEST(testControl);
24 CPPUNIT_TEST(testPing);
25 CPPUNIT_TEST(testLogin);
26 CPPUNIT_TEST(testJoin);
27 CPPUNIT_TEST(testPart);
28 CPPUNIT_TEST(testPlayerUpdate);
29 CPPUNIT_TEST(testSpawnEntity);
30 CPPUNIT_TEST(testDespawnEntity);
31 CPPUNIT_TEST(testEntityUpdate);
32 CPPUNIT_TEST(testPlayerCorrection);
33 CPPUNIT_TEST(testChunkBegin);
34 CPPUNIT_TEST(testChunkData);
35
36 CPPUNIT_TEST_SUITE_END();
37
38 public:
39         void setUp();
40         void tearDown();
41
42         void testControl();
43         void testPing();
44         void testLogin();
45         void testJoin();
46         void testPart();
47         void testPlayerUpdate();
48         void testSpawnEntity();
49         void testDespawnEntity();
50         void testEntityUpdate();
51         void testPlayerCorrection();
52         void testChunkBegin();
53         void testChunkData();
54
55 private:
56         static void AssertPacket(
57                 const std::string &name,
58                 std::uint8_t expected_type,
59                 std::size_t expected_length,
60                 const Packet::Payload &actual);
61         static void AssertPacket(
62                 const std::string &name,
63                 std::uint8_t expected_type,
64                 std::size_t min_length,
65                 std::size_t max_length,
66                 const Packet::Payload &actual);
67
68         static void AssertEqual(
69                 const std::string &message,
70                 const EntityState &expected,
71                 const EntityState &actual);
72         static void AssertEqual(
73                 const std::string &message,
74                 const AABB &expected,
75                 const AABB &actual);
76         static void AssertEqual(
77                 const std::string &message,
78                 const glm::ivec3 &expected,
79                 const glm::ivec3 &actual);
80         static void AssertEqual(
81                 const std::string &message,
82                 const glm::vec3 &expected,
83                 const glm::vec3 &actual);
84         static void AssertEqual(
85                 const std::string &message,
86                 const glm::quat &expected,
87                 const glm::quat &actual);
88
89 private:
90         UDPpacket udp_pack;
91
92 };
93
94 }
95 }
96
97 #endif