remove obsolete tests
This commit is contained in:
@@ -1,17 +0,0 @@
|
|||||||
#include <td/protocol/command/CommandFactory.h>
|
|
||||||
|
|
||||||
#include <td/misc/Test.h>
|
|
||||||
|
|
||||||
static int Test() {
|
|
||||||
for (std::size_t i = 0; i < static_cast<int>(td::protocol::CommandType::COMMAND_COUNT); i++) {
|
|
||||||
td::protocol::CommandType commandType = td::protocol::CommandType(i);
|
|
||||||
|
|
||||||
if (td::protocol::CommandFactory::CreateReadOnlyCommand(commandType)->GetType() != commandType)
|
|
||||||
return TD_TEST_FAILED;
|
|
||||||
}
|
|
||||||
return TD_TEST_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return Test();
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
#include <td/protocol/command/CommandSerializer.h>
|
|
||||||
|
|
||||||
#include <td/misc/Test.h>
|
|
||||||
#include <td/protocol/command/CommandFactory.h>
|
|
||||||
|
|
||||||
namespace tp = td::protocol;
|
|
||||||
|
|
||||||
class Comparator {
|
|
||||||
public:
|
|
||||||
bool operator()(const tp::cdata::End& left, const tp::cdata::End& right) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::PlaceTower& left, const tp::cdata::PlaceTower& right) {
|
|
||||||
return left.m_Placer == right.m_Placer && left.m_Position.x == right.m_Position.x && left.m_Position.y == right.m_Position.y &&
|
|
||||||
left.m_Type == right.m_Type;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::PlayerJoin& left, const tp::cdata::PlayerJoin& right) {
|
|
||||||
return left.m_ID == right.m_ID && left.m_Name == right.m_Name;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::SpawnTroop& left, const tp::cdata::SpawnTroop& right) {
|
|
||||||
return left.m_Level == right.m_Level && left.m_Position.x == right.m_Position.x && left.m_Position.y == right.m_Position.y &&
|
|
||||||
left.m_Sender == right.m_Sender && left.m_Type == right.m_Type;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::TeamChange& left, const tp::cdata::TeamChange& right) {
|
|
||||||
return left.m_NewTeam == right.m_NewTeam && left.m_Player == right.m_Player;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::UpgradeTower& left, const tp::cdata::UpgradeTower& right) {
|
|
||||||
return left.m_Tower == right.m_Tower && left.m_Upgrade == right.m_Upgrade;
|
|
||||||
}
|
|
||||||
bool operator()(const tp::cdata::UseItem& left, const tp::cdata::UseItem& right) {
|
|
||||||
return left.m_Item == right.m_Item && left.m_Position.x == right.m_Position.x && left.m_Position.y == right.m_Position.y &&
|
|
||||||
left.m_User == right.m_User;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Command_T, typename Command_Data_T = typename Command_T::CommandDataType>
|
|
||||||
static int TestCommand(const Command_T& command) {
|
|
||||||
|
|
||||||
td::DataBuffer buffer = tp::CommandSerializer::Serialize(command);
|
|
||||||
|
|
||||||
auto abstractCommand = tp::CommandSerializer::Deserialize(buffer);
|
|
||||||
|
|
||||||
td_test_assert(abstractCommand);
|
|
||||||
|
|
||||||
Command_T* command2 = dynamic_cast<Command_T*>(abstractCommand.get());
|
|
||||||
|
|
||||||
td_test_assert(command2);
|
|
||||||
td_test_assert(command.GetType() == command2->GetType());
|
|
||||||
|
|
||||||
return Comparator{}(command.m_Data, command2->m_Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DeclareCommand(Command, ...) td_test_assert(TestCommand<tp::commands::Command>({}));
|
|
||||||
|
|
||||||
static int TestAllCommands() {
|
|
||||||
td_test_assert(TestCommand<tp::commands::End>({}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::PlaceTower>({tp::cdata::PlaceTower{
|
|
||||||
td::TowerType::Necromancer,
|
|
||||||
8,
|
|
||||||
td::TowerCoords{-50, 69},
|
|
||||||
}}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::PlayerJoin>({tp::cdata::PlayerJoin{
|
|
||||||
4,
|
|
||||||
"Persson",
|
|
||||||
}}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::SpawnTroop>({tp::cdata::SpawnTroop{
|
|
||||||
td::EntityType::Blaze,
|
|
||||||
4,
|
|
||||||
td::EntityCoords{td::FpFloat{54}, td::FpFloat{58}},
|
|
||||||
2,
|
|
||||||
}}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::TeamChange>({tp::cdata::TeamChange{
|
|
||||||
7,
|
|
||||||
td::Team::Red,
|
|
||||||
}}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::UpgradeTower>({tp::cdata::UpgradeTower{
|
|
||||||
69,
|
|
||||||
3,
|
|
||||||
}}));
|
|
||||||
td_test_assert(TestCommand<tp::commands::UseItem>({tp::cdata::UseItem{
|
|
||||||
td::ShopItem::Freeze,
|
|
||||||
5,
|
|
||||||
td::EntityCoords{td::FpFloat{24}, td::FpFloat{-69}},
|
|
||||||
}}));
|
|
||||||
|
|
||||||
DeclareAllCommand()
|
|
||||||
|
|
||||||
return TD_TEST_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return TestAllCommands();
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#include <td/protocol/packet/PacketFactory.h>
|
|
||||||
|
|
||||||
#include <td/misc/Test.h>
|
|
||||||
|
|
||||||
static int Test() {
|
|
||||||
for (std::size_t i = 0; i < static_cast<int>(td::protocol::PacketType::PACKET_COUNT); i++) {
|
|
||||||
td::protocol::PacketType packetType = td::protocol::PacketType(i);
|
|
||||||
|
|
||||||
if (td::protocol::PacketFactory::CreateReadOnlyPacket(packetType)->GetType() != packetType)
|
|
||||||
return TD_TEST_FAILED;
|
|
||||||
}
|
|
||||||
return TD_TEST_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return Test();
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#include <td/protocol/packet/PacketSerializer.h>
|
|
||||||
|
|
||||||
#include <td/misc/Test.h>
|
|
||||||
#include <td/protocol/packet/PacketFactory.h>
|
|
||||||
|
|
||||||
namespace tp = td::protocol;
|
|
||||||
|
|
||||||
template <typename Packet_T, typename Packet_Data_T = typename Packet_T::PacketDataType>
|
|
||||||
static int TestPacket() {
|
|
||||||
Packet_T packet;
|
|
||||||
|
|
||||||
td::DataBuffer buffer = tp::PacketSerializer::Serialize(packet);
|
|
||||||
|
|
||||||
auto abstractPacket = tp::PacketSerializer::Deserialize(buffer);
|
|
||||||
|
|
||||||
td_test_assert(abstractPacket);
|
|
||||||
|
|
||||||
Packet_T* packet2 = dynamic_cast<Packet_T*>(abstractPacket.get());
|
|
||||||
|
|
||||||
td_test_assert(packet2);
|
|
||||||
td_test_assert(packet.GetType() == packet2->GetType());
|
|
||||||
|
|
||||||
return std::memcmp(&packet.m_Data, &packet2->m_Data, sizeof(Packet_Data_T));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DeclarePacket(Packet, ...) TestPacket<tp::packets::Packet>();
|
|
||||||
|
|
||||||
static int TestAllPackets() {
|
|
||||||
DeclareAllPacket()
|
|
||||||
|
|
||||||
return TD_TEST_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return TestAllPackets();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user