Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.BeforeClass;
- import org.junit.Test;
- public class PlacarTest extends Placar {
- private Placar pl;
- private static Placar pl2;
- @BeforeClass
- public static void setupBeforeClass() {
- pl2 = new Placar();
- }
- @Test
- public void testToString1() {
- String r =
- " (1) | (7) | (4) \n" +
- " --------------------------\n" +
- " (2) | (8) | (5) \n" +
- " --------------------------\n" +
- " (3) | (9) | (6) \n" +
- " --------------------------\n" +
- " | (10) | \n" +
- " +----------+ \n";
- assertEquals(pl2.toString(),r);
- }
- @Test(expected=BozoException.class)
- public void testAddPosInvalida1() {
- pl.add(0, new int[] {1,1,1,1,1});
- }
- @Test
- public void testToString2() {
- pl2.add(1, new int[] {1,1,1,1,1});
- String r =
- " 5 | (7) | (4) \n" +
- " --------------------------\n" +
- " (2) | (8) | (5) \n" +
- " --------------------------\n" +
- " (3) | (9) | (6) \n" +
- " --------------------------\n" +
- " | (10) | \n" +
- " +----------+ \n";
- assertEquals(pl2.toString(),r);
- }
- @Before
- public void setup() {
- pl = new Placar();
- }
- @Test
- public void testGetScoreVazio() {
- int k = pl.getScore();
- assertEquals(0,k);
- }
- @Test
- public void testGetScoreCheio() {
- pl.add(1, new int[] {1, 2, 3, 4, 5} );
- pl.add(2, new int[] {1, 2, 3, 4, 5} );
- pl.add(3, new int[] {1, 2, 3, 4, 5} );
- pl.add(4, new int[] {1, 2, 3, 4, 5} );
- pl.add(5, new int[] {1, 2, 3, 4, 5} );
- pl.add(6, new int[] {1, 2, 3, 4, 5} );
- pl.add(7, new int[] {1, 2, 3, 4, 5} );
- pl.add(8, new int[] {1, 2, 3, 4, 5} );
- pl.add(9, new int[] {1, 2, 3, 4, 5} );
- pl.add(10, new int[] {1, 2, 3, 4, 5} );
- int k = pl.getScore();
- assertEquals(35,k);
- }
- @After
- public void tearDown() {
- pl = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement