2014-06-29 23:14:46 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <items/WeaponItem.hpp>
|
|
|
|
#include <objects/CharacterObject.hpp>
|
|
|
|
#include "test_globals.hpp"
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(ItemTests)
|
2016-06-16 22:11:55 +02:00
|
|
|
|
|
|
|
#if RW_TEST_WITH_DATA
|
2014-06-29 23:14:46 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_character_inventory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
|
|
|
|
BOOST_REQUIRE( character != nullptr );
|
|
|
|
|
2016-04-15 02:06:10 +02:00
|
|
|
auto item = Global::get().e->getInventoryItem(4);
|
2016-05-02 18:38:04 +02:00
|
|
|
auto fist = Global::get().e->getInventoryItem(0);
|
2016-04-15 02:06:10 +02:00
|
|
|
|
|
|
|
BOOST_REQUIRE(item != nullptr);
|
2016-05-02 18:38:04 +02:00
|
|
|
BOOST_REQUIRE(fist != nullptr );
|
|
|
|
BOOST_CHECK_NE( fist, item );
|
2014-06-29 23:14:46 +02:00
|
|
|
|
|
|
|
character->addToInventory(item);
|
|
|
|
|
2016-05-02 18:38:04 +02:00
|
|
|
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
|
|
|
|
2014-06-29 23:14:46 +02:00
|
|
|
character->setActiveItem( item->getInventorySlot() );
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL( character->getActiveItem(), item );
|
|
|
|
|
2016-04-10 19:55:40 +02:00
|
|
|
character->removeFromInventory( item->getInventorySlot() );
|
2014-06-29 23:14:46 +02:00
|
|
|
|
2016-05-02 18:38:04 +02:00
|
|
|
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
2014-06-29 23:14:46 +02:00
|
|
|
|
|
|
|
Global::get().e->destroyObject(character);
|
|
|
|
}
|
|
|
|
}
|
2016-06-16 22:11:55 +02:00
|
|
|
#endif
|
2014-06-29 23:14:46 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|
|
|
|
|