2014-09-17 04:13:02 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2016-09-03 05:11:55 +02:00
|
|
|
#include <data/ModelData.hpp>
|
2017-10-31 04:05:12 +01:00
|
|
|
#include <loaders/LoaderIDE.hpp>
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:38:58 +02:00
|
|
|
namespace {
|
|
|
|
constexpr auto kTestDataObjects = R"(
|
|
|
|
objs
|
|
|
|
1100, NAME, TXD, 1, 220, 0"
|
|
|
|
end
|
|
|
|
|
|
|
|
cars
|
|
|
|
90, vehicle, texture, car, HANDLING, NAME, richfamily, 10, 7, 0, 164, 0.8
|
|
|
|
end
|
2018-08-06 00:55:20 +02:00
|
|
|
|
|
|
|
peds
|
|
|
|
1, mod, txd, COP, STAT_COP, man, 7f
|
|
|
|
end
|
2018-08-05 22:38:58 +02:00
|
|
|
)";
|
2018-08-05 23:21:49 +02:00
|
|
|
|
|
|
|
template<size_t N>
|
|
|
|
void ASSERT_INSTANCE_IS(BaseModelInfo& info, const char* model, const char* txd,
|
|
|
|
const std::array<float, N>& lods, size_t flags) {
|
|
|
|
BOOST_ASSERT(info.type() == SimpleModelInfo::kType);
|
|
|
|
const auto& t = dynamic_cast<SimpleModelInfo&>(info);
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_TEST(t.name == model);
|
|
|
|
BOOST_TEST(t.textureslot == txd);
|
|
|
|
BOOST_TEST(t.getNumAtomics() == lods.size());
|
2018-08-05 23:21:49 +02:00
|
|
|
for (auto i = 0u; i < lods.size(); ++i) {
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_TEST(t.getLodDistance(i) == lods[i]);
|
2018-08-05 23:21:49 +02:00
|
|
|
}
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_TEST(t.flags == flags);
|
2018-08-05 23:21:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ASSERT_VEHICLE_IS(BaseModelInfo& info, const char* model, const char* txd,
|
|
|
|
VehicleModelInfo::VehicleType type, const char* handling, const char* name,
|
|
|
|
VehicleModelInfo::VehicleClass clas_, int frequency, ModelID wheel, float wheelScale) {
|
|
|
|
BOOST_ASSERT(info.type() == VehicleModelInfo::kType);
|
|
|
|
const auto& t = dynamic_cast<VehicleModelInfo&>(info);
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_TEST(t.name == model);
|
|
|
|
BOOST_TEST(t.textureslot == txd);
|
|
|
|
BOOST_TEST(t.vehicletype_ == type);
|
|
|
|
BOOST_TEST(t.handling_ == handling);
|
|
|
|
BOOST_TEST(t.vehiclename_ == name);
|
|
|
|
BOOST_TEST(t.vehicleclass_ == clas_);
|
|
|
|
BOOST_TEST(t.frequency_ == frequency);
|
|
|
|
BOOST_TEST(t.wheelmodel_ == wheel);
|
|
|
|
BOOST_TEST(t.wheelscale_ == wheelScale);
|
2018-08-05 23:21:49 +02:00
|
|
|
}
|
2018-08-06 00:55:20 +02:00
|
|
|
|
|
|
|
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);
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_TEST(t.name == model);
|
|
|
|
BOOST_TEST(t.textureslot == txd);
|
|
|
|
BOOST_TEST(t.pedtype_ == type);
|
|
|
|
BOOST_TEST(t.statindex_ == statindex);
|
|
|
|
BOOST_TEST(t.animgroup_ == animgroup);
|
|
|
|
BOOST_TEST(t.carsmask_ == carmask);
|
2018-08-06 00:55:20 +02:00
|
|
|
}
|
2018-08-05 22:38:58 +02:00
|
|
|
}
|
|
|
|
|
2018-08-05 23:29:01 +02:00
|
|
|
struct WithLoaderIDE {
|
|
|
|
LoaderIDE loader;
|
|
|
|
|
|
|
|
std::istringstream test_data_stream {kTestDataObjects};
|
|
|
|
};
|
|
|
|
|
2018-08-06 01:03:32 +02:00
|
|
|
BOOST_FIXTURE_TEST_SUITE(LoaderIDETests, WithLoaderIDE)
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-06 00:55:20 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(objects_contains_modelID) {
|
2018-08-05 23:29:01 +02:00
|
|
|
loader.load(test_data_stream, {});
|
2018-08-06 21:40:43 +02:00
|
|
|
BOOST_CHECK(loader.objects.find(1100) != loader.objects.end());
|
2018-08-05 17:29:47 +02:00
|
|
|
}
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-06 00:55:20 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(instance_data_is_correct) {
|
2018-08-05 23:29:01 +02:00
|
|
|
loader.load(test_data_stream, {});
|
2018-09-01 04:09:03 +02:00
|
|
|
ASSERT_INSTANCE_IS<1>(*loader.objects[1100], "NAME", "TXD", {{220.f}}, 0);
|
2018-08-06 00:55:20 +02:00
|
|
|
}
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-06 00:55:20 +02:00
|
|
|
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",
|
2018-08-05 23:21:49 +02:00
|
|
|
VehicleModelInfo::RICHFAMILY, 10, 164, 0.8f);
|
2015-04-24 19:09:21 +02:00
|
|
|
}
|
|
|
|
|
2018-08-06 00:55:20 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-09-17 04:13:02 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|