diff options
author | savilli <78875209+savilli@users.noreply.github.com> | 2022-09-27 22:22:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-27 16:22:11 -0400 |
commit | 907dcdcf7bb513ecfeb1c988f071f497dcfbf765 (patch) | |
tree | 5ef19550e97f876f9a1d5eadbedc4c4de879d8a8 /src/unittest/test_server_shutdown_state.cpp | |
parent | 3f801bc096077a91094087fab4a4557198429851 (diff) | |
download | minetest-907dcdcf7bb513ecfeb1c988f071f497dcfbf765.tar.xz |
Add unittests for item movement code (#11885)
Diffstat (limited to 'src/unittest/test_server_shutdown_state.cpp')
-rw-r--r-- | src/unittest/test_server_shutdown_state.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/unittest/test_server_shutdown_state.cpp b/src/unittest/test_server_shutdown_state.cpp index 50305e725..679030696 100644 --- a/src/unittest/test_server_shutdown_state.cpp +++ b/src/unittest/test_server_shutdown_state.cpp @@ -17,27 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <server.h> #include "test.h" +#include "test_config.h" + +#include "mock_server.h" #include "util/string.h" #include "util/serialize.h" -class FakeServer : public Server -{ -public: - FakeServer() : Server("fakeworld", SubgameSpec("fakespec", "fakespec"), true, - Address(), true, nullptr) - { - } - -private: - void SendChatMessage(session_t peer_id, const ChatMessage &message) - { - // NOOP - } -}; - class TestServerShutdownState : public TestBase { public: @@ -93,10 +80,10 @@ void TestServerShutdownState::testTrigger() void TestServerShutdownState::testTick() { - auto fakeServer = std::make_unique<FakeServer>(); + auto server = std::make_unique<MockServer>(); Server::ShutdownState ss; ss.trigger(28.0f, "testtrigger", true); - ss.tick(0.0f, fakeServer.get()); + ss.tick(0.0f, server.get()); // Tick with no time should not change anything UASSERT(!ss.is_requested); @@ -105,14 +92,14 @@ void TestServerShutdownState::testTick() UASSERT(ss.m_timer == 28.0f); // Tick 2 seconds - ss.tick(2.0f, fakeServer.get()); + ss.tick(2.0f, server.get()); UASSERT(!ss.is_requested); UASSERT(ss.should_reconnect); UASSERT(ss.message == "testtrigger"); UASSERT(ss.m_timer == 26.0f); // Tick remaining seconds + additional expire - ss.tick(26.1f, fakeServer.get()); + ss.tick(26.1f, server.get()); UASSERT(ss.is_requested); UASSERT(ss.should_reconnect); UASSERT(ss.message == "testtrigger"); |