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
|
|
@ -246,3 +246,77 @@ func TestEdgeCrossingEating(t *testing.T) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
// Checks that snakes moving out of bounds get wrapped to the other side.
|
||||
var wrappedCaseMoveAndWrap = gameTestCase{
|
||||
"Wrapped Case Move and Wrap",
|
||||
&BoardState{
|
||||
Width: 10,
|
||||
Height: 10,
|
||||
Snakes: []Snake{
|
||||
{
|
||||
ID: "one",
|
||||
Body: []Point{{0, 0}, {1, 0}},
|
||||
Health: 100,
|
||||
},
|
||||
{
|
||||
ID: "two",
|
||||
Body: []Point{{3, 4}, {3, 3}},
|
||||
Health: 100,
|
||||
},
|
||||
{
|
||||
ID: "three",
|
||||
Body: []Point{},
|
||||
Health: 100,
|
||||
EliminatedCause: EliminatedBySelfCollision,
|
||||
},
|
||||
},
|
||||
Food: []Point{},
|
||||
Hazards: []Point{},
|
||||
},
|
||||
[]SnakeMove{
|
||||
{ID: "one", Move: MoveLeft},
|
||||
{ID: "two", Move: MoveUp},
|
||||
{ID: "three", Move: MoveLeft}, // Should be ignored
|
||||
},
|
||||
nil,
|
||||
&BoardState{
|
||||
Width: 10,
|
||||
Height: 10,
|
||||
Snakes: []Snake{
|
||||
{
|
||||
ID: "one",
|
||||
Body: []Point{{9, 0}, {0, 0}},
|
||||
Health: 99,
|
||||
},
|
||||
{
|
||||
ID: "two",
|
||||
Body: []Point{{3, 5}, {3, 4}},
|
||||
Health: 99,
|
||||
},
|
||||
{
|
||||
ID: "three",
|
||||
Body: []Point{},
|
||||
Health: 100,
|
||||
EliminatedCause: EliminatedBySelfCollision,
|
||||
},
|
||||
},
|
||||
Food: []Point{},
|
||||
Hazards: []Point{},
|
||||
},
|
||||
}
|
||||
|
||||
func TestWrappedCreateNextBoardState(t *testing.T) {
|
||||
cases := []gameTestCase{
|
||||
// inherits these test cases from standard
|
||||
standardCaseErrNoMoveFound,
|
||||
standardCaseErrZeroLengthSnake,
|
||||
standardCaseMoveEatAndGrow,
|
||||
standardMoveAndCollideMAD,
|
||||
wrappedCaseMoveAndWrap,
|
||||
}
|
||||
r := WrappedRuleset{}
|
||||
for _, gc := range cases {
|
||||
gc.requireValidNextState(t, &r)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue