1
0
mirror of https://github.com/maaslalani/gambit.git synced 2025-01-14 02:23:04 +02:00

border_test

This commit is contained in:
Maas Lalani 2021-12-25 23:13:58 -05:00
parent d997be5af2
commit 2cb018acb0
No known key found for this signature in database
GPG Key ID: 5A6ED5CBF1A0A000
3 changed files with 42 additions and 4 deletions

View File

@ -29,7 +29,6 @@ func Cell(x, y int) string {
col := (x - marginLeft) / cellWidth
row := board.LastRow - (y-marginTop)/cellHeight
return position.ToSquare(row, col)
}
// withMarginLeft returns a string with a prepended left margin

39
border/border_test.go Normal file
View File

@ -0,0 +1,39 @@
package border_test
import (
"testing"
"github.com/maaslalani/gambit/border"
)
func TestTopBorder(t *testing.T) {
tests := []struct {
borderFunc func() string
want string
}{
{
border.Top,
" ┌───┬───┬───┬───┬───┬───┬───┬───┐\n",
},
{
border.Middle,
" ├───┼───┼───┼───┼───┼───┼───┼───┤\n",
},
{
border.Bottom,
" └───┴───┴───┴───┴───┴───┴───┴───┘\n",
},
{
border.BottomLabels,
" A B C D E F G H\n",
},
}
for _, test := range tests {
got := test.borderFunc()
if got != test.want {
t.Errorf("want %s, got %s", test.want, got)
}
}
}

View File

@ -8,7 +8,7 @@ func fg(color string) colorFunc {
return NewStyle().Foreground(Color(color)).Render
}
var Magenta = fg("5")
var Faint = fg("8")
var Red = fg("1")
var Cyan = fg("6")
var Faint = fg("8")
var Magenta = fg("5")
var Red = fg("1")