]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/unittest/test.cpp
Replace all uses of core::list with std::list (#12313)
[dragonfireclient.git] / src / unittest / test.cpp
index 3ac8ffb193885e971856ee03f9709b5698ec0212..af30c209dba101c77dedf12fe3d05ef37f508a7f 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gamedef.h"
 #include "modchannels.h"
 #include "content/mods.h"
+#include "database/database-dummy.h"
 #include "util/numeric.h"
 #include "porting.h"
 
@@ -55,6 +56,7 @@ class TestGameDef : public IGameDef {
        scene::ISceneManager *getSceneManager() { return m_scenemgr; }
        IRollbackManager *getRollbackManager() { return m_rollbackmgr; }
        EmergeManager *getEmergeManager() { return m_emergemgr; }
+       ModMetadataDatabase *getModStorageDatabase() { return m_mod_storage_database; }
 
        scene::IAnimatedMesh *getMesh(const std::string &filename) { return NULL; }
        bool checkLocalPrivilege(const std::string &priv) { return false; }
@@ -68,7 +70,6 @@ class TestGameDef : public IGameDef {
                return testmodspec;
        }
        virtual const ModSpec* getModSpec(const std::string &modname) const { return NULL; }
-       virtual std::string getModStoragePath() const { return "."; }
        virtual bool registerModStorage(ModMetadata *meta) { return true; }
        virtual void unregisterModStorage(const std::string &name) {}
        bool joinModChannel(const std::string &channel);
@@ -89,11 +90,13 @@ class TestGameDef : public IGameDef {
        scene::ISceneManager *m_scenemgr = nullptr;
        IRollbackManager *m_rollbackmgr = nullptr;
        EmergeManager *m_emergemgr = nullptr;
+       ModMetadataDatabase *m_mod_storage_database = nullptr;
        std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
 };
 
 
 TestGameDef::TestGameDef() :
+       m_mod_storage_database(new Database_Dummy()),
        m_modchannel_mgr(new ModChannelMgr())
 {
        m_itemdef = createItemDefManager();
@@ -107,6 +110,7 @@ TestGameDef::~TestGameDef()
 {
        delete m_itemdef;
        delete m_nodedef;
+       delete m_mod_storage_database;
 }
 
 
@@ -180,7 +184,7 @@ void TestGameDef::defineSomeNodes()
                "{default_water.png";
        f = ContentFeatures();
        f.name = itemdef.name;
-       f.alpha = 128;
+       f.alpha = ALPHAMODE_BLEND;
        f.liquid_type = LIQUID_SOURCE;
        f.liquid_viscosity = 4;
        f.is_ground_content = true;
@@ -201,7 +205,7 @@ void TestGameDef::defineSomeNodes()
                "{default_lava.png";
        f = ContentFeatures();
        f.name = itemdef.name;
-       f.alpha = 128;
+       f.alpha = ALPHAMODE_OPAQUE;
        f.liquid_type = LIQUID_SOURCE;
        f.liquid_viscosity = 7;
        f.light_source = LIGHT_MAX-1;
@@ -356,7 +360,7 @@ struct TestMapBlock: public TestBase
 
                MapNode node;
                bool position_valid;
-               core::list<v3s16> validity_exceptions;
+               std::list<v3s16> validity_exceptions;
 
                TC()
                {
@@ -367,7 +371,7 @@ struct TestMapBlock: public TestBase
                {
                        //return position_valid ^ (p==position_valid_exception);
                        bool exception = false;
-                       for(core::list<v3s16>::Iterator i=validity_exceptions.begin();
+                       for(std::list<v3s16>::iterator i=validity_exceptions.begin();
                                        i != validity_exceptions.end(); i++)
                        {
                                if(p == *i)
@@ -529,7 +533,7 @@ struct TestMapBlock: public TestBase
                        parent.node.setContent(CONTENT_AIR);
                        parent.node.setLight(LIGHTBANK_DAY, LIGHT_SUN);
                        parent.node.setLight(LIGHTBANK_NIGHT, 0);
-                       core::map<v3s16, bool> light_sources;
+                       std::map<v3s16, bool> light_sources;
                        // The bottom block is invalid, because we have a shadowing node
                        UASSERT(b.propagateSunlight(light_sources) == false);
                        UASSERT(b.getNode(v3s16(1,4,0)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
@@ -556,7 +560,7 @@ struct TestMapBlock: public TestBase
                        parent.position_valid = true;
                        b.setIsUnderground(true);
                        parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
-                       core::map<v3s16, bool> light_sources;
+                       std::map<v3s16, bool> light_sources;
                        // The block below should be valid because there shouldn't be
                        // sunlight in there either
                        UASSERT(b.propagateSunlight(light_sources, true) == true);
@@ -597,7 +601,7 @@ struct TestMapBlock: public TestBase
                        }
                        // Lighting value for the valid nodes
                        parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
-                       core::map<v3s16, bool> light_sources;
+                       std::map<v3s16, bool> light_sources;
                        // Bottom block is not valid
                        UASSERT(b.propagateSunlight(light_sources) == false);
                }
@@ -650,12 +654,12 @@ struct TestMapSector: public TestBase
                // Create one with no heightmaps
                ServerMapSector sector(&parent, v2s16(1,1));
 
-               UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
-               UASSERT(sector.getBlockNoCreateNoEx(1) == 0);
+               UASSERT(sector.getBlockNoCreateNoEx(0) == nullptr);
+               UASSERT(sector.getBlockNoCreateNoEx(1) == nullptr);
 
                MapBlock * bref = sector.createBlankBlock(-2);
 
-               UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
+               UASSERT(sector.getBlockNoCreateNoEx(0) == nullptr);
                UASSERT(sector.getBlockNoCreateNoEx(-2) == bref);
 
                //TODO: Check for AlreadyExistsException