From 2cb018acb05060620b4d312a21006302d485c076 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Sat, 25 Dec 2021 23:13:58 -0500 Subject: [PATCH] border_test --- border/border.go | 1 - border/border_test.go | 39 +++++++++++++++++++++++++++++++++++++++ style/style.go | 6 +++--- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 border/border_test.go diff --git a/border/border.go b/border/border.go index 5c4ee9f..b7aec2f 100644 --- a/border/border.go +++ b/border/border.go @@ -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 diff --git a/border/border_test.go b/border/border_test.go new file mode 100644 index 0000000..6b177da --- /dev/null +++ b/border/border_test.go @@ -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) + } + } +} diff --git a/style/style.go b/style/style.go index f25e49d..21fbe94 100644 --- a/style/style.go +++ b/style/style.go @@ -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")