Browse Source

Adjust companion hint formatting for the Translate element

Marcin Ziąbek 3 months ago
parent
commit
d194cb47a6

+ 1 - 0
Source/QuestPDF.UnitTests/TranslateTests.cs

@@ -15,6 +15,7 @@ namespace QuestPDF.UnitTests
         [TestCase(0, 15, "Y=15")]
         [TestCase(0, 15, "Y=15")]
         [TestCase(0, -20, "Y=-20")]
         [TestCase(0, -20, "Y=-20")]
         [TestCase(30, -40, "X=30   Y=-40")]
         [TestCase(30, -40, "X=30   Y=-40")]
+        [TestCase(1.2345f, -2.3456f, "X=1.2   Y=-2.3")]
         public void CompanionHint(float x, float y, string expected)
         public void CompanionHint(float x, float y, string expected)
         {
         {
             var container = EmptyContainer.Create();
             var container = EmptyContainer.Create();

+ 1 - 1
Source/QuestPDF/Elements/Translate.cs

@@ -20,7 +20,7 @@ namespace QuestPDF.Elements
 
 
         internal override string? GetCompanionHint()
         internal override string? GetCompanionHint()
         {
         {
-            return string.Join("   ", GetOptions().Where(x => x.value != 0).Select(x => $"{x.Label}={x.value}"));
+            return string.Join("   ", GetOptions().Where(x => x.value != 0).Select(x => $"{x.Label}={x.value:F1}"));
             
             
             IEnumerable<(string Label, float value)> GetOptions()
             IEnumerable<(string Label, float value)> GetOptions()
             {
             {