Add tests, clean-up

This commit is contained in:
Matthew Coleman 2024-03-08 13:02:01 -05:00
parent 4b7343b987
commit e980c4bb2b
2 changed files with 54 additions and 2 deletions

View File

@ -713,7 +713,33 @@ func TestNew(t *testing.T) {
},
},
{
desc: "horizontal unequal split",
desc: "horizontal, reversed unequal split",
termSize: image.Point{10, 20},
container: func(ft *faketerm.Terminal) (*Container, error) {
return New(
ft,
SplitHorizontal(
Top(
Border(linestyle.Light),
),
Bottom(
Border(linestyle.Light),
),
SplitPercentFromEnd(20),
),
)
},
want: func(size image.Point) *faketerm.Terminal {
ft := faketerm.MustNew(size)
cvs := testcanvas.MustNew(ft.Area())
testdraw.MustBorder(cvs, image.Rect(0, 0, 10, 16))
testdraw.MustBorder(cvs, image.Rect(0, 16, 10, 20))
testcanvas.MustApply(cvs, ft)
return ft
},
},
{
desc: "horizontal fixed splits",
termSize: image.Point{10, 20},
container: func(ft *faketerm.Terminal) (*Container, error) {
return New(
@ -738,6 +764,32 @@ func TestNew(t *testing.T) {
return ft
},
},
{
desc: "horizontal, reversed fixed splits",
termSize: image.Point{10, 20},
container: func(ft *faketerm.Terminal) (*Container, error) {
return New(
ft,
SplitHorizontal(
Top(
Border(linestyle.Light),
),
Bottom(
Border(linestyle.Light),
),
SplitFixedFromEnd(4),
),
)
},
want: func(size image.Point) *faketerm.Terminal {
ft := faketerm.MustNew(size)
cvs := testcanvas.MustNew(ft.Area())
testdraw.MustBorder(cvs, image.Rect(0, 0, 10, 16))
testdraw.MustBorder(cvs, image.Rect(0, 16, 10, 20))
testcanvas.MustApply(cvs, ft)
return ft
},
},
{
desc: "horizontal split, parent and children have borders",
termSize: image.Point{10, 10},