diff --git a/Makefile b/Makefile index 8b4d4c3..69f26e6 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ build: test: go test -v ./internal/chess + go test -v ./internal/search perft-test: go test -v ./internal/perft/ diff --git a/internal/search/drawtable_test.go b/internal/search/drawtable_test.go new file mode 100644 index 0000000..541a47b --- /dev/null +++ b/internal/search/drawtable_test.go @@ -0,0 +1,42 @@ +package search + +import "testing" + +const hash uint64 = 16046803855257665054 + +func TestPush(t *testing.T) { + table := newDrawTable() + + table.Push(hash) + retrieved := table.hashes[0] + if retrieved != hash { + t.Fatalf("%s: expected hash '%v' got '%v'", t.Name(), hash, retrieved) + } +} + +func TestPop(t *testing.T) { + table := newDrawTable() + table.Push(hash) + popped, ok := table.Pop() + t.Log("ok:", ok) + if popped != hash { + t.Fatalf("%s: expected hash '%v' got '%v'", t.Name(), hash, popped) + } +} + +func TestIsRepeat(t *testing.T) { + table := newDrawTable() + + table.Push(hash) + table.Push(hash) + + if table.IsRepeat(hash) != false { + t.Fatalf("%s: expected not be a draw but one was found", t.Name()) + } + + table.Push(hash) + + if table.IsRepeat(hash) != true { + t.Fatalf("%s: expected to be a draw but one was not found", t.Name()) + } +}