@@ 16,51 16,49 @@ package tcell
import (
"testing"
-
- . "github.com/smartystreets/goconvey/convey"
)
func TestCanDisplay(t *testing.T) {
- Convey("With a UTF-8 screen", t,
- WithScreen(t, "UTF-8", func(s SimulationScreen) {
- So(s.CharacterSet(), ShouldEqual, "UTF-8")
- So(s.CanDisplay('a', true), ShouldBeTrue)
- So(s.CanDisplay(RuneHLine, true), ShouldBeTrue)
- So(s.CanDisplay(RuneHLine, false), ShouldBeTrue)
- So(s.CanDisplay('⌀', false), ShouldBeTrue)
- }))
- Convey("With an ASCII screen", t,
- WithScreen(t, "US-ASCII", func(s SimulationScreen) {
- So(s.CharacterSet(), ShouldEqual, "US-ASCII")
- So(s.CanDisplay('a', true), ShouldBeTrue)
- So(s.CanDisplay(RuneHLine, true), ShouldBeTrue)
- So(s.CanDisplay(RunePi, false), ShouldBeFalse)
- So(s.CanDisplay('⌀', false), ShouldBeFalse)
- }))
+ WithScreen(t, "UTF-8", func(s SimulationScreen) {
+ assertEqual("utf8 1", s.CharacterSet(), "UTF-8", t)
+ assertEqual("utf8 2", s.CanDisplay('a', true), true, t)
+ assertEqual("utf8 3", s.CanDisplay(RuneHLine, true), true, t)
+ assertEqual("utf8 4", s.CanDisplay(RuneHLine, false), true, t)
+ assertEqual("utf8 5", s.CanDisplay('⌀', false), true, t)
+ })()
+
+ WithScreen(t, "US-ASCII", func(s SimulationScreen) {
+ assertEqual("ascii 1", s.CharacterSet(), "US-ASCII", t)
+ assertEqual("ascii 2", s.CanDisplay('a', true), true, t)
+ assertEqual("ascii 3", s.CanDisplay(RuneHLine, true), true, t)
+ assertEqual("ascii 4", s.CanDisplay(RunePi, false), false, t)
+ assertEqual("ascii 5", s.CanDisplay('⌀', false), false, t)
+ })()
}
func TestRegisterFallback(t *testing.T) {
- Convey("With an ASCII screen", t,
- WithScreen(t, "US-ASCII", func(s SimulationScreen) {
- So(s.CharacterSet(), ShouldEqual, "US-ASCII")
- s.RegisterRuneFallback('⌀', "o")
- So(s.CanDisplay('⌀', false), ShouldBeFalse)
- So(s.CanDisplay('⌀', true), ShouldBeTrue)
- s.UnregisterRuneFallback('⌀')
- So(s.CanDisplay('⌀', false), ShouldBeFalse)
- So(s.CanDisplay('⌀', true), ShouldBeFalse)
- }))
+
+ WithScreen(t, "US-ASCII", func(s SimulationScreen) {
+ assertEqual("ascii 1", s.CharacterSet(), "US-ASCII", t)
+ s.RegisterRuneFallback('⌀', "o")
+ assertEqual("registered false", s.CanDisplay('⌀', false), false, t)
+ assertEqual("registered true", s.CanDisplay('⌀', true), true, t)
+ s.UnregisterRuneFallback('⌀')
+ assertEqual("unregistered false", s.CanDisplay('⌀', false), false, t)
+ assertEqual("unregistered true", s.CanDisplay('⌀', true), false, t)
+ })()
}
func TestUnregisterFallback(t *testing.T) {
- Convey("With an ASCII screen (HLine)", t,
- WithScreen(t, "US-ASCII", func(s SimulationScreen) {
- So(s.CharacterSet(), ShouldEqual, "US-ASCII")
- So(s.CanDisplay(RuneHLine, true), ShouldBeTrue)
- s.UnregisterRuneFallback(RuneHLine)
- So(s.CanDisplay(RuneHLine, true), ShouldBeFalse)
- }))
+
+ WithScreen(t, "US-ASCII", func(s SimulationScreen) {
+ assertEqual("ascii 1", s.CharacterSet(), "US-ASCII", t)
+
+ assertEqual("registered", s.CanDisplay(RuneHLine, true), true, t)
+ s.UnregisterRuneFallback(RuneHLine)
+ assertEqual("unregistered", s.CanDisplay(RuneHLine, true), false, t)
+ })()
}
@@ 122,8 122,8 @@ func TestClearScreen(t *testing.T) {
}
func TestSetCell(t *testing.T) {
- st := StyleDefault.Background(ColorRed).Blink(true)
WithScreen(t, "", func(s SimulationScreen) {
+ st := StyleDefault.Background(ColorRed).Blink(true)
s.SetContent(2, 5, '@', nil, st)
b, x, y := s.GetContents()
assertEqual("x", x, 80, t)
@@ 142,8 142,8 @@ func TestSetCell(t *testing.T) {
}
func TestResize(t *testing.T) {
- st := StyleDefault.Background(ColorYellow).Underline(true)
WithScreen(t, "", func(s SimulationScreen) {
+ st := StyleDefault.Background(ColorYellow).Underline(true)
s.SetContent(2, 5, '&', nil, st)
b, _, _ := s.GetContents()
s.Show()