Skip to content

Commit

Permalink
Add test for line recognition with span
Browse files Browse the repository at this point in the history
  • Loading branch information
steffi3011 committed Feb 25, 2022
1 parent ab22328 commit 70e25b9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/SixLabors.Fonts.Tests/TextLayoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,26 @@ public void CountLines(string text, int usedLines)
Assert.Equal(usedLines, count);
}

[Fact]
public void CountLinesWithSpan()
{
Font font = CreateFont("hello\n!");

Span<char> text = stackalloc char[]
{
'h',
'e',
'l',
'l',
'o',
'\n',
'!'
};
int count = TextMeasurer.CountLines(text, new TextOptions(font) { Dpi = font.FontMetrics.ScaleFactor });

Assert.Equal(2, count);
}

[Theory]
[InlineData("This is a long and Honorificabilitudinitatibus califragilisticexpialidocious", 25, 7)]
[InlineData("This is a long and Honorificabilitudinitatibus califragilisticexpialidocious", 50, 7)]
Expand Down

0 comments on commit 70e25b9

Please sign in to comment.