From 746cdc262d27a6855eec12abefefb98d72be50e2 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 1 Aug 2020 00:27:32 +0100 Subject: [PATCH] Fixing TextFormatter unit test. --- Terminal.Gui/Core/TextFormatter.cs | 2 +- UnitTests/TextFormatterTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Core/TextFormatter.cs b/Terminal.Gui/Core/TextFormatter.cs index 7fe96445d..98e58c2b8 100644 --- a/Terminal.Gui/Core/TextFormatter.cs +++ b/Terminal.Gui/Core/TextFormatter.cs @@ -47,7 +47,7 @@ namespace Terminal.Gui { set { text = value; - if (Size.Width == 0 || Size.Height == 0 || Size.Width != text.RuneCount) { + if (text.RuneCount > 0 && (Size.Width == 0 || Size.Height == 0 || Size.Width != text.RuneCount)) { // Proivde a default size (width = length of longest line, height = 1) // TODO: It might makem more sense for the default to be width = length of first line? Size = new Size (TextFormatter.MaxWidth (Text, int.MaxValue), 1); diff --git a/UnitTests/TextFormatterTests.cs b/UnitTests/TextFormatterTests.cs index 17200127b..c20fafb10 100644 --- a/UnitTests/TextFormatterTests.cs +++ b/UnitTests/TextFormatterTests.cs @@ -533,8 +533,8 @@ namespace Terminal.Gui { { Assert.Equal (Rect.Empty, TextFormatter.CalcRect (0, 0, null)); Assert.Equal (Rect.Empty, TextFormatter.CalcRect (0, 0, "")); - Assert.Equal (Rect.Empty, TextFormatter.CalcRect (1, 2, "")); - Assert.Equal (Rect.Empty, TextFormatter.CalcRect (-1, -2, "")); + Assert.Equal (new Rect (new Point (1, 2), Size.Empty), TextFormatter.CalcRect (1, 2, "")); + Assert.Equal (new Rect (new Point (-1, -2), Size.Empty), TextFormatter.CalcRect (-1, -2, "")); } [Fact]