mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 03:42:48 +01:00
Add more object tests and fix a ped info bug
The car mask ped info member was being loaded as base 10 instead of base 16
This commit is contained in:
parent
a8b2b94b05
commit
fc64c5e87e
@ -172,7 +172,7 @@ bool LoaderIDE::load(std::istream& str, const PedStatsList& stats) {
|
||||
getline(strstream, peds->animgroup_, ',');
|
||||
|
||||
getline(strstream, buff, ',');
|
||||
peds->carsmask_ = lexical_cast<int>(buff);
|
||||
peds->carsmask_ = static_cast<int>(std::strtol(buff.c_str(), nullptr, 16));
|
||||
|
||||
objects.emplace(peds->id(), std::move(peds));
|
||||
break;
|
||||
|
@ -12,6 +12,10 @@ end
|
||||
cars
|
||||
90, vehicle, texture, car, HANDLING, NAME, richfamily, 10, 7, 0, 164, 0.8
|
||||
end
|
||||
|
||||
peds
|
||||
1, mod, txd, COP, STAT_COP, man, 7f
|
||||
end
|
||||
)";
|
||||
|
||||
template<size_t N>
|
||||
@ -43,6 +47,19 @@ void ASSERT_VEHICLE_IS(BaseModelInfo& info, const char* model, const char* txd,
|
||||
BOOST_CHECK_EQUAL(t.wheelmodel_, wheel);
|
||||
BOOST_CHECK_EQUAL(t.wheelscale_, wheelScale);
|
||||
}
|
||||
|
||||
void ASSERT_PED_IS(BaseModelInfo& info, const char* model, const char* txd,
|
||||
PedModelInfo::PedType type, int statindex, const char* animgroup,
|
||||
size_t carmask) {
|
||||
BOOST_ASSERT(info.type() == PedModelInfo::kType);
|
||||
const auto& t = dynamic_cast<PedModelInfo&>(info);
|
||||
BOOST_CHECK_EQUAL(t.name, model);
|
||||
BOOST_CHECK_EQUAL(t.textureslot, txd);
|
||||
BOOST_CHECK_EQUAL(t.pedtype_, type);
|
||||
BOOST_CHECK_EQUAL(t.statindex_, statindex);
|
||||
BOOST_CHECK_EQUAL(t.animgroup_, animgroup);
|
||||
BOOST_CHECK_EQUAL(t.carsmask_, carmask);
|
||||
}
|
||||
}
|
||||
|
||||
struct WithLoaderIDE {
|
||||
@ -53,23 +70,25 @@ struct WithLoaderIDE {
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(ObjectDataTests, WithLoaderIDE)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(parses_basic_instance) {
|
||||
BOOST_AUTO_TEST_CASE(objects_contains_modelID) {
|
||||
loader.load(test_data_stream, {});
|
||||
|
||||
BOOST_ASSERT(loader.objects.find(1100) != loader.objects.end());
|
||||
auto info = loader.objects[1100].get();
|
||||
|
||||
ASSERT_INSTANCE_IS<1>(*info, "NAME", "TXD", {220}, 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(parses_vehicle) {
|
||||
BOOST_AUTO_TEST_CASE(instance_data_is_correct) {
|
||||
loader.load(test_data_stream, {});
|
||||
ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {220}, 0);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(loader.objects.find(90) != loader.objects.end());
|
||||
auto obj = loader.objects[90].get();
|
||||
|
||||
ASSERT_VEHICLE_IS(*obj, "vehicle", "texture", VehicleModelInfo::CAR, "HANDLING", "NAME",
|
||||
BOOST_AUTO_TEST_CASE(vehicle_data_is_correct) {
|
||||
loader.load(test_data_stream, {});
|
||||
ASSERT_VEHICLE_IS(*loader.objects[90], "vehicle", "texture", VehicleModelInfo::CAR, "HANDLING", "NAME",
|
||||
VehicleModelInfo::RICHFAMILY, 10, 164, 0.8f);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(pedestrian_data_is_correct) {
|
||||
loader.load(test_data_stream, {});
|
||||
ASSERT_PED_IS(*loader.objects[1], "mod", "txd", PedModelInfo::COP, -1, "man", 0x7f);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user