Skip to content

Commit

Permalink
Add more board test case and case description
Browse files Browse the repository at this point in the history
  • Loading branch information
eloylp committed Nov 22, 2019
1 parent 6ec1366 commit 0e220dc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import (
func TestBoard_NextGen(t *testing.T) {

type sample struct {
Case string
Matrix Board
ExpectedMatrix Board
}

samples := []sample{
{
Case: "Generation 1, when board must maintain and create new cells.",
Matrix: Board{
{false, false, false, false},
{false, true, false, false},
Expand All @@ -28,12 +30,27 @@ func TestBoard_NextGen(t *testing.T) {
{false, true, true, false},
},
},
{
Case: "Generation 2, when board must kill, maintain and create some cells.",
Matrix: Board{
{false, false, false, false},
{false, true, true, false},
{true, true, true, false},
{false, true, true, false},
},
ExpectedMatrix: Board{
{false, false, false, false},
{true, false, true, false},
{true, false, false, true},
{true, false, true, false},
},
},
}

for _, s := range samples {

nextGen := s.Matrix.NextGen()
assert.Equal(t, s.ExpectedMatrix, nextGen)
assert.Equal(t, s.ExpectedMatrix, nextGen, fmt.Sprintf("Failed case: %s", s.Case))
}
}

Expand Down

0 comments on commit 0e220dc

Please sign in to comment.