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