2018-06-15 14:07:34 +02:00
|
|
|
/*****************************************************************************
|
2023-01-01 11:58:01 +01:00
|
|
|
* Copyright (c) 2014-2023 OpenRCT2 developers
|
2018-06-15 14:07:34 +02:00
|
|
|
*
|
|
|
|
* 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>
|
2022-02-18 21:57:00 +01: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(
|
2021-02-24 14:02:58 +01:00
|
|
|
"%s: (%d, %d, %d)", ride.GetRideTypeDescriptor().EnumName, static_cast<int>(ratings.Excitement),
|
2020-04-30 15:51:50 +02:00
|
|
|
static_cast<int>(ratings.Intensity), static_cast<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
|
|
|
|
2022-02-18 21:57:00 +01:00
|
|
|
Platform::CoreInit();
|
2017-06-03 14:57:40 +02:00
|
|
|
auto context = CreateContext();
|
|
|
|
bool initialised = context->Initialise();
|
|
|
|
ASSERT_TRUE(initialised);
|
|
|
|
|
2022-10-08 19:27:47 +02:00
|
|
|
GetContext()->LoadParkFromFile(path);
|
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
|
2022-02-27 22:23:35 +01:00
|
|
|
auto expectedDataPath = Path::Combine(TestData::GetBasePath(), u8"ratings", u8"bpb.sv6.txt");
|
2017-05-17 20:12:02 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|