mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 08:17:53 +01:00
* initial * basically working * removed test settings * removed extra usings * Improved API docs * Renamed glyphs to be consistent and use unicode names; use char literals * Refactored Glyphs class & Json format to not be static (startup perf) * Refactored Glyphs class & Json format to not be static (startup perf) * Fixed a bunch of API doc errors * Switched checked/selected to glyhps from box drawing range * Switched button glyphs to nicer looking ones that seem to work on standard fonts * Upgraded LineDrawing scenario * CrossHair->Cross * Fixed unit tests * Fixed unit tests; moved Glyphs from Application to ConfigurationManager; added CM global using alias * Found and replaced all other special glyphs; fixed more unit tests
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
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 (new Button ("選ぶ")) { Width = 14, Height = 4 };
|
|
dg.Add (lbl);
|
|
Application.Begin (Application.Top);
|
|
Application.Begin (dg);
|
|
((FakeDriver)Application.Driver).SetBufferSize (30, 10);
|
|
|
|
var expected = @$"
|
|
┌────────────────────────────┐
|
|
│これは広いルーンラインです。│
|
|
│これは広いルーンラインです。│
|
|
│これは ┌────────────┐ です。│
|
|
│これは │ワイドルーン│ です。│
|
|
│これは │ {CM.Glyphs.LeftBracket} 選ぶ {CM.Glyphs.RightBracket} │ です。│
|
|
│これは └────────────┘ です。│
|
|
│これは広いルーンラインです。│
|
|
│これは広いルーンラインです。│
|
|
└────────────────────────────┘
|
|
";
|
|
|
|
var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
|
|
Assert.Equal (new Rect (0, 0, 30, 10), pos);
|
|
}
|
|
}
|
|
} |