github.com/frankkopp/FrankyGo@v1.0.3/test/searchtreesize/searchtreesize_test.go (about)

     1  //
     2  // FrankyGo - UCI chess engine in GO for learning purposes
     3  //
     4  // MIT License
     5  //
     6  // Copyright (c) 2018-2020 Frank Kopp
     7  //
     8  // Permission is hereby granted, free of charge, to any person obtaining a copy
     9  // of this software and associated documentation files (the "Software"), to deal
    10  // in the Software without restriction, including without limitation the rights
    11  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    12  // copies of the Software, and to permit persons to whom the Software is
    13  // furnished to do so, subject to the following conditions:
    14  //
    15  // The above copyright notice and this permission notice shall be included in all
    16  // copies or substantial portions of the Software.
    17  //
    18  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    19  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    20  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    21  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    22  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    23  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    24  // SOFTWARE.
    25  //
    26  
    27  package searchtreesize
    28  
    29  import (
    30  	"os"
    31  	"path"
    32  	"runtime"
    33  	"testing"
    34  	"time"
    35  
    36  	"github.com/op/go-logging"
    37  
    38  	"github.com/frankkopp/FrankyGo/internal/config"
    39  	mylogging "github.com/frankkopp/FrankyGo/internal/logging"
    40  )
    41  
    42  var logTest *logging.Logger
    43  
    44  // make tests run in the projects root directory
    45  func init() {
    46  	_, filename, _, _ := runtime.Caller(0)
    47  	dir := path.Join(path.Dir(filename), "../..")
    48  	err := os.Chdir(dir)
    49  	if err != nil {
    50  		panic(err)
    51  	}
    52  }
    53  
    54  // Setup the tests
    55  func TestMain(m *testing.M) {
    56  	config.Setup()
    57  	logTest = mylogging.GetTestLog()
    58  	code := m.Run()
    59  	os.Exit(code)
    60  }
    61  
    62  func TestSearchTreeSize(t *testing.T) {
    63  	if testing.Short() {
    64  		t.Skip("skipping test in short mode.")
    65  	}
    66  	SizeTest(0, 10*time.Second, 0, 80)
    67  }