Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Clark committed Mar 1, 2024
1 parent 447ef27 commit 3ca340d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,32 @@ func TestCompleteRow(t *testing.T) {
}
}

func TestGameOver(t *testing.T) {
gameRoot, gameInput, gameOutput := NewGame()

gameInput <- PlayInputPause
game := <-gameOutput

if game.State != StateRunning {
t.Errorf("Game not running. %d", game.State)
}

for i := 1; i < 18; i++ {
gameRoot.Field[i][5] = 1
gameRoot.Field[i][6] = 1
}

gameInput <- PlayInputPause
game = <-gameOutput

gameInput <- PlayInputDrop
game = <-gameOutput

if game.State != StateGameOver {
t.Errorf("Game not over. %d", game.State)
}
}

// func TestGetDebugState(t *testing.T) {
// // FIXME
// }
Expand Down Expand Up @@ -265,6 +291,8 @@ func TestPauseGame(t *testing.T) {
gameInput <- PlayInputPause
time.Sleep(3 * time.Second)

gameInput <- PlayInputDrop

gameInput <- PlayInputPause
game = <-gameOutput
log.Printf("%+v", game)
Expand Down

0 comments on commit 3ca340d

Please sign in to comment.