From 1682eb0aa7943c1b77b02faa4b840d89981b6ee8 Mon Sep 17 00:00:00 2001 From: Michael Dvorkin Date: Sun, 3 May 2015 11:11:40 -0700 Subject: [PATCH] Removed UCI tests --- engine_uci_test.go | 98 ---------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 engine_uci_test.go diff --git a/engine_uci_test.go b/engine_uci_test.go deleted file mode 100644 index 61361c5..0000000 --- a/engine_uci_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2014-2015 by Michael Dvorkin. All Rights Reserved. -// Use of this source code is governed by a MIT-style license that can -// be found in the LICENSE file. - -package donna - -import ( - `github.com/michaeldv/donna/expect` - `io/ioutil` - `os` - `syscall` - `testing` -) - -// Mocks os.Stdin by redirecting standard input to read data from a temporary -// file we create. -func mockStdin(input string) (string, error) { - // Create temporary file with read/write access. - f, err := ioutil.TempFile(``, `donna`) - if err != nil { - return ``, err - } - - // Save the file name and write input string to the file. - mock := f.Name() - f.WriteString(input) - f.Close() - - // Reopen the file in read-only mode. - f, err = os.Open(mock) - if err != nil { - return mock, err - } - defer f.Close() - - // Redirect os.Stdin (fd=0) to read from the file. - syscall.Dup2(int(f.Fd()), int(os.Stdin.Fd())) - - return mock, nil -} - -// Resores os.Stdin and removes input mock file. -func unmockStdin(mock string) { - os.Stdin = os.NewFile(uintptr(syscall.Stdin), `/dev/stdin`) - if mock != `` { - os.Remove(mock) - } -} - -func TestUci000(t *testing.T) { - mock, err := mockStdin("position startpos\ngo test movetime 12345\nquit\n") - - if err != nil { - t.Errorf(err.Error()) - } else { - defer unmockStdin(mock) - defer NewEngine() - - engine := NewEngine().Uci() - expect.Eq(t, engine.options.moveTime, int64(12345)) - expect.Eq(t, engine.options.timeLeft, int64(0)) - expect.Eq(t, engine.options.timeInc, int64(0)) - } -} - -func TestUci010(t *testing.T) { - mock, err := mockStdin("position startpos\ngo test wtime 12345 btime 98765 movestogo 42\nquit\n") - - if err != nil { - t.Errorf(err.Error()) - } else { - defer unmockStdin(mock) - defer NewEngine() - - engine := NewEngine().Uci() - expect.Eq(t, engine.options.timeLeft, int64(12345)) - expect.Eq(t, engine.options.moveTime, int64(0)) - expect.Eq(t, engine.options.timeInc, int64(0)) - expect.Eq(t, engine.options.movesToGo, int64(42)) - } -} - -func TestUci020(t *testing.T) { - mock, err := mockStdin("position startpos moves e2e4\ngo test wtime 12345 btime 98765 movestogo 42\nquit\n") - - if err != nil { - t.Errorf(err.Error()) - } else { - defer unmockStdin(mock) - defer NewEngine() - - engine := NewEngine().Uci() - expect.Eq(t, engine.options.timeLeft, int64(98765)) - expect.Eq(t, engine.options.moveTime, int64(0)) - expect.Eq(t, engine.options.timeInc, int64(0)) - expect.Eq(t, engine.options.movesToGo, int64(42)) - } -}