mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 06:52:34 +02:00
Simplify IPL tests by adding output and comparison operators
This commit is contained in:
parent
7938f8678f
commit
a0eb668f79
@ -11,13 +11,43 @@ ZONE_B, 0, 200.0, 10.0, -100.0, 100.0, 1000.0, 100.0, 2
|
||||
end
|
||||
|
||||
inst
|
||||
101, ModelA, 10.0, 12.0, 5.0, 1, 1, 1, 0, 0, -0.70, 0.70
|
||||
112, ModelB, 10.0, 12.0, 5.0, 1, 1, 1, 0, 0, -0.70, 0.70
|
||||
101, ModelA, 10.0, 12.0, 5.0, 1, 1, 1, 0, 0, 1, 0
|
||||
112, ModelB, 10.0, 12.0, 5.0, 1, 1, 1, 0, 0, 1, 0
|
||||
112, ModelB, 11.0, 12.0, 5.0, 1, 1, 1, 0, 0, 0, 1
|
||||
end
|
||||
)";
|
||||
}
|
||||
|
||||
bool operator==(const ZoneData& lhs, const ZoneData& rhs) {
|
||||
return
|
||||
lhs.name == rhs.name &&
|
||||
lhs.type == rhs.type &&
|
||||
lhs.min == rhs.min &&
|
||||
lhs.max == rhs.max &&
|
||||
lhs.island == rhs.island;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& str, const ZoneData& z) {
|
||||
str << "ZoneData { " << z.name << ", "
|
||||
<< z.type << ", " << z.min << ", " << z.max << ", " << z.island << " }";
|
||||
return str;
|
||||
}
|
||||
|
||||
bool operator==(const InstanceData& lhs, const InstanceData& rhs) {
|
||||
return
|
||||
lhs.id == rhs.id &&
|
||||
lhs.model == rhs.model &&
|
||||
lhs.pos == rhs.pos &&
|
||||
lhs.scale == rhs.scale &&
|
||||
lhs.rot == rhs.rot;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& str, const InstanceData& i) {
|
||||
str << "InstanceData { " << i.id << ", "
|
||||
<< i.model << ", " << i.pos << ", " << i.scale << ", " << glm::to_string(i.rot) << " }";
|
||||
return str;
|
||||
}
|
||||
|
||||
struct WithLoaderIPL {
|
||||
LoaderIPL loader;
|
||||
|
||||
@ -34,11 +64,8 @@ BOOST_AUTO_TEST_CASE(zone_count_is_correct) {
|
||||
BOOST_AUTO_TEST_CASE(zone_data_is_correct) {
|
||||
BOOST_REQUIRE(loader.load(test_data_stream));
|
||||
|
||||
auto& zone1 = loader.zones[1];
|
||||
BOOST_TEST(zone1.name == "ZONE_B");
|
||||
BOOST_TEST(zone1.type == 0);
|
||||
BOOST_TEST(zone1.min.x == 200.0f);
|
||||
BOOST_TEST(zone1.island == 2);
|
||||
const auto expectedZone = ZoneData("ZONE_B", 0, {200.0f, 10.0f, -100.0}, {100.0f, 1000.0f, 100.0f}, 2, 0, 0);
|
||||
BOOST_TEST(loader.zones[1] == expectedZone);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(instance_count_is_correct) {
|
||||
@ -49,13 +76,8 @@ BOOST_AUTO_TEST_CASE(instance_count_is_correct) {
|
||||
BOOST_AUTO_TEST_CASE(instance_data_is_correct) {
|
||||
BOOST_REQUIRE(loader.load(test_data_stream));
|
||||
|
||||
auto& instance = loader.m_instances[1];
|
||||
BOOST_TEST(instance->id == 112);
|
||||
BOOST_TEST(instance->model == "ModelB");
|
||||
BOOST_TEST(instance->pos.x == 10.0f);
|
||||
BOOST_TEST(instance->pos.y == 12.0f);
|
||||
BOOST_TEST(instance->pos.z == 5.0f);
|
||||
BOOST_TEST(instance->rot.x == 0.0f);
|
||||
const auto expectedInstance = InstanceData(112, "ModelB", {10.0f, 12.0f, 5.0f}, {1.f, 1.f, 1.f}, {0.0f, 0.f, 0.f, 1.0f});
|
||||
BOOST_TEST(*loader.m_instances[1] == expectedInstance);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
Reference in New Issue
Block a user