2017-01-10 13:57:55 +01:00
|
|
|
#include <string>
|
|
|
|
#include <gtest/gtest.h>
|
2017-06-03 14:57:40 +02:00
|
|
|
#include <openrct2/audio/AudioContext.h>
|
|
|
|
#include <openrct2/Context.h>
|
2017-05-17 20:12:02 +02:00
|
|
|
#include <openrct2/core/File.h>
|
2017-01-10 13:57:55 +01:00
|
|
|
#include <openrct2/core/Path.hpp>
|
|
|
|
#include <openrct2/core/String.hpp>
|
|
|
|
#include <openrct2/OpenRCT2.h>
|
2017-01-11 18:15:24 +01:00
|
|
|
#include "TestData.h"
|
2017-01-10 13:57:55 +01:00
|
|
|
|
2017-09-28 22:30:02 +02:00
|
|
|
#include <openrct2/platform/platform.h>
|
2017-11-30 18:17:06 +01:00
|
|
|
#include <openrct2/Game.h>
|
2017-01-10 13:57:55 +01:00
|
|
|
|
2017-06-03 14:57:40 +02:00
|
|
|
using namespace OpenRCT2;
|
|
|
|
|
2017-01-10 13:57:55 +01:00
|
|
|
class RideRatings : public testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
2017-01-10 20:54:43 +01:00
|
|
|
void CalculateRatingsForAllRides()
|
|
|
|
{
|
|
|
|
for (int rideId = 0; rideId < MAX_RIDES; rideId++)
|
|
|
|
{
|
2017-09-12 11:29:43 +02:00
|
|
|
Ride * ride = get_ride(rideId);
|
2017-01-10 20:54:43 +01:00
|
|
|
if (ride->type != RIDE_TYPE_NULL)
|
|
|
|
{
|
|
|
|
ride_ratings_update_ride(rideId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DumpRatings()
|
|
|
|
{
|
|
|
|
for (int rideId = 0; rideId < MAX_RIDES; rideId++)
|
|
|
|
{
|
2017-09-12 11:29:43 +02:00
|
|
|
Ride * ride = get_ride(rideId);
|
2017-01-10 20:54:43 +01:00
|
|
|
if (ride->type != RIDE_TYPE_NULL)
|
|
|
|
{
|
|
|
|
std::string line = FormatRatings(ride);
|
|
|
|
printf("%s\n", line.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 11:29:43 +02:00
|
|
|
std::string FormatRatings(Ride * ride)
|
2017-01-10 20:54:43 +01:00
|
|
|
{
|
|
|
|
rating_tuple ratings = ride->ratings;
|
|
|
|
std::string line = String::StdFormat("%s: (%d, %d, %d)",
|
|
|
|
ride_type_get_enum_name(ride->type),
|
|
|
|
(int)ratings.excitement,
|
|
|
|
(int)ratings.intensity,
|
|
|
|
(int)ratings.nausea);
|
|
|
|
return line;
|
|
|
|
}
|
2017-01-10 13:57:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(RideRatings, all)
|
|
|
|
{
|
2017-05-17 20:12:02 +02:00
|
|
|
std::string path = TestData::GetParkPath("bpb.sv6");
|
2017-01-10 13:57:55 +01:00
|
|
|
|
|
|
|
gOpenRCT2Headless = true;
|
2017-06-03 14:57:40 +02:00
|
|
|
|
2017-01-10 13:57:55 +01:00
|
|
|
core_init();
|
2017-06-03 14:57:40 +02:00
|
|
|
auto context = CreateContext();
|
|
|
|
bool initialised = context->Initialise();
|
|
|
|
ASSERT_TRUE(initialised);
|
|
|
|
|
2017-08-23 08:04:36 +02:00
|
|
|
load_from_sv6(path.c_str());
|
2017-01-10 13:57:55 +01:00
|
|
|
|
|
|
|
// Check ride count to check load was successful
|
2017-05-17 20:12:02 +02:00
|
|
|
ASSERT_EQ(gRideCount, 134);
|
2017-01-10 13:57:55 +01:00
|
|
|
|
2017-01-10 20:54:43 +01:00
|
|
|
CalculateRatingsForAllRides();
|
|
|
|
|
2017-05-17 20:12:02 +02:00
|
|
|
// Load expected ratings
|
|
|
|
auto expectedDataPath = Path::Combine(TestData::GetBasePath(), "ratings", "bpb.sv6.txt");
|
|
|
|
auto expectedRatings = File::ReadAllLines(expectedDataPath);
|
|
|
|
|
2017-01-10 13:57:55 +01:00
|
|
|
// Check ride ratings
|
|
|
|
int expI = 0;
|
|
|
|
for (int rideId = 0; rideId < MAX_RIDES; rideId++)
|
|
|
|
{
|
2017-09-12 11:29:43 +02:00
|
|
|
Ride * ride = get_ride(rideId);
|
2017-01-10 13:57:55 +01:00
|
|
|
if (ride->type != RIDE_TYPE_NULL)
|
|
|
|
{
|
2017-01-10 20:54:43 +01:00
|
|
|
std::string actual = FormatRatings(ride);
|
2017-05-17 20:12:02 +02:00
|
|
|
std::string expected = expectedRatings[expI];
|
2017-01-10 20:54:43 +01:00
|
|
|
ASSERT_STREQ(actual.c_str(), expected.c_str());
|
2017-01-10 13:57:55 +01:00
|
|
|
|
|
|
|
expI++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-03 14:57:40 +02:00
|
|
|
delete context;
|
2017-01-10 13:57:55 +01:00
|
|
|
}
|