Minor changes to tests
Signed-off-by: John Jones-Steele <jjjoness@amazon.com>
This commit is contained in:
+24
-24
@@ -13,94 +13,94 @@
|
||||
|
||||
TEST(AzQtComponents, FloatToString_Truncate2Decimals)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocal, showThousandsSeparator), "0.12");
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator), "0.12");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_AllZerosButOne)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateAllZerosButOne)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateNotRound)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 3;
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "0.123");
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "0.123");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRound)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 3;
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.123");
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.123");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimal)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_Truncate2DecimalsWithLocale)
|
||||
{
|
||||
QLocale testLocal{ QLocale() };
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
QString testString = "0" + QString(testLocal.decimalPoint()) + "12";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(0.1234, numDecimalPlaces, testLocal, showThousandsSeparator));
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "12";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_AllZerosButOneWithLocale)
|
||||
{
|
||||
QLocale testLocal{ QLocale() };
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
QString testString = "1" + QString(testLocal.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1.0000, numDecimalPlaces, testLocal, showThousandsSeparator));
|
||||
QString testString = "1" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRoundWithLocale)
|
||||
{
|
||||
QLocale testLocal{ QLocale() };
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
const int numDecimalPlaces = 3;
|
||||
QString testString = "1" + QString(testLocal.groupSeparator()) + "000" + QString(testLocal.decimalPoint()) + "123";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocal, showThousandsSeparator));
|
||||
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "123";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimalWithLocale)
|
||||
{
|
||||
QLocale testLocal{ QLocale() };
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 2;
|
||||
QString testString = "1" + QString(testLocal.groupSeparator()) + "000" + QString(testLocal.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator));
|
||||
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user