1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-17 02:15:22 +02:00

Unittest: Add inventory callback tests

This commit is contained in:
SmallJoker
2022-09-29 22:16:29 +02:00
committed by SmallJoker
parent 4245a7604b
commit 61a5733692
7 changed files with 187 additions and 41 deletions

View File

@@ -17,11 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <gamedef.h>
#include <inventory.h>
#include <inventorymanager.h>
#pragma once
class MockInventoryManager : public InventoryManager
#include "gamedef.h"
#include "inventory.h"
#include "server/serverinventorymgr.h"
class ServerEnvironment;
class MockInventoryManager : public ServerInventoryManager
{
public:
MockInventoryManager(IGameDef *gamedef) :
@@ -29,14 +33,17 @@ public:
p2(gamedef->getItemDefManager())
{};
virtual Inventory* getInventory(const InventoryLocation &loc){
Inventory *getInventory(const InventoryLocation &loc) override
{
if (loc.type == InventoryLocation::PLAYER && loc.name == "p1")
return &p1;
if (loc.type == InventoryLocation::PLAYER && loc.name == "p2")
return &p2;
return nullptr;
}
void setInventoryModified(const InventoryLocation &loc) override {}
Inventory p1;
Inventory p2;
};