Skip to content

Commit

Permalink
Add unit test for WordWrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp committed Nov 24, 2023
1 parent 063cea8 commit b94ca72
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions UnitTests/Text/TextFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@ public void TabWith_PreserveTrailingSpaces_False (int width, int height, TextDir
tf.TabWidth = tabWidth;
tf.Text = text;

Assert.False (tf.WordWrap);
Assert.False (tf.PreserveTrailingSpaces);
Assert.Equal (new Size (width, height), tf.Size);
tf.Draw (new Rect (0, 0, width, height), new Attribute (ColorName.White, ColorName.Black), new Attribute (ColorName.Blue, ColorName.Black));
Expand All @@ -1528,6 +1529,26 @@ public void TabWith_PreserveTrailingSpaces_True (int width, int height, TextDire
tf.PreserveTrailingSpaces = true;
tf.Text = text;

Assert.False (tf.WordWrap);
Assert.Equal (new Size (width, height), tf.Size);
tf.Draw (new Rect (0, 0, width, height), new Attribute (ColorName.White, ColorName.Black), new Attribute (ColorName.Blue, ColorName.Black));
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
}

[Theory, AutoInitShutdown]
[InlineData (17, 1, TextDirection.LeftRight_TopBottom, 4, "This is a Tab")]
[InlineData (1, 17, TextDirection.TopBottom_LeftRight, 4, "T\nh\ni\ns\n \ni\ns\n \na\n \n \n \n \n \nT\na\nb")]
[InlineData (13, 1, TextDirection.LeftRight_TopBottom, 0, "This is a Tab")]
[InlineData (1, 13, TextDirection.TopBottom_LeftRight, 0, "T\nh\ni\ns\n \ni\ns\n \na\n \nT\na\nb")]
public void TabWith_WordWrap_True (int width, int height, TextDirection textDirection, int tabWidth, string expected)
{
var text = "This is a \tTab";
var tf = new TextFormatter ();
tf.Direction = textDirection;
tf.TabWidth = tabWidth;
tf.WordWrap = true;
tf.Text = text;

Assert.Equal (new Size (width, height), tf.Size);
tf.Draw (new Rect (0, 0, width, height), new Attribute (ColorName.White, ColorName.Black), new Attribute (ColorName.Blue, ColorName.Black));
TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Expand Down

0 comments on commit b94ca72

Please sign in to comment.