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:14:18 +02:00
|
|
|
struct WithLoaderIDE {
|
|
|
|
LoaderIDE loader;
|
|
|
|
};
|
|
|
|
|
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-05 22:14:18 +02:00
|
|
|
BOOST_FIXTURE_TEST_SUITE(ObjectDataTests, WithLoaderIDE)
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(parses_basic_instance) {
|
2018-08-05 22:38:58 +02:00
|
|
|
std::istringstream str {kTestDataObjects};
|
|
|
|
loader.load(str, {});
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:14:18 +02:00
|
|
|
BOOST_ASSERT(loader.objects.find(1100) != loader.objects.end());
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:14:18 +02:00
|
|
|
auto obj = loader.objects[1100].get();
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
auto def = dynamic_cast<SimpleModelInfo *>(obj);
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_ASSERT(def->type() == ModelDataType::SimpleInfo);
|
2014-09-19 01:10:05 +02:00
|
|
|
|
2018-08-05 22:38:58 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->name, "NAME");
|
|
|
|
BOOST_CHECK_EQUAL(def->textureslot, "TXD");
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->getNumAtomics(), 1);
|
|
|
|
BOOST_CHECK_EQUAL(def->getLodDistance(0), 220);
|
|
|
|
BOOST_CHECK_EQUAL(def->flags, 0);
|
|
|
|
}
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(parses_vehicle) {
|
2018-08-05 22:38:58 +02:00
|
|
|
std::istringstream str {kTestDataObjects};
|
|
|
|
loader.load(str, {});
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:14:18 +02:00
|
|
|
BOOST_ASSERT(loader.objects.find(90) != loader.objects.end());
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:14:18 +02:00
|
|
|
auto obj = loader.objects[90].get();
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
auto def = dynamic_cast<VehicleModelInfo*>(obj);
|
2014-09-19 01:10:05 +02:00
|
|
|
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_ASSERT(def->type() == ModelDataType::VehicleInfo);
|
2014-09-17 04:13:02 +02:00
|
|
|
|
2018-08-05 22:38:58 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->name, "vehicle");
|
|
|
|
BOOST_CHECK_EQUAL(def->textureslot, "texture");
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->vehicletype_, VehicleModelInfo::CAR);
|
2018-08-05 22:38:58 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->handling_, "HANDLING");
|
|
|
|
BOOST_CHECK_EQUAL(def->vehiclename_, "NAME");
|
2018-08-05 17:29:47 +02:00
|
|
|
BOOST_CHECK_EQUAL(def->vehicleclass_, VehicleModelInfo::RICHFAMILY);
|
|
|
|
BOOST_CHECK_EQUAL(def->frequency_, 10);
|
|
|
|
BOOST_CHECK_EQUAL(def->wheelmodel_, 164);
|
|
|
|
BOOST_CHECK_CLOSE(def->wheelscale_, 0.8f, 0.01f);
|
2015-04-24 19:09:21 +02:00
|
|
|
}
|
|
|
|
|
2014-09-17 04:13:02 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|