addded services
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package engine
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBasicGameplayAndBot(t *testing.T) {
|
||||
e, err := New(VariantStandard, "", 0, "smoke-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer e.Close()
|
||||
|
||||
if !e.AddMove(Move{From: 12, To: 28}) {
|
||||
t.Fatal("e2-e4 should be legal")
|
||||
}
|
||||
if e.Turn() != ColorBlack {
|
||||
t.Fatal("expected black to move")
|
||||
}
|
||||
|
||||
bot := e.BotMove(2)
|
||||
if !e.AddMove(bot) {
|
||||
t.Fatalf("bot move should be legal: %+v", bot)
|
||||
}
|
||||
|
||||
if e.HistoryCount() != 2 {
|
||||
t.Fatalf("expected history count 2, got %d", e.HistoryCount())
|
||||
}
|
||||
|
||||
mv, ok := e.GetMoveAt(0)
|
||||
if !ok || mv.From != 12 || mv.To != 28 {
|
||||
t.Fatalf("unexpected move at index 0: %+v ok=%v", mv, ok)
|
||||
}
|
||||
|
||||
if e.IsLegal(Move{From: 12, To: 28}) {
|
||||
t.Fatal("e2 is empty now, should not be legal")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user