mchess-server/types/coordinate_test.go

26 lines
685 B
Go

package types
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Coordinate_GetSquaresOfRow(t *testing.T) {
t.Run("get row for a coordinate", func(t *testing.T) {
startSquare := Coordinate{Col: 4, Row: 2}
row := startSquare.GetSquaresOnRow()
assert.Len(t, row, 8)
assert.Equal(t,row[0].Col, 1)
assert.Equal(t,row[7].Col, 8)
})
t.Run("get column for a coordinate", func(t *testing.T) {
startSquare := Coordinate{Col: 4, Row: 2}
column := startSquare.GetSquaresOnColumn()
assert.Len(t, column, 8)
assert.Equal(t,column[0].Row, 1)
assert.Equal(t,column[7].Row, 8)
})
}