go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/matchmaker/pkg/sim/player_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2024 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package sim
     9  
    10  import (
    11  	"testing"
    12  
    13  	"go.charczuk.com/sdk/assert"
    14  	c9s "go.charczuk.com/sdk/collections"
    15  	"go.charczuk.com/sdk/uuid"
    16  )
    17  
    18  func Test_Player_WinrateRecent(t *testing.T) {
    19  	p := new(Player)
    20  	p.ID = uuid.V4()
    21  	p.Recent = new(c9s.Queue[*Game])
    22  	p.Recent.Push(mockGame(p, TeamA, TeamA))
    23  	p.Recent.Push(mockGame(p, TeamA, TeamB))
    24  	p.Recent.Push(mockGame(p, TeamA, TeamA))
    25  	p.Recent.Push(mockGame(p, TeamA, TeamB))
    26  	assert.ItsEqual(t, 0.5, p.WinrateRecent())
    27  }