mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Test: Check that game packet ID to string mappings are correct/complete
This commit is contained in:
parent
7c569b2c83
commit
5dc0bb61ea
@ -143,7 +143,7 @@ enum PacketGameType : uint8_t {
|
||||
PACKET_END, ///< Must ALWAYS be on the end of this list!! (period)
|
||||
};
|
||||
|
||||
const char *GetPacketTypeName(PacketGameType type);
|
||||
const char *GetPacketGameTypeName(PacketGameType type);
|
||||
|
||||
/** Packet that wraps a command */
|
||||
struct CommandPacket;
|
||||
|
@ -11,6 +11,7 @@ add_test_files(
|
||||
strings_func.cpp
|
||||
test_main.cpp
|
||||
test_network_crypto.cpp
|
||||
test_network_debug.cpp
|
||||
test_script_admin.cpp
|
||||
test_window_desc.cpp
|
||||
)
|
||||
|
78
src/tests/test_network_debug.cpp
Normal file
78
src/tests/test_network_debug.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file test_network_debug.cpp Tests for network debug related functions. */
|
||||
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "../3rdparty/catch2/catch.hpp"
|
||||
|
||||
#include "../network/core/tcp_game.h"
|
||||
|
||||
|
||||
TEST_CASE("GetPacketGameTypeName")
|
||||
{
|
||||
uint number_of_tests = 0;
|
||||
#define CHECK_NAME(pkttype) number_of_tests++; CHECK(GetPacketGameTypeName(PACKET_ ## pkttype) == std::string_view{#pkttype})
|
||||
CHECK_NAME(SERVER_FULL);
|
||||
CHECK_NAME(SERVER_BANNED);
|
||||
CHECK_NAME(CLIENT_JOIN);
|
||||
CHECK_NAME(SERVER_ERROR);
|
||||
CHECK_NAME(CLIENT_UNUSED);
|
||||
CHECK_NAME(SERVER_UNUSED);
|
||||
CHECK_NAME(SERVER_GAME_INFO);
|
||||
CHECK_NAME(CLIENT_GAME_INFO);
|
||||
CHECK_NAME(SERVER_NEWGAME);
|
||||
CHECK_NAME(SERVER_SHUTDOWN);
|
||||
CHECK_NAME(SERVER_GAME_INFO_EXTENDED);
|
||||
CHECK_NAME(SERVER_AUTH_REQUEST);
|
||||
CHECK_NAME(CLIENT_AUTH_RESPONSE);
|
||||
CHECK_NAME(SERVER_ENABLE_ENCRYPTION);
|
||||
CHECK_NAME(CLIENT_IDENTIFY);
|
||||
CHECK_NAME(SERVER_CHECK_NEWGRFS);
|
||||
CHECK_NAME(CLIENT_NEWGRFS_CHECKED);
|
||||
CHECK_NAME(SERVER_NEED_COMPANY_PASSWORD);
|
||||
CHECK_NAME(CLIENT_COMPANY_PASSWORD);
|
||||
CHECK_NAME(CLIENT_SETTINGS_PASSWORD);
|
||||
CHECK_NAME(SERVER_SETTINGS_ACCESS);
|
||||
CHECK_NAME(SERVER_WELCOME);
|
||||
CHECK_NAME(SERVER_CLIENT_INFO);
|
||||
CHECK_NAME(CLIENT_GETMAP);
|
||||
CHECK_NAME(SERVER_WAIT);
|
||||
CHECK_NAME(SERVER_MAP_BEGIN);
|
||||
CHECK_NAME(SERVER_MAP_SIZE);
|
||||
CHECK_NAME(SERVER_MAP_DATA);
|
||||
CHECK_NAME(SERVER_MAP_DONE);
|
||||
CHECK_NAME(CLIENT_MAP_OK);
|
||||
CHECK_NAME(SERVER_JOIN);
|
||||
CHECK_NAME(SERVER_FRAME);
|
||||
CHECK_NAME(CLIENT_ACK);
|
||||
CHECK_NAME(SERVER_SYNC);
|
||||
CHECK_NAME(CLIENT_COMMAND);
|
||||
CHECK_NAME(SERVER_COMMAND);
|
||||
CHECK_NAME(CLIENT_CHAT);
|
||||
CHECK_NAME(SERVER_CHAT);
|
||||
CHECK_NAME(SERVER_EXTERNAL_CHAT);
|
||||
CHECK_NAME(CLIENT_RCON);
|
||||
CHECK_NAME(SERVER_RCON);
|
||||
CHECK_NAME(CLIENT_MOVE);
|
||||
CHECK_NAME(SERVER_MOVE);
|
||||
CHECK_NAME(CLIENT_SET_PASSWORD);
|
||||
CHECK_NAME(CLIENT_SET_NAME);
|
||||
CHECK_NAME(SERVER_COMPANY_UPDATE);
|
||||
CHECK_NAME(SERVER_CONFIG_UPDATE);
|
||||
CHECK_NAME(CLIENT_QUIT);
|
||||
CHECK_NAME(SERVER_QUIT);
|
||||
CHECK_NAME(CLIENT_ERROR);
|
||||
CHECK_NAME(SERVER_ERROR_QUIT);
|
||||
CHECK_NAME(CLIENT_DESYNC_LOG);
|
||||
CHECK_NAME(SERVER_DESYNC_LOG);
|
||||
CHECK_NAME(CLIENT_DESYNC_MSG);
|
||||
CHECK_NAME(CLIENT_DESYNC_SYNC_DATA);
|
||||
#undef CHECK_NAME
|
||||
CHECK(number_of_tests == static_cast<uint>(PACKET_END));
|
||||
}
|
Loading…
Reference in New Issue
Block a user