1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Use hard-coded test data in object data tests

This removes the dependency on the game data for these tests.
This commit is contained in:
Daniel Evans 2018-08-05 21:38:58 +01:00
parent 19368133b5
commit 81b7e5226a

View File

@ -7,11 +7,23 @@ struct WithLoaderIDE {
LoaderIDE loader;
};
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
)";
}
BOOST_FIXTURE_TEST_SUITE(ObjectDataTests, WithLoaderIDE)
#if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(parses_basic_instance) {
loader.load(Global::get().getGamePath() + "/data/maps/generic.ide", {});
std::istringstream str {kTestDataObjects};
loader.load(str, {});
BOOST_ASSERT(loader.objects.find(1100) != loader.objects.end());
@ -21,15 +33,16 @@ BOOST_AUTO_TEST_CASE(parses_basic_instance) {
BOOST_ASSERT(def->type() == ModelDataType::SimpleInfo);
BOOST_CHECK_EQUAL(def->name, "rd_Corner1");
BOOST_CHECK_EQUAL(def->textureslot, "generic");
BOOST_CHECK_EQUAL(def->name, "NAME");
BOOST_CHECK_EQUAL(def->textureslot, "TXD");
BOOST_CHECK_EQUAL(def->getNumAtomics(), 1);
BOOST_CHECK_EQUAL(def->getLodDistance(0), 220);
BOOST_CHECK_EQUAL(def->flags, 0);
}
BOOST_AUTO_TEST_CASE(parses_vehicle) {
loader.load(Global::get().getGamePath() + "/data/default.ide", {});
std::istringstream str {kTestDataObjects};
loader.load(str, {});
BOOST_ASSERT(loader.objects.find(90) != loader.objects.end());
@ -39,16 +52,15 @@ BOOST_AUTO_TEST_CASE(parses_vehicle) {
BOOST_ASSERT(def->type() == ModelDataType::VehicleInfo);
BOOST_CHECK_EQUAL(def->name, "landstal");
BOOST_CHECK_EQUAL(def->textureslot, "landstal");
BOOST_CHECK_EQUAL(def->name, "vehicle");
BOOST_CHECK_EQUAL(def->textureslot, "texture");
BOOST_CHECK_EQUAL(def->vehicletype_, VehicleModelInfo::CAR);
BOOST_CHECK_EQUAL(def->handling_, "LANDSTAL");
BOOST_CHECK_EQUAL(def->vehiclename_, "LANDSTK");
BOOST_CHECK_EQUAL(def->handling_, "HANDLING");
BOOST_CHECK_EQUAL(def->vehiclename_, "NAME");
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);
}
#endif
BOOST_AUTO_TEST_SUITE_END()