Slide 49
Slide 49 text
@Test public void perfect() throws Exception {
assertEquals(300, game.score(new Integer[]
{10,10,10,10,10,10,10,10,10,10,10,10}));
}
@Test public void alternatingStrikeSpare() throws Exception {
assertEquals(200, game.score(new Integer[]
{ 10,5,5, 10,5,5, 10,5,5, 10,5,5, 10,5,5, 10}));
}
@Test public void alternatingSpareStrike() throws Exception {
assertEquals(200, game.score(new Integer[]
{ 5,5, 10,5,5, 10,5,5, 10,5,5, 10,5,5, 10,5,5}));
}
@Test public void trailingSpare() throws Exception {
assertEquals(20, game.score(new Integer[]
{ 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 10,5,5}));
}
@Test public void pitStrikeFinalFrame() throws Exception {
assertEquals(15, game.score(new Integer[]
{ 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 10,2,3}));
}
@Test public void pitStrikeNinthFrame() throws Exception {
assertEquals(20, game.score(new Integer[]
{ 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 10, 2,3}));
}
}
package haskellBowling;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class BowlingGameTest {
BowlingGame game;
@Before public void setUp() throws Exception {
game = new BowlingGame();
}
@Test public void hookup() {
assertTrue(true);
}
@Test public void opens() throws Exception {
assertEquals(60, game.score(new Integer[]
{3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}));
}
@Test public void spare() throws Exception {
assertEquals(22, game.score(new Integer[]
{6,4,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));
}
Version 4b - Java - domain-rich - Version 4 (inspired by Dan Meadâs Haskell version) corrected to include Pitâs two new tests - Ron Jeffries
â This test is referred to by Tom Moertel as the ninth-frame-strike test.
â
Pit
1..10
ten-ness