2018-06-15 14:07:34 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
|
|
|
*
|
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-22 22:29:03 +02:00
|
|
|
#include "TestData.h"
|
|
|
|
|
2017-01-10 13:57:55 +01:00
|
|
|
#include <gtest/gtest.h>
|
2017-06-03 14:57:40 +02:00
|
|
|
#include <openrct2/Context.h>
|
2018-06-22 22:29:03 +02:00
|
|
|
#include <openrct2/Game.h>
|
|
|
|
#include <openrct2/OpenRCT2.h>
|
|
|
|
#include <openrct2/audio/AudioContext.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>
|
2017-09-28 22:30:02 +02:00
|
|
|
#include <openrct2/platform/platform.h>
|
2018-06-22 22:29:03 +02:00
|
|
|
#include <openrct2/ride/Ride.h>
|
2020-06-19 23:03:24 +02:00
|
|
|
#include <openrct2/ride/RideData.h>
|
2018-06-22 22:29:03 +02:00
|
|
|
#include <string>
|
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()
|
|
|
|
{
|
2019-08-03 18:27:50 +02:00
|
|
|
for (const auto& ride : GetRideManager())
|
2017-01-10 20:54:43 +01:00
|
|
|
{
|
2019-08-03 18:27:50 +02:00
|
|
|
ride_ratings_update_ride(ride);
|
2017-01-10 20:54:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DumpRatings()
|
|
|
|
{
|
2019-08-03 18:27:50 +02:00
|
|
|
for (const auto& ride : GetRideManager())
|
2017-01-10 20:54:43 +01:00
|
|
|
{
|
2019-08-03 18:27:50 +02:00
|
|
|
std::string line = FormatRatings(ride);
|
|
|
|
printf("%s\n", line.c_str());
|
2017-01-10 20:54:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-03 18:27:50 +02:00
|
|
|
std::string FormatRatings(const Ride& ride)
|
2017-01-10 20:54:43 +01:00
|
|
|
{
|
2020-06-17 22:22:52 +02:00
|
|
|
RatingTuple ratings = ride.ratings;
|
2018-06-22 22:29:03 +02:00
|
|
|
std::string line = String::StdFormat(
|
2020-06-19 23:03:24 +02:00
|
|
|
"%s: (%d, %d, %d)", RideTypeDescriptors[ride.type].EnumName, (int)ratings.Excitement, (int)ratings.Intensity,
|
2020-06-17 22:22:52 +02:00
|
|
|
(int)ratings.Nausea);
|
2017-01-10 20:54:43 +01:00
|
|
|
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;
|
2018-04-10 13:33:37 +02:00
|
|
|
gOpenRCT2NoGraphics = 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
|
2019-08-03 18:27:50 +02:00
|
|
|
ASSERT_EQ(ride_get_count(), 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;
|
2019-08-03 18:27:50 +02:00
|
|
|
for (const auto& ride : GetRideManager())
|
2017-01-10 13:57:55 +01:00
|
|
|
{
|
2019-08-03 18:27:50 +02:00
|
|
|
auto actual = FormatRatings(ride);
|
|
|
|
auto expected = expectedRatings[expI];
|
|
|
|
ASSERT_STREQ(actual.c_str(), expected.c_str());
|
2017-01-10 13:57:55 +01:00
|
|
|
|
2019-08-03 18:27:50 +02:00
|
|
|
expI++;
|
2017-01-10 13:57:55 +01:00
|
|
|
}
|
|
|
|
}
|