DEV-765 add some additional tests (#65)
Adds additional test coverage. Re-uses standard test cases where possible and added a few additional cases specific to some modes.
This commit is contained in:
parent
9cf20bb8ab
commit
5e629e9e93
8 changed files with 655 additions and 196 deletions
54
solo_test.go
54
solo_test.go
|
|
@ -55,3 +55,57 @@ func TestSoloIsGameOver(t *testing.T) {
|
|||
require.Equal(t, test.Expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
// Checks that a single snake doesn't end the game
|
||||
// also that:
|
||||
// - snake moves okay
|
||||
// - food gets consumed
|
||||
// - snake grows and gets health from food
|
||||
var soloCaseNotOver = gameTestCase{
|
||||
"Solo Case Game Not Over",
|
||||
&BoardState{
|
||||
Width: 10,
|
||||
Height: 10,
|
||||
Snakes: []Snake{
|
||||
{
|
||||
ID: "one",
|
||||
Body: []Point{{1, 1}, {1, 2}},
|
||||
Health: 100,
|
||||
},
|
||||
},
|
||||
Food: []Point{{0, 0}, {1, 0}},
|
||||
Hazards: []Point{},
|
||||
},
|
||||
[]SnakeMove{
|
||||
{ID: "one", Move: MoveDown},
|
||||
},
|
||||
nil,
|
||||
&BoardState{
|
||||
Width: 10,
|
||||
Height: 10,
|
||||
Snakes: []Snake{
|
||||
{
|
||||
ID: "one",
|
||||
Body: []Point{{1, 0}, {1, 1}, {1, 1}},
|
||||
Health: 100,
|
||||
},
|
||||
},
|
||||
Food: []Point{{0, 0}},
|
||||
Hazards: []Point{},
|
||||
},
|
||||
}
|
||||
|
||||
func TestSoloCreateNextBoardState(t *testing.T) {
|
||||
cases := []gameTestCase{
|
||||
// inherits these test cases from standard
|
||||
standardCaseErrNoMoveFound,
|
||||
standardCaseErrZeroLengthSnake,
|
||||
standardCaseMoveEatAndGrow,
|
||||
standardMoveAndCollideMAD,
|
||||
soloCaseNotOver,
|
||||
}
|
||||
r := SoloRuleset{}
|
||||
for _, gc := range cases {
|
||||
gc.requireValidNextState(t, &r)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue