mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 08:50:25 +01:00
Added TextFormatter unit tests that show Right has bug
This commit is contained in:
@@ -3312,4 +3312,120 @@ ssb
|
||||
);
|
||||
Assert.Equal (resultLines, wrappedLines);
|
||||
}
|
||||
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Theory]
|
||||
[InlineData ("A", 0, "")]
|
||||
[InlineData ("A", 1, "A")]
|
||||
[InlineData ("A", 2, "A")]
|
||||
[InlineData ("AB", 1, "A")]
|
||||
[InlineData ("AB", 2, "AB")]
|
||||
[InlineData ("ABC", 3, "ABC")]
|
||||
[InlineData ("ABC", 4, "ABC")]
|
||||
[InlineData ("ABC", 6, "ABC")]
|
||||
public void Draw_Horizontal_Left (string text, int width, string expectedText)
|
||||
|
||||
{
|
||||
TextFormatter tf = new ()
|
||||
{
|
||||
Size = new Size (width, 1),
|
||||
|
||||
Text = text,
|
||||
Alignment = TextAlignment.Left
|
||||
};
|
||||
tf.Draw (new Rectangle (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Theory]
|
||||
[InlineData ("A", 0, false, "")]
|
||||
[InlineData ("A", 1, false, "A")]
|
||||
[InlineData ("A", 2, false, " A")]
|
||||
[InlineData ("AB", 1, false, "A")]
|
||||
[InlineData ("AB", 2, false, "AB")]
|
||||
[InlineData ("ABC", 3, false, "ABC")]
|
||||
[InlineData ("ABC", 4, false, " ABC")]
|
||||
[InlineData ("ABC", 6, false, " ABC")]
|
||||
|
||||
[InlineData ("A", 0, true, "")]
|
||||
[InlineData ("A", 1, true, "A")]
|
||||
[InlineData ("A", 2, true, " A")]
|
||||
[InlineData ("AB", 1, true, "")] // BUGBUG: This is wrong, it should be "A"
|
||||
[InlineData ("AB", 2, true, "AB")]
|
||||
[InlineData ("ABC", 3, true, "ABC")]
|
||||
[InlineData ("ABC", 4, true, " ABC")]
|
||||
[InlineData ("ABC", 6, true, " ABC")]
|
||||
public void Draw_Horizontal_Right (string text, int width, bool autoSize, string expectedText)
|
||||
{
|
||||
TextFormatter tf = new ()
|
||||
{
|
||||
Text = text,
|
||||
Alignment = TextAlignment.Right,
|
||||
AutoSize = autoSize,
|
||||
};
|
||||
|
||||
if (!autoSize)
|
||||
{
|
||||
tf.Size = new Size (width, 1);
|
||||
}
|
||||
|
||||
tf.Draw (new Rectangle (Point.Empty, new (width, 1)), Attribute.Default, Attribute.Default);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Theory]
|
||||
[InlineData ("A", 0, "")]
|
||||
[InlineData ("A", 1, "A")]
|
||||
[InlineData ("A", 2, "A")]
|
||||
[InlineData ("A", 3, " A")]
|
||||
[InlineData ("AB", 1, "A")]
|
||||
[InlineData ("AB", 2, "AB")]
|
||||
[InlineData ("ABC", 3, "ABC")]
|
||||
[InlineData ("ABC", 4, "ABC")]
|
||||
[InlineData ("ABC", 5, " ABC")]
|
||||
[InlineData ("ABC", 6, " ABC")]
|
||||
[InlineData ("ABC", 9, " ABC")]
|
||||
public void Draw_Horizontal_Centered (string text, int width, string expectedText)
|
||||
{
|
||||
TextFormatter tf = new ()
|
||||
{
|
||||
Size = new Size (width, 1),
|
||||
Text = text,
|
||||
Alignment = TextAlignment.Centered
|
||||
};
|
||||
tf.Draw (new Rectangle (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Theory]
|
||||
[InlineData ("A", 0, "")]
|
||||
[InlineData ("A", 1, "A")]
|
||||
[InlineData ("A", 2, "A")]
|
||||
[InlineData ("A B", 3, "A B")]
|
||||
[InlineData ("A B", 1, "A")]
|
||||
[InlineData ("A B", 2, "A")]
|
||||
[InlineData ("A B", 3, "A B")]
|
||||
[InlineData ("A B", 4, "A B")]
|
||||
[InlineData ("A B", 5, "A B")]
|
||||
[InlineData ("A B", 6, "A B")]
|
||||
[InlineData ("A B", 10, "A B")]
|
||||
[InlineData ("ABC ABC", 10, "ABC ABC")]
|
||||
public void Draw_Horizontal_Justified (string text, int width, string expectedText)
|
||||
{
|
||||
TextFormatter tf = new ()
|
||||
{
|
||||
Size = new Size (width, 1),
|
||||
Text = text,
|
||||
Alignment = TextAlignment.Justified,
|
||||
};
|
||||
tf.Draw (new Rectangle (0, 0, width, 1), Attribute.Default, Attribute.Default);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user