From 45a5c96395140004d1dd1a618ded841b5d9a5214 Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Sat, 29 Mar 2025 09:51:53 -0500 Subject: [PATCH] Move `TestGameDef` to test.h header This makes the test gamedef available to all test modules. I removed an unused include from test.h and included some stuff we use in test.h, since I had to modify the include list anyway for the change. --- src/unittest/test.cpp | 19 ------------------- src/unittest/test.h | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 8f0eaf855a..6eeb77feb7 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -32,25 +32,6 @@ content_t t_CONTENT_BRICK; //// TestGameDef //// -class TestGameDef : public DummyGameDef { -public: - TestGameDef(); - ~TestGameDef() = default; - - void defineSomeNodes(); - - bool joinModChannel(const std::string &channel); - bool leaveModChannel(const std::string &channel); - bool sendModChannelMessage(const std::string &channel, const std::string &message); - ModChannel *getModChannel(const std::string &channel) - { - return m_modchannel_mgr->getModChannel(channel); - } - -private: - std::unique_ptr m_modchannel_mgr; -}; - TestGameDef::TestGameDef() : DummyGameDef(), diff --git a/src/unittest/test.h b/src/unittest/test.h index dcecb9fb4c..04a02556fe 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -4,15 +4,21 @@ #pragma once -#include -#include -#include -#include - +#include "dummygamedef.h" #include "irrlichttypes_bloated.h" -#include "porting.h" #include "filesys.h" #include "mapnode.h" +#include "modchannels.h" +#include "porting.h" + +#include +#include +#include +#include +#include +#include +#include +#include class TestFailedException { // don’t derive from std::exception to avoid accidental catch public: @@ -105,6 +111,25 @@ public: } }; +class TestGameDef : public DummyGameDef { +public: + TestGameDef(); + ~TestGameDef() = default; + + void defineSomeNodes(); + + bool joinModChannel(const std::string &channel); + bool leaveModChannel(const std::string &channel); + bool sendModChannelMessage(const std::string &channel, const std::string &message); + ModChannel *getModChannel(const std::string &channel) + { + return m_modchannel_mgr->getModChannel(channel); + } + +private: + std::unique_ptr m_modchannel_mgr; +}; + // A few item and node definitions for those tests that need them extern content_t t_CONTENT_STONE; extern content_t t_CONTENT_GRASS;