浏览代码

fixed culture issue

Charlie Kindel 5 年之前
父节点
当前提交
24e0c0f1bf
共有 2 个文件被更改,包括 18 次插入12 次删除
  1. 9 6
      UnitTests/DimTests.cs
  2. 9 6
      UnitTests/PosTests.cs

+ 9 - 6
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?)

+ 9 - 6
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]