1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00
openrw/tests/test_items.cpp
2014-06-29 22:14:46 +01:00

33 lines
808 B
C++

#include <boost/test/unit_test.hpp>
#include <items/WeaponItem.hpp>
#include <objects/CharacterObject.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(ItemTests)
BOOST_AUTO_TEST_CASE(test_character_inventory)
{
{
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
BOOST_REQUIRE( character != nullptr );
auto item = new WeaponItem(Global::get().e->gameData.weaponData["unarmed"]);
character->addToInventory(item);
character->setActiveItem( item->getInventorySlot() );
BOOST_CHECK_EQUAL( character->getActiveItem(), item );
character->destroyItem( item->getInventorySlot() );
BOOST_CHECK_EQUAL( character->getActiveItem(), nullptr );
// Dtor also destroys all items, but w/e
Global::get().e->destroyObject(character);
}
}
BOOST_AUTO_TEST_SUITE_END()