Forráskód Böngészése

Merge pull request #3644 from Gillibald/fixes/LineBreakCharacterTests

Add tests for the remaining break chars
Dariusz Komosiński 5 éve
szülő
commit
36c34b46d5
1 módosított fájl, 12 hozzáadás és 5 törlés
  1. 12 5
      tests/Avalonia.Skia.UnitTests/TextLayoutTests.cs

+ 12 - 5
tests/Avalonia.Skia.UnitTests/TextLayoutTests.cs

@@ -406,9 +406,13 @@ namespace Avalonia.Skia.UnitTests
         }
 
         [Theory]
-        [InlineData("abcde\r\n")]
-        [InlineData("abcde\n\r")]
-        public void Should_Break_With_BreakChar_Pair(string text)
+        [InlineData("abcde\r\n", 7)] // Carriage Return + Line Feed
+        [InlineData("abcde\n\r", 7)] // This isn't valid but we somehow have to support it.
+        [InlineData("abcde\u000A", 6)] // Line Feed
+        [InlineData("abcde\u000B", 6)] // Vertical Tab
+        [InlineData("abcde\u000C", 6)] // Form Feed
+        [InlineData("abcde\u000D", 6)] // Carriage Return
+        public void Should_Break_With_BreakChar(string text, int expectedLength)
         {
             using (Start())
             {
@@ -422,11 +426,14 @@ namespace Avalonia.Skia.UnitTests
 
                 Assert.Equal(1, layout.TextLines[0].TextRuns.Count);
 
-                Assert.Equal(7, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters.Length);
+                Assert.Equal(expectedLength, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters.Length);
 
                 Assert.Equal(5, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters[5]);
 
-                Assert.Equal(5, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters[6]);
+                if(expectedLength == 7)
+                {
+                    Assert.Equal(5, ((ShapedTextRun)layout.TextLines[0].TextRuns[0]).GlyphRun.GlyphClusters[6]);
+                }
             }
         }