EMMA Coverage Report (generated Fri Mar 15 09:08:15 CET 2013)
[all classes][jpacman.model]

COVERAGE SUMMARY FOR SOURCE FILE [GameTest.java]

nameclass, %method, %block, %line, %
GameTest.java100% (1/1)100% (4/4)100% (99/99)100% (21/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GameTest100% (1/1)100% (4/4)100% (99/99)100% (21/21)
GameTest (): void 100% (1/1)100% (3/3)100% (1/1)
testDxDyImpossibleMove (): void 100% (1/1)100% (30/30)100% (6/6)
testDxDyPossibleMove (): void 100% (1/1)100% (47/47)100% (9/9)
testGetMonsters (): void 100% (1/1)100% (19/19)100% (5/5)

1package jpacman.model;
2 
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotSame;
5import static org.junit.Assert.assertNull;
6 
7import java.util.Vector;
8 
9import org.junit.Test;
10 
11/**
12 * Series of test cases for the game itself.
13 * It makes use of the GameTestCase fixture, which
14 * contains a simple board.
15 * @author Arie van Deursen, 2007
16 * @version $Id: GameTest.java,v 1.7 2008/02/10 19:28:20 arie Exp $
17 *
18 */
19public class GameTest extends GameTestCase {
20 
21    /**
22     * Is each list of monsters a fresh one?
23     */
24    @Test
25    public void testGetMonsters() {
26        assertEquals(2, theGame.getMonsters().size());
27        // each call to getMonsters should deliver a fresh copy.
28        Vector<Monster> ms1 = theGame.getMonsters();
29        Vector<Monster> ms2 = theGame.getMonsters();
30        assertNotSame(ms1, ms2);
31    }
32 
33    /**
34     * Are the dx/dy in the player correctly set after moving
35     * the player around?
36     */
37    @Test
38    public void testDxDyPossibleMove() {
39        // start dx/dy should be zero.
40        assertEquals(0, theGame.getPlayerLastDx());
41        assertEquals(0, theGame.getPlayerLastDy());
42        // move to left empty cell -- dx should have beeen adjusted.
43        theGame.movePlayer(1, 0);
44        assertEquals(1, theGame.getPlayerLastDx());
45        assertEquals(0, theGame.getPlayerLastDy());
46        // move to up empty cell -- dy should have been adjusted.
47        theGame.movePlayer(0, -1);
48        assertEquals(0, theGame.getPlayerLastDx());
49        assertEquals(-1, theGame.getPlayerLastDy());
50    }
51 
52    /**
53     * Do the player dx/dy remain unaltered if a move fails?
54     */
55    @Test
56    public void testDxDyImpossibleMove() {
57        // start dx/dy should be zero.
58        assertEquals(0, theGame.getPlayerLastDx());
59        assertEquals(0, theGame.getPlayerLastDy());
60        // move to a wallcell -- dxdy should have been adjusted.
61        theGame.movePlayer(0, -1);
62        assertEquals(0, theGame.getPlayerLastDx());
63        assertEquals(-1, theGame.getPlayerLastDy());
64    }
65 
66}

[all classes][jpacman.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov