1
0
mirror of https://github.com/maaslalani/gambit.git synced 2025-01-03 22:52:10 +02:00
gambit/position/position_test.go

39 lines
618 B
Go
Raw Normal View History

2021-12-22 06:24:53 +02:00
package position
2021-12-22 00:57:16 +02:00
2021-12-22 17:52:21 +02:00
import (
"testing"
. "github.com/maaslalani/gambit/squares"
)
2021-12-22 00:57:16 +02:00
func TestPosition(t *testing.T) {
tt := []struct {
2021-12-22 18:33:08 +02:00
s Square
2021-12-22 00:57:16 +02:00
row int
col int
}{
2021-12-22 17:52:21 +02:00
{A8, 7, 0},
{B7, 6, 1},
{C6, 5, 2},
{D5, 4, 3},
{E4, 3, 4},
{F3, 2, 5},
{G2, 1, 6},
{H1, 0, 7},
2021-12-22 00:57:16 +02:00
}
for i, tc := range tt {
p := Position{tc.row, tc.col}
2021-12-22 18:33:08 +02:00
if p.String() != string(tc.s) {
2021-12-22 00:57:16 +02:00
t.Errorf("Test %d: expected %s, got %s", i, tc.s, p.String())
}
}
for i, tc := range tt {
p := ToPosition(tc.s)
if p.Col != tc.col || p.Row != tc.row {
t.Errorf("Test %d: expected %s, got %s", i, tc.s, p.String())
}
}
}