Advertisement
Guest User

progm

a guest
Apr 27th, 2017
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. import static org.junit.Assert.*;
  2.  
  3. import org.junit.After;
  4. import org.junit.Before;
  5. import org.junit.BeforeClass;
  6. import org.junit.Test;
  7.  
  8. public class PlacarTest extends Placar {
  9.  
  10. private Placar pl;
  11. private static Placar pl2;
  12.  
  13.     @BeforeClass
  14.     public static void setupBeforeClass() {
  15.         pl2 = new Placar();
  16.     }
  17.    
  18.     @Test
  19.     public void testToString1() {
  20.         String r =
  21.                         " (1)    |   (7)    |   (4) \n" +
  22.                         " --------------------------\n" +
  23.                         " (2)    |   (8)    |   (5) \n" +
  24.                         " --------------------------\n" +
  25.                         " (3)    |   (9)    |   (6) \n" +
  26.                         " --------------------------\n" +
  27.                         "        |   (10)   |       \n" +
  28.                         "        +----------+       \n";
  29.         assertEquals(pl2.toString(),r);
  30.     }
  31.    
  32.     @Test(expected=BozoException.class)
  33.     public void testAddPosInvalida1() {
  34.         pl.add(0, new int[] {1,1,1,1,1});
  35.        
  36.     }
  37.    
  38.  
  39.    
  40.     @Test
  41.     public void testToString2() {
  42.         pl2.add(1, new int[] {1,1,1,1,1});
  43.         String r =
  44.                         " 5     |   (7)    |   (4) \n" +
  45.                         " --------------------------\n" +
  46.                         " (2)    |   (8)    |   (5) \n" +
  47.                         " --------------------------\n" +
  48.                         " (3)    |   (9)    |   (6) \n" +
  49.                         " --------------------------\n" +
  50.                         "        |   (10)   |       \n" +
  51.                         "        +----------+       \n";
  52.         assertEquals(pl2.toString(),r);
  53.     }
  54.  
  55.     @Before
  56.     public void setup() {
  57.         pl = new Placar();
  58.     }
  59.    
  60.     @Test
  61.     public void testGetScoreVazio() {
  62.         int k = pl.getScore();
  63.         assertEquals(0,k);
  64.     }
  65.    
  66.     @Test
  67.     public void testGetScoreCheio() {
  68.         pl.add(1, new int[] {1, 2, 3, 4, 5} );
  69.         pl.add(2, new int[] {1, 2, 3, 4, 5} );
  70.         pl.add(3, new int[] {1, 2, 3, 4, 5} );
  71.         pl.add(4, new int[] {1, 2, 3, 4, 5} );
  72.         pl.add(5, new int[] {1, 2, 3, 4, 5} );
  73.         pl.add(6, new int[] {1, 2, 3, 4, 5} );
  74.         pl.add(7, new int[] {1, 2, 3, 4, 5} );
  75.         pl.add(8, new int[] {1, 2, 3, 4, 5} );
  76.         pl.add(9, new int[] {1, 2, 3, 4, 5} );
  77.         pl.add(10, new int[] {1, 2, 3, 4, 5} );
  78.         int k = pl.getScore();
  79.         assertEquals(35,k);
  80.     }
  81.    
  82.     @After
  83.     public void tearDown() {
  84.         pl = null;
  85.     }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement