mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Fixes #4382. StringExtensions.GetColumns method should only return the total text width and not the sum of all runes width * Trying to fix unit test error * Update StringExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Resolving merge conflicts * Prevents Runes throwing if Grapheme is null * Add unit test to prove that null and empty string doesn't not throws anything. * Fix unit test failure * Fix IsValidLocation for wide graphemes * Add more combining * Prevent set invalid graphemes * Fix unit tests * Grapheme doesn't support invalid code points like lone surrogates * Fixes more unit tests * Fix unit test * Seems all test are fixed now * Adjust CharMap scenario with graphemes * Upgrade Wcwidth to version 4.0.0 * Reformat * Trying fix CheckDefaultState assertion * Revert "Trying fix CheckDefaultState assertion" This reverts commitc9b46b796a. * Forgot to include driver.End in the test * Reapply "Trying fix CheckDefaultState assertion" This reverts commit1060ac9b63. * Remove ToString * Fix merge errors * Change to conditional expression * Assertion to prove that no exception throws during cell initialization. * Remove unnecessary assignment * Remove assignment to end * Replace string concatenation with 'StringBuilder'. * Replace more string concatenation with 'StringBuilder' * Remove redundant call to 'ToString' because Rune cast to a String object. * Replace foreach loop with Sum linq --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
using UnitTests;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace UnitTests_Parallelizable.DriverTests;
|
|
|
|
public class DriverTests : FakeDriverBase
|
|
{
|
|
[Theory]
|
|
[InlineData (null, true)]
|
|
[InlineData ("", true)]
|
|
[InlineData ("a", true)]
|
|
[InlineData ("👩❤️💋👨", false)]
|
|
public void IsValidLocation (string text, bool positive)
|
|
{
|
|
IDriver driver = CreateFakeDriver ();
|
|
driver.SetScreenSize (10, 10);
|
|
|
|
// positive
|
|
Assert.True (driver.IsValidLocation (text, 0, 0));
|
|
Assert.True (driver.IsValidLocation (text, 1, 1));
|
|
Assert.Equal (positive, driver.IsValidLocation (text, driver.Cols - 1, driver.Rows - 1));
|
|
|
|
// negative
|
|
Assert.False (driver.IsValidLocation (text, -1, 0));
|
|
Assert.False (driver.IsValidLocation (text, 0, -1));
|
|
Assert.False (driver.IsValidLocation (text, -1, -1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows - 1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows - 1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows));
|
|
|
|
// Define a clip rectangle
|
|
driver.Clip = new (new Rectangle (5, 5, 5, 5));
|
|
|
|
// positive
|
|
Assert.True (driver.IsValidLocation (text, 5, 5));
|
|
Assert.Equal (positive, driver.IsValidLocation (text, 9, 9));
|
|
|
|
// negative
|
|
Assert.False (driver.IsValidLocation (text, 4, 5));
|
|
Assert.False (driver.IsValidLocation (text, 5, 4));
|
|
Assert.False (driver.IsValidLocation (text, 10, 9));
|
|
Assert.False (driver.IsValidLocation (text, 9, 10));
|
|
Assert.False (driver.IsValidLocation (text, -1, 0));
|
|
Assert.False (driver.IsValidLocation (text, 0, -1));
|
|
Assert.False (driver.IsValidLocation (text, -1, -1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows - 1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows - 1));
|
|
Assert.False (driver.IsValidLocation (text, driver.Cols, driver.Rows));
|
|
|
|
driver.End ();
|
|
}
|
|
}
|