]> git.localhorst.tv Git - blank.git/blobdiff - tst/net/PacketTest.hpp
unit test for EntityUpdate packet
[blank.git] / tst / net / PacketTest.hpp
index 12b93da38372779330246f4c86bed21d0d0e055b..4942a2a228b59908b8ab8d2c82a4315ecfc601d6 100644 (file)
@@ -1,7 +1,14 @@
 #ifndef BLANK_TEST_NET_PACKETTEST_HPP_
 #define BLANK_TEST_NET_PACKETTEST_HPP_
 
+#include "model/geometry.hpp"
+#include "net/Packet.hpp"
+#include "world/EntityState.hpp"
+
+#include <cstdint>
+#include <string>
 #include <SDL_net.h>
+#include <glm/glm.hpp>
 #include <cppunit/extensions/HelperMacros.h>
 
 
@@ -18,6 +25,10 @@ CPPUNIT_TEST(testPing);
 CPPUNIT_TEST(testLogin);
 CPPUNIT_TEST(testJoin);
 CPPUNIT_TEST(testPart);
+CPPUNIT_TEST(testPlayerUpdate);
+CPPUNIT_TEST(testSpawnEntity);
+CPPUNIT_TEST(testDespawnEntity);
+CPPUNIT_TEST(testEntityUpdate);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -30,6 +41,44 @@ public:
        void testLogin();
        void testJoin();
        void testPart();
+       void testPlayerUpdate();
+       void testSpawnEntity();
+       void testDespawnEntity();
+       void testEntityUpdate();
+
+private:
+       static void AssertPacket(
+               const std::string &name,
+               std::uint8_t expected_type,
+               std::size_t expected_length,
+               const Packet::Payload &actual);
+       static void AssertPacket(
+               const std::string &name,
+               std::uint8_t expected_type,
+               std::size_t min_length,
+               std::size_t max_length,
+               const Packet::Payload &actual);
+
+       static void AssertEqual(
+               const std::string &message,
+               const EntityState &expected,
+               const EntityState &actual);
+       static void AssertEqual(
+               const std::string &message,
+               const AABB &expected,
+               const AABB &actual);
+       static void AssertEqual(
+               const std::string &message,
+               const glm::ivec3 &expected,
+               const glm::ivec3 &actual);
+       static void AssertEqual(
+               const std::string &message,
+               const glm::vec3 &expected,
+               const glm::vec3 &actual);
+       static void AssertEqual(
+               const std::string &message,
+               const glm::quat &expected,
+               const glm::quat &actual);
 
 private:
        UDPpacket udp_pack;