add handing ±∞ to PerfGraphWidget.SixCharacterFormatFloat()
This commit is contained in:
committed by
Gustas Kažukauskas
parent
74c4bcc072
commit
096ad0c413
@@ -40,15 +40,21 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
int GetTextWidth(string text) => font.Measure(text).X;
|
||||
|
||||
// Try to keep the text at 6 characters long to align columns.
|
||||
public void SixCharacterFormatFloat(StringBuilder output, double value)
|
||||
{
|
||||
// Try to keep the text at 6 characters long to align columns.
|
||||
if (double.IsNaN(value))
|
||||
{
|
||||
output.Append("NaN ");
|
||||
return;
|
||||
}
|
||||
|
||||
if (double.IsInfinity(value))
|
||||
{
|
||||
output.Append(double.IsPositiveInfinity(value) ? "+Inf " : "-Inf ");
|
||||
return;
|
||||
}
|
||||
|
||||
if (value < 0)
|
||||
{
|
||||
output.Append("<0 ");
|
||||
|
||||
@@ -34,6 +34,13 @@ namespace OpenRA.Test
|
||||
AssertThat(double.NaN, "NaN ");
|
||||
}
|
||||
|
||||
[TestCase(TestName = "Infinities are reported with 2 padding spaces after.")]
|
||||
public void Infinity()
|
||||
{
|
||||
AssertThat(double.PositiveInfinity, "+Inf ");
|
||||
AssertThat(double.NegativeInfinity, "-Inf ");
|
||||
}
|
||||
|
||||
[TestCase(TestName = "Negative numbers are discarded as \"<0\" with 4 padding spaces after.")]
|
||||
public void Negative()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user