mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Remove NStack and replace ustring to string.
* Add unit test and improving some code.
* Adjust code and fix all unit tests errors.
* Add XML Document and move the Rune folder into the Text folder.
* Improve unit tests with byte array on DecodeRune and DecodeLastRune.
* Fix unit test.
* 😂Code review
* Reduce unit tests code.
* Change StringExtensions.Make to StringExtensions.ToString and added some more unit tests.
* Fix merge errors.
* Remove GetTextWidth and calls replaced with StringExtensions.GetColumns.
* Hack to use UseSystemConsole passed in the command line arguments.
* Revert "Hack to use UseSystemConsole passed in the command line arguments."
This reverts commit b74d11c786.
* Remove Application.UseSystemConsole from the config file.
* Fix errors related by removing UseSystemConsole from the config file.
* Fixes #2633. DecodeEscSeq throw an exception if cki is null.
* Fix an exception if SelectedItem is -1.
* Set SelectedItem to 0 and remove unnecessary ToString.
* Using a unique ToString method for Rune and other for byte.
* Fix a bug where a wider rune is added with only a width of 1.
* Force the SelectedGlyph is the one that was typed after jumpList is executed.
* Added more InlineData to RuneTests.
* Reducing significantly the code by using Theory attribute in the TextFormatterTests.
* Override PositionCursor to handle the CharMap cursor position.
* Fix merge errors.
* Minor tweaks to API docs
---------
Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
using Xunit;
|
||
|
||
namespace Terminal.Gui.TextTests;
|
||
|
||
#nullable enable
|
||
|
||
public class StringTests {
|
||
[Fact]
|
||
public void TestGetColumns_Empty ()
|
||
{
|
||
var str = string.Empty;
|
||
Assert.Equal (0, str.GetColumns ());
|
||
}
|
||
|
||
[Fact]
|
||
public void TestGetColumns_Null ()
|
||
{
|
||
string? str = null;
|
||
Assert.Equal (0, str.GetColumns ());
|
||
}
|
||
|
||
[Fact]
|
||
public void TestGetColumns_SingleRune ()
|
||
{
|
||
var str = "a";
|
||
Assert.Equal (1, str.GetColumns ());
|
||
}
|
||
|
||
[Theory]
|
||
[InlineData ("a", 1)]
|
||
[InlineData ("á", 1)]
|
||
[InlineData ("ab", 2)]
|
||
[InlineData ("áé", 2)]
|
||
[InlineData ("abc", 3)]
|
||
[InlineData ("áéí", 3)]
|
||
[InlineData ("abcd", 4)]
|
||
public void TestGetColumns_MultiRune (string str, int expected)
|
||
{
|
||
Assert.Equal (expected, str.GetColumns ());
|
||
}
|
||
|
||
// Test known wide codepoints
|
||
[Theory]
|
||
[InlineData ("🙂", 2)]
|
||
[InlineData ("a🙂", 3)]
|
||
[InlineData ("🙂a", 3)]
|
||
[InlineData ("👨👩👦👦", 8)]
|
||
[InlineData ("👨👩👦👦🙂", 10)]
|
||
[InlineData ("👨👩👦👦🙂a", 11)]
|
||
[InlineData ("👨👩👦👦a🙂", 11)]
|
||
[InlineData ("👨👩👦👦👨👩👦👦", 16)]
|
||
[InlineData ("山", 2)] // The character for "mountain" in Chinese/Japanese/Korean (山), Unicode U+5C71
|
||
[InlineData ("山🙂", 4)] // The character for "mountain" in Chinese/Japanese/Korean (山), Unicode U+5C71
|
||
public void TestGetColumns_MultiRune_WideBMP (string str, int expected)
|
||
{
|
||
Assert.Equal (expected, str.GetColumns ());
|
||
}
|
||
|
||
// Test non-BMP codepoints
|
||
// Face with Tears of Joy Emoji (😂), Unicode U+1F602 is 2 columns wide
|
||
[Theory]
|
||
[InlineData ("😂", 2)]
|
||
[InlineData ("😂😂", 4)]
|
||
public void TestGetColumns_MultiRune_NonBMP (string str, int expected)
|
||
{
|
||
Assert.Equal (expected, str.GetColumns ());
|
||
}
|
||
|
||
}
|
||
|