]> git.localhorst.tv Git - blank.git/blob - tst/net/PacketTest.hpp
618df1e68d9d75fe3eb8b6377a71473b188ec55a
[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
32 CPPUNIT_TEST_SUITE_END();
33
34 public:
35         void setUp();
36         void tearDown();
37
38         void testControl();
39         void testPing();
40         void testLogin();
41         void testJoin();
42         void testPart();
43         void testPlayerUpdate();
44         void testSpawnEntity();
45         void testDespawnEntity();
46
47 private:
48         static void AssertPacket(
49                 const std::string &name,
50                 std::uint8_t expected_type,
51                 std::size_t expected_length,
52                 const Packet::Payload &actual);
53         static void AssertPacket(
54                 const std::string &name,
55                 std::uint8_t expected_type,
56                 std::size_t min_length,
57                 std::size_t max_length,
58                 const Packet::Payload &actual);
59
60         static void AssertEqual(
61                 const std::string &message,
62                 const EntityState &expected,
63                 const EntityState &actual);
64         static void AssertEqual(
65                 const std::string &message,
66                 const AABB &expected,
67                 const AABB &actual);
68         static void AssertEqual(
69                 const std::string &message,
70                 const glm::ivec3 &expected,
71                 const glm::ivec3 &actual);
72         static void AssertEqual(
73                 const std::string &message,
74                 const glm::vec3 &expected,
75                 const glm::vec3 &actual);
76         static void AssertEqual(
77                 const std::string &message,
78                 const glm::quat &expected,
79                 const glm::quat &actual);
80
81 private:
82         UDPpacket udp_pack;
83
84 };
85
86 }
87 }
88
89 #endif