mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
* initial commit * All tests pass * Updated readme * Revert "All tests pass" This reverts commit94ac462350. * Revert "initial commit" This reverts commit36d92cc4e5. * Moved Terminal.Gui files around * Nuked .Graphs namespace * Nuked .Graphs namespace * Nuked .Trees namespace * Nuked .Configuration namespace * Nuked .Configuration namespace * All tests pass * tweaked tests * removed unneeded usings * re-enabled scrollview tests * move scrollview test to ScrollViewTests * Moved view navigation related tests to separate cs file * Moved view scrollbarview related tests ScrollBarTestse * Refactored View tests into smaller files * Refactored driver tests * Fixed a ton of BUGBUGs
This commit is contained in:
87
UnitTests/Text/UnicodeTests.cs
Normal file
87
UnitTests/Text/UnicodeTests.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using NStack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terminal.Gui;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
// Alias Console to MockConsole so we don't accidentally use Console
|
||||
using Console = Terminal.Gui.FakeConsole;
|
||||
|
||||
namespace Terminal.Gui.TextTests {
|
||||
public class UnicodeTests {
|
||||
readonly ITestOutputHelper output;
|
||||
|
||||
public UnicodeTests (ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0x0000001F, 0x241F)]
|
||||
[InlineData (0x0000007F, 0x247F)]
|
||||
[InlineData (0x0000009F, 0x249F)]
|
||||
[InlineData (0x0001001A, 0x1001A)]
|
||||
public void MakePrintable_Converts_Control_Chars_To_Proper_Unicode (uint code, uint expected)
|
||||
{
|
||||
var actual = ConsoleDriver.MakePrintable (code);
|
||||
|
||||
Assert.Equal (expected, actual.Value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0x20)]
|
||||
[InlineData (0x7E)]
|
||||
[InlineData (0xA0)]
|
||||
[InlineData (0x010020)]
|
||||
public void MakePrintable_Does_Not_Convert_Ansi_Chars_To_Unicode (uint code)
|
||||
{
|
||||
var actual = ConsoleDriver.MakePrintable (code);
|
||||
|
||||
Assert.Equal (code, actual.Value);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void AddRune_On_Clip_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space ()
|
||||
{
|
||||
var tv = new TextView () {
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
Text = @"これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。
|
||||
これは広いルーンラインです。"
|
||||
};
|
||||
var win = new Window ("ワイドルーン") { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
win.Add (tv);
|
||||
Application.Top.Add (win);
|
||||
var lbl = new Label ("ワイドルーン。");
|
||||
var dg = new Dialog ("テスト", 14, 4, new Button ("選ぶ"));
|
||||
dg.Add (lbl);
|
||||
Application.Begin (Application.Top);
|
||||
Application.Begin (dg);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (30, 10);
|
||||
|
||||
var expected = @"
|
||||
┌┤ワイドルーン├──────────────┐
|
||||
│これは広いルーンラインです。│
|
||||
│これは広いルーンラインです。│
|
||||
│これは ┌┤テスト├────┐ です。│
|
||||
│これは │ワイドルーン│ です。│
|
||||
│これは │ [ 選ぶ ] │ です。│
|
||||
│これは └────────────┘ です。│
|
||||
│これは広いルーンラインです。│
|
||||
│これは広いルーンラインです。│
|
||||
└────────────────────────────┘
|
||||
";
|
||||
|
||||
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
||||
Assert.Equal (new Rect (0, 0, 30, 10), pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user