|
@@ -64,3 +64,43 @@ TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimal)
|
|
|
int numDecimalPlaces = 2;
|
|
|
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.0");
|
|
|
}
|
|
|
+
|
|
|
+TEST(AzQtComponents, FloatToString_Truncate2DecimalsWithLocale)
|
|
|
+{
|
|
|
+ QLocale testLocal{ QLocale() };
|
|
|
+
|
|
|
+ const bool showThousandsSeparator = false;
|
|
|
+ const int numDecimalPlaces = 2;
|
|
|
+ QString testString = "0" + QString(testLocal.decimalPoint()) + "12";
|
|
|
+ EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocal, showThousandsSeparator), testString);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(AzQtComponents, FloatToString_AllZerosButOneWithLocale)
|
|
|
+{
|
|
|
+ QLocale testLocal{ QLocale() };
|
|
|
+
|
|
|
+ const bool showThousandsSeparator = false;
|
|
|
+ const int numDecimalPlaces = 2;
|
|
|
+ QString testString = "1" + QString(testLocal.decimalPoint()) + "0";
|
|
|
+ EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocal, showThousandsSeparator), testString);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRoundWithLocale)
|
|
|
+{
|
|
|
+ QLocale testLocal{ QLocale() };
|
|
|
+
|
|
|
+ const bool showThousandsSeparator = true;
|
|
|
+ const int numDecimalPlaces = 3;
|
|
|
+ QString testString = "1" + QString(testLocal.groupSeparator()) + "000" + QString(testLocal.decimalPoint()) + "123";
|
|
|
+ EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocal, showThousandsSeparator), testString);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimalWithLocale)
|
|
|
+{
|
|
|
+ QLocale testLocal{ QLocale() };
|
|
|
+
|
|
|
+ const bool showThousandsSeparator = true;
|
|
|
+ int numDecimalPlaces = 2;
|
|
|
+ QString testString = "1" + QString(testLocal.groupSeparator()) + "000" + QString(testLocal.decimalPoint()) + "0";
|
|
|
+ EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator), testString);
|
|
|
+}
|