1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-02 00:42:33 +01:00
openrw/tests/test_GameData.cpp

100 lines
3.0 KiB
C++
Raw Normal View History

#include <boost/test/unit_test.hpp>
#include <engine/GameData.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(GameDataTests)
#if RW_TEST_WITH_DATA
2016-09-09 22:13:22 +02:00
BOOST_AUTO_TEST_CASE(test_object_data) {
2016-12-02 01:56:38 +01:00
GameData gd(&Global::get().log, Global::getGamePath());
2016-09-09 22:13:22 +02:00
gd.load();
GameWorld gw(&Global::get().log, &gd);
2016-09-09 22:13:22 +02:00
{
auto def = gd.findModelInfo<SimpleModelInfo>(1100);
2016-09-09 22:13:22 +02:00
BOOST_REQUIRE(def);
BOOST_ASSERT(def->type() == ModelDataType::SimpleInfo);
BOOST_CHECK_EQUAL(def->name, "rd_Corner1");
BOOST_CHECK_EQUAL(def->textureslot, "generic");
BOOST_CHECK_EQUAL(def->getNumAtomics(), 1);
BOOST_CHECK_EQUAL(def->getLodDistance(0), 220);
2016-09-09 22:13:22 +02:00
BOOST_CHECK_EQUAL(def->flags, 0);
}
}
BOOST_AUTO_TEST_CASE(test_ped_stats) {
GameData gd(&Global::get().log, Global::getGamePath());
gd.load();
BOOST_REQUIRE(gd.pedstats.size() > 2);
auto& stat1 = gd.pedstats[0];
auto& stat2 = gd.pedstats[1];
BOOST_CHECK_EQUAL(stat1.id_, 0);
BOOST_CHECK_EQUAL(stat1.fleedistance_, 0.0f);
BOOST_CHECK_EQUAL(stat1.defendweakness_, 0.4f);
BOOST_CHECK_EQUAL(stat1.flags_, 6);
BOOST_CHECK_EQUAL(stat2.id_, 1);
BOOST_CHECK_EQUAL(stat2.fleedistance_, 20.0f);
BOOST_CHECK_EQUAL(stat2.defendweakness_, 1.0f);
BOOST_CHECK_EQUAL(stat2.flags_, 2);
}
BOOST_AUTO_TEST_CASE(test_ped_stat_info) {
GameData gd(&Global::get().log, Global::getGamePath());
gd.load();
BOOST_REQUIRE(gd.pedstats.size() > 2);
BOOST_REQUIRE(gd.modelinfo.find(1) != gd.modelinfo.end());
auto it = gd.modelinfo.find(1);
auto cop = static_cast<PedModelInfo*>(it->second.get());
auto& stat_cop = gd.pedstats[1];
BOOST_CHECK_EQUAL(cop->statindex_, stat_cop.id_);
}
2017-01-16 21:39:35 +01:00
BOOST_AUTO_TEST_CASE(test_ped_relations) {
GameData gd(&Global::get().log, Global::getGamePath());
gd.load();
auto& rel_cop = gd.pedrels[PedModelInfo::COP];
auto& rel_crim = gd.pedrels[PedModelInfo::CRIMINAL];
BOOST_CHECK_EQUAL(rel_cop.id_, PedRelationship::THREAT_COP);
BOOST_CHECK_EQUAL(rel_cop.threatflags_,
PedRelationship::THREAT_GUN |
PedRelationship::THREAT_EXPLOSION |
PedRelationship::THREAT_DEADPEDS);
BOOST_CHECK_EQUAL(rel_crim.id_, PedRelationship::THREAT_CRIMINAL);
BOOST_CHECK_EQUAL(rel_crim.threatflags_,
PedRelationship::THREAT_GUN |
PedRelationship::THREAT_COP |
PedRelationship::THREAT_COP_CAR |
PedRelationship::THREAT_EXPLOSION);
}
2017-01-16 21:40:54 +01:00
BOOST_AUTO_TEST_CASE(test_ped_groups) {
GameData gd(&Global::get().log, Global::getGamePath());
gd.load();
BOOST_REQUIRE(gd.pedgroups.size() > 2);
const auto& def = gd.pedgroups[0];
const auto& red = gd.pedgroups[1];
BOOST_REQUIRE_GE(def.size(), 8);
BOOST_CHECK_EQUAL(def[0], 30);
BOOST_REQUIRE_GE(red.size(), 8);
BOOST_CHECK_EQUAL(red[0], 34);
}
#endif
BOOST_AUTO_TEST_SUITE_END()