1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Introduce Config namespace and struct

This commit is contained in:
Aaron van Geffen
2024-05-10 12:10:21 +02:00
parent 9e206d5528
commit a63d86c488
101 changed files with 1162 additions and 1108 deletions

View File

@@ -140,7 +140,7 @@ TEST_F(FormattingTests, comma_large)
TEST_F(FormattingTests, currency)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Pounds;
Config::Get().general.CurrencyFormat = CurrencyType::Pounds;
ASSERT_EQ(u8"-£251", FormatString("{CURRENCY}", -2510));
ASSERT_EQ(u8"£1", FormatString("{CURRENCY}", 4));
ASSERT_EQ(u8"£1", FormatString("{CURRENCY}", 5));
@@ -151,7 +151,7 @@ TEST_F(FormattingTests, currency)
TEST_F(FormattingTests, currency2dp)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Pounds;
Config::Get().general.CurrencyFormat = CurrencyType::Pounds;
ASSERT_EQ(u8"-£251.00", FormatString("{CURRENCY2DP}", -2510));
ASSERT_EQ(u8"£0.40", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ(u8"£0.50", FormatString("{CURRENCY2DP}", 5));
@@ -162,7 +162,7 @@ TEST_F(FormattingTests, currency2dp)
TEST_F(FormattingTests, currency_yen)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Yen;
Config::Get().general.CurrencyFormat = CurrencyType::Yen;
ASSERT_EQ(u8"-¥25,100", FormatString("{CURRENCY}", -2510));
ASSERT_EQ(u8"¥40", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ(u8"¥50", FormatString("{CURRENCY2DP}", 5));
@@ -173,7 +173,7 @@ TEST_F(FormattingTests, currency_yen)
TEST_F(FormattingTests, currency2dp_yen)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Yen;
Config::Get().general.CurrencyFormat = CurrencyType::Yen;
ASSERT_EQ(u8"-¥25,100", FormatString("{CURRENCY2DP}", -2510));
ASSERT_EQ(u8"¥40", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ(u8"¥50", FormatString("{CURRENCY2DP}", 5));
@@ -184,14 +184,14 @@ TEST_F(FormattingTests, currency2dp_yen)
TEST_F(FormattingTests, currency_pts)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Peseta;
Config::Get().general.CurrencyFormat = CurrencyType::Peseta;
ASSERT_EQ("-251Pts", FormatString("{CURRENCY}", -2510));
ASSERT_EQ("112Pts", FormatString("{CURRENCY}", 1111));
}
TEST_F(FormattingTests, currency2dp_pts)
{
gConfigGeneral.CurrencyFormat = CurrencyType::Peseta;
Config::Get().general.CurrencyFormat = CurrencyType::Peseta;
ASSERT_EQ("-251.00Pts", FormatString("{CURRENCY2DP}", -2510));
ASSERT_EQ("0.40Pts", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ("111.10Pts", FormatString("{CURRENCY2DP}", 1111));
@@ -211,42 +211,42 @@ TEST_F(FormattingTests, escaped_braces)
TEST_F(FormattingTests, velocity_mph)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::Imperial;
Config::Get().general.MeasurementFormat = MeasurementFormat::Imperial;
auto actual = FormatString("Train is going at {VELOCITY}.", 1024);
ASSERT_EQ("Train is going at 1,024 mph.", actual);
}
TEST_F(FormattingTests, velocity_kph)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::Metric;
Config::Get().general.MeasurementFormat = MeasurementFormat::Metric;
auto actual = FormatString("Train is going at {VELOCITY}.", 1024);
ASSERT_EQ("Train is going at 1,648 km/h.", actual);
}
TEST_F(FormattingTests, velocity_mps)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::SI;
Config::Get().general.MeasurementFormat = MeasurementFormat::SI;
auto actual = FormatString("Train is going at {VELOCITY}.", 1024);
ASSERT_EQ("Train is going at 457.7 m/s.", actual);
}
TEST_F(FormattingTests, length_imperial)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::Imperial;
Config::Get().general.MeasurementFormat = MeasurementFormat::Imperial;
auto actual = FormatString("Height: {LENGTH}", 1024);
ASSERT_EQ("Height: 3,360 ft", actual);
}
TEST_F(FormattingTests, length_metric)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::Metric;
Config::Get().general.MeasurementFormat = MeasurementFormat::Metric;
auto actual = FormatString("Height: {LENGTH}", 1024);
ASSERT_EQ("Height: 1,024 m", actual);
}
TEST_F(FormattingTests, length_si)
{
gConfigGeneral.MeasurementFormat = MeasurementFormat::SI;
Config::Get().general.MeasurementFormat = MeasurementFormat::SI;
auto actual = FormatString("Height: {LENGTH}", 2048);
ASSERT_EQ("Height: 2,048 m", actual);
}