From b94ca727ea3a64d83ee5df7861ef956838d1eca9 Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 24 Nov 2023 23:54:25 +0000 Subject: [PATCH] Add unit test for WordWrap. --- UnitTests/Text/TextFormatterTests.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/UnitTests/Text/TextFormatterTests.cs b/UnitTests/Text/TextFormatterTests.cs index 32f2a799a..740e847cf 100644 --- a/UnitTests/Text/TextFormatterTests.cs +++ b/UnitTests/Text/TextFormatterTests.cs @@ -1508,6 +1508,7 @@ ssb 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)); @@ -1528,6 +1529,26 @@ ssb 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);