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:
@@ -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;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user