mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 16:52:25 +00:00
Add inspect message regression test
Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com>
This commit is contained in:
parent
e02da5ba4a
commit
106fb2aeea
@ -13,6 +13,7 @@ SET(tests_headers
|
||||
fixed_memory_variable_test.h
|
||||
hextoi_32_64_test.h
|
||||
ipc_mutex_test.h
|
||||
inspect_message_test.h
|
||||
memory_mapped_file_test.h
|
||||
string_util_test.h
|
||||
skills_util_test.h
|
||||
|
||||
52
tests/inspect_message_test.h
Normal file
52
tests/inspect_message_test.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program 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 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H
|
||||
#define __EQEMU_TESTS_INSPECT_MESSAGE_TEST_H
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include "cppunit/cpptest.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/strings.h"
|
||||
|
||||
class InspectMessageTest : public Test::Suite {
|
||||
typedef void(InspectMessageTest::*TestFunction)(void);
|
||||
public:
|
||||
InspectMessageTest() {
|
||||
TEST_ADD(InspectMessageTest::CopyEnsuresNullTermination);
|
||||
}
|
||||
|
||||
~InspectMessageTest() {
|
||||
}
|
||||
|
||||
private:
|
||||
void CopyEnsuresNullTermination() {
|
||||
InspectMessage_Struct incoming{};
|
||||
InspectMessage_Struct stored{};
|
||||
|
||||
std::string long_text(300, 'A');
|
||||
strn0cpy(incoming.text, long_text.c_str(), sizeof(incoming.text));
|
||||
strn0cpy(stored.text, incoming.text, sizeof(stored.text));
|
||||
|
||||
TEST_ASSERT_EQUALS(stored.text[sizeof(stored.text) - 1], '\0');
|
||||
TEST_ASSERT_EQUALS(std::strlen(stored.text), sizeof(stored.text) - 1);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -28,6 +28,7 @@
|
||||
#include "fixed_memory_variable_test.h"
|
||||
#include "atobool_test.h"
|
||||
#include "hextoi_32_64_test.h"
|
||||
#include "inspect_message_test.h"
|
||||
#include "string_util_test.h"
|
||||
#include "data_verification_test.h"
|
||||
#include "skills_util_test.h"
|
||||
@ -52,6 +53,7 @@ int main()
|
||||
tests.add(new FixedMemoryVariableHashTest());
|
||||
tests.add(new atoboolTest());
|
||||
tests.add(new hextoi_32_64_Test());
|
||||
tests.add(new InspectMessageTest());
|
||||
tests.add(new StringUtilTest());
|
||||
tests.add(new DataVerificationTest());
|
||||
tests.add(new SkillsUtilsTest());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user