Skip to content

Commit

Permalink
search: add tests for drawTable
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Dec 5, 2023
1 parent 4a19bbf commit 149cbe0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build:

test:
go test -v ./internal/chess
go test -v ./internal/search

perft-test:
go test -v ./internal/perft/
Expand Down
42 changes: 42 additions & 0 deletions internal/search/drawtable_test.go
Original file line number Diff line number Diff line change
@@ -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())
}
}

0 comments on commit 149cbe0

Please sign in to comment.