forked from tleyden/checkerlution
/
validmovecortexinput_test.go
45 lines (34 loc) · 1.1 KB
/
validmovecortexinput_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package checkerlution
import (
"encoding/json"
"github.com/couchbaselabs/go.assert"
"github.com/couchbaselabs/logg"
ng "github.com/tleyden/neurgo"
"testing"
)
func init() {
logg.LogKeys["TEST"] = true
}
func FakePiece() Piece {
jsonString := `{"location":7,"validMoves":[{"locations":[1],"captures":[{"team":1,"piece":11}],"king":true}]}`
piecePtr := &Piece{}
jsonBytes := []byte(jsonString)
err := json.Unmarshal(jsonBytes, piecePtr)
if err != nil {
logg.LogError(err)
}
piece := *piecePtr
return piece
}
func TestNewValidMoveCortexInput(t *testing.T) {
piece := FakePiece()
validMove := piece.ValidMoves[0]
vmCortexInput := NewValidMoveCortexInput(validMove, piece)
endLocationNormalized := vmCortexInput.endLocation
expected := -1.0
logg.LogTo("TEST", "endLocationNormalized: %v", endLocationNormalized)
assert.True(t, ng.EqualsWithMaxDelta(endLocationNormalized, expected, 0.1))
assert.True(t, ng.EqualsWithMaxDelta(vmCortexInput.willBecomeKing, 1.0, 0.1))
assert.True(t, ng.EqualsWithMaxDelta(vmCortexInput.captureValue, 0.0, 0.1))
logg.LogTo("TEST", "vmCortexInput: %v", vmCortexInput)
}