1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00
openrw/tests/test_object.cpp
Daniel Evans e1a37e44c4 Cleaned up some object data
Renamed some vehicle related data objects
Changed types on some vehicle data containers
Renamed GTAObject to GameObject
2014-02-28 11:23:51 +00:00

60 lines
1.3 KiB
C++

#include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/GTAInstance.hpp>
#include <engine/GameWorld.hpp>
BOOST_AUTO_TEST_SUITE(ObjectUnitTests)
BOOST_AUTO_TEST_CASE(instance_test_damage)
{
std::shared_ptr<ObjectData> object(new ObjectData);
GTAInstance inst(Global::get().e,
glm::vec3(0.f, 0.f, 0.f),
glm::quat(), nullptr,
glm::vec3(1.f),
object,
nullptr
);
GameObject::DamageInfo dmg;
dmg.type = GameObject::DamageInfo::Bullet;
dmg.hitpoints = 50.f;
// Set object to undamagable.
object->flags = 0;
BOOST_CHECK( ! inst.takeDamage(dmg) );
// Now make it explode on hit
object->flags = ObjectData::EXPLODEONHIT;
BOOST_CHECK( inst.takeDamage(dmg) );
BOOST_CHECK( inst.mHealth < 0.f );
}
BOOST_AUTO_TEST_CASE(instance_test_destroy)
{
std::shared_ptr<ObjectData> object(new ObjectData);
GTAInstance inst(Global::get().e,
glm::vec3(0.f, 0.f, 0.f),
glm::quat(), nullptr,
glm::vec3(1.f),
object,
nullptr
);
GameObject::DamageInfo dmg;
dmg.type = GameObject::DamageInfo::Bullet;
dmg.hitpoints = inst.mHealth + 1.f;
// Now make it damageable
object->flags = ObjectData::EXPLODEONHIT;
BOOST_CHECK( inst.takeDamage(dmg) );
BOOST_CHECK( inst.mHealth < 0.f );
}
BOOST_AUTO_TEST_SUITE_END()