1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 07:13:07 +01:00

Apply review comments and fix build

This commit is contained in:
Ted John
2020-11-04 23:44:57 +00:00
parent 167aaac633
commit fd605d7399
2 changed files with 14 additions and 14 deletions

View File

@@ -238,13 +238,13 @@ namespace OpenRCT2
return result;
}
static std::string_view GetDigitSeperator()
static std::string_view GetDigitSeparator()
{
auto sz = language_get_string(STR_LOCALE_THOUSANDS_SEPARATOR);
return sz != nullptr ? sz : std::string_view();
}
static std::string_view GetDecimalSeperator()
static std::string_view GetDecimalSeparator()
{
auto sz = language_get_string(STR_LOCALE_DECIMAL_POINT);
return sz != nullptr ? sz : std::string_view();
@@ -262,7 +262,7 @@ namespace OpenRCT2
}
}
template<size_t TSize, typename TIndex> static void AppendSeperator(char (&buffer)[TSize], TIndex& i, std::string_view sep)
template<size_t TSize, typename TIndex> static void AppendSeparator(char (&buffer)[TSize], TIndex& i, std::string_view sep)
{
if (i < TSize)
{
@@ -299,12 +299,12 @@ namespace OpenRCT2
num /= 10;
}
auto decSep = GetDecimalSeperator();
AppendSeperator(buffer, i, decSep);
auto decSep = GetDecimalSeparator();
AppendSeparator(buffer, i, decSep);
}
// Whole digits
[[maybe_unused]] auto digitSep = GetDigitSeperator();
[[maybe_unused]] auto digitSep = GetDigitSeparator();
size_t groupLen = 0;
do
{
@@ -313,7 +313,7 @@ namespace OpenRCT2
if (groupLen >= 3)
{
groupLen = 0;
AppendSeperator(buffer, i, digitSep);
AppendSeparator(buffer, i, digitSep);
}
}
buffer[i++] = static_cast<char>('0' + (num % 10));
@@ -333,7 +333,7 @@ namespace OpenRCT2
template<size_t TDecimalPlace, bool TDigitSep, typename T> void FormatCurrency(std::stringstream& ss, T rawValue)
{
auto currencyDesc = &CurrencyDescriptors[gConfigGeneral.currency_format];
auto currencyDesc = &CurrencyDescriptors[EnumValue(gConfigGeneral.currency_format)];
auto value = static_cast<int64_t>(rawValue) * currencyDesc->rate;
// Negative sign

View File

@@ -108,7 +108,7 @@ TEST_F(FormattingTests, comma_0)
TEST_F(FormattingTests, currency)
{
gConfigGeneral.currency_format = CURRENCY_POUNDS;
gConfigGeneral.currency_format = CurrencyType::Pounds;
ASSERT_EQ(u8"-£251", FormatString("{CURRENCY}", -2510));
ASSERT_EQ(u8"£1", FormatString("{CURRENCY}", 4));
ASSERT_EQ(u8"£1", FormatString("{CURRENCY}", 5));
@@ -119,7 +119,7 @@ TEST_F(FormattingTests, currency)
TEST_F(FormattingTests, currency2dp)
{
gConfigGeneral.currency_format = CURRENCY_POUNDS;
gConfigGeneral.currency_format = 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));
@@ -130,7 +130,7 @@ TEST_F(FormattingTests, currency2dp)
TEST_F(FormattingTests, currency_yen)
{
gConfigGeneral.currency_format = CURRENCY_YEN;
gConfigGeneral.currency_format = CurrencyType::Yen;
ASSERT_EQ(u8"-¥25,100", FormatString("{CURRENCY}", -2510));
ASSERT_EQ(u8"¥40", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ(u8"¥50", FormatString("{CURRENCY2DP}", 5));
@@ -141,7 +141,7 @@ TEST_F(FormattingTests, currency_yen)
TEST_F(FormattingTests, currency2dp_yen)
{
gConfigGeneral.currency_format = CURRENCY_YEN;
gConfigGeneral.currency_format = CurrencyType::Yen;
ASSERT_EQ(u8"-¥25,100", FormatString("{CURRENCY2DP}", -2510));
ASSERT_EQ(u8"¥40", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ(u8"¥50", FormatString("{CURRENCY2DP}", 5));
@@ -152,14 +152,14 @@ TEST_F(FormattingTests, currency2dp_yen)
TEST_F(FormattingTests, currency_pts)
{
gConfigGeneral.currency_format = CURRENCY_PESETA;
gConfigGeneral.currency_format = CurrencyType::Peseta;
ASSERT_EQ("-251Pts", FormatString("{CURRENCY}", -2510));
ASSERT_EQ("112Pts", FormatString("{CURRENCY}", 1111));
}
TEST_F(FormattingTests, currency2dp_pts)
{
gConfigGeneral.currency_format = CURRENCY_PESETA;
gConfigGeneral.currency_format = CurrencyType::Peseta;
ASSERT_EQ("-251.00Pts", FormatString("{CURRENCY2DP}", -2510));
ASSERT_EQ("0.40Pts", FormatString("{CURRENCY2DP}", 4));
ASSERT_EQ("111.10Pts", FormatString("{CURRENCY2DP}", 1111));