diff --git a/UnitTests/DimTests.cs b/UnitTests/DimTests.cs index f0c0150e5..2b99510db 100644 --- a/UnitTests/DimTests.cs +++ b/UnitTests/DimTests.cs @@ -97,12 +97,15 @@ namespace Terminal.Gui { [Fact] public void Percent_SetsValue () { - var dim = Dim.Percent (0); - Assert.Equal ("Dim.Factor(0)", dim.ToString ()); - dim = Dim.Percent (0.5F); - Assert.Equal ("Dim.Factor(0.005)", dim.ToString ()); - dim = Dim.Percent (100); - Assert.Equal ("Dim.Factor(1)", dim.ToString ()); + float f = 0; + var dim = Dim.Percent (f); + Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ()); + f = 0.5F; + dim = Dim.Percent (f); + Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ()); + f = 100; + dim = Dim.Percent (f); + Assert.Equal ($"Dim.Factor({f/100:0.###})", dim.ToString ()); } // TODO: Other Dim.Percent tests (e.g. Equal?) diff --git a/UnitTests/PosTests.cs b/UnitTests/PosTests.cs index f3d02f103..ff4c672e1 100644 --- a/UnitTests/PosTests.cs +++ b/UnitTests/PosTests.cs @@ -155,12 +155,15 @@ namespace Terminal.Gui { [Fact] public void Percent_SetsValue () { - var pos = Pos.Percent (0); - Assert.Equal ("Pos.Factor(0)", pos.ToString ()); - pos = Pos.Percent (0.5F); - Assert.Equal ("Pos.Factor(0.005)", pos.ToString ()); - pos = Pos.Percent (100); - Assert.Equal ("Pos.Factor(1)", pos.ToString ()); + float f = 0; + var pos = Pos.Percent (f); + Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ()); + f = 0.5F; + pos = Pos.Percent (f); + Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ()); + f = 100; + pos = Pos.Percent (f); + Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ()); } [Fact]