Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.60 KB | None | 0 0
  1. import org.junit.Ignore;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4.  
  5. import java.util.List;
  6.  
  7. import static java.util.Arrays.asList;
  8. import static java.util.Collections.singletonList;
  9. import static org.hamcrest.CoreMatchers.is;
  10. import static org.junit.Assert.assertThat;
  11.  
  12. public class DiamondPrinterTest {
  13.  
  14.     private DiamondPrinter diamondPrinter;
  15.  
  16.     @Before
  17.     public void setUp() {
  18.         diamondPrinter = new DiamondPrinter();
  19.     }
  20.  
  21.     @Test
  22.     public void testOneByOneDiamond() {
  23.         List<String> output = diamondPrinter.printToList('A');
  24.         assertThat(output, is(singletonList("A")));
  25.     }
  26.  
  27.     @Ignore("Remove to run test")
  28.     @Test
  29.     public void testTwoByTwoDiamond() {
  30.         List<String> output = diamondPrinter.printToList('B');
  31.         assertThat(output, is(asList(" A ",
  32.                                      "B B",
  33.                                      " A ")));
  34.     }
  35.  
  36.     @Ignore("Remove to run test")
  37.     @Test
  38.     public void testThreeByThreeDiamond() {
  39.         List<String> output = diamondPrinter.printToList('C');
  40.         assertThat(output, is(asList("  A  ",
  41.                                      " B B ",
  42.                                      "C   C",
  43.                                      " B B ",
  44.                                      "  A  ")));
  45.     }
  46.  
  47.     @Ignore("Remove to run test")
  48.     @Test
  49.     public void testFourByFourDiamond() {
  50.         List<String> output = diamondPrinter.printToList('D');
  51.         assertThat(output, is(asList("   A   ",
  52.                                      "  B B  ",
  53.                                      " C   C ",
  54.                                      "D     D",
  55.                                      " C   C ",
  56.                                      "  B B  ",
  57.                                      "   A   ")));
  58.     }
  59.  
  60.     @Ignore("Remove to run test")
  61.     @Test
  62.     public void testFullDiamond() {
  63.         List<String> output = diamondPrinter.printToList('Z');
  64.         assertThat(output, is(asList("                         A                         ",
  65.                                      "                        B B                        ",
  66.                                      "                       C   C                       ",
  67.                                      "                      D     D                      ",
  68.                                      "                     E       E                     ",
  69.                                      "                    F         F                    ",
  70.                                      "                   G           G                   ",
  71.                                      "                  H             H                  ",
  72.                                      "                 I               I                 ",
  73.                                      "                J                 J                ",
  74.                                      "               K                   K               ",
  75.                                      "              L                     L              ",
  76.                                      "             M                       M             ",
  77.                                      "            N                         N            ",
  78.                                      "           O                           O           ",
  79.                                      "          P                             P          ",
  80.                                      "         Q                               Q         ",
  81.                                      "        R                                 R        ",
  82.                                      "       S                                   S       ",
  83.                                      "      T                                     T      ",
  84.                                      "     U                                       U     ",
  85.                                      "    V                                         V    ",
  86.                                      "   W                                           W   ",
  87.                                      "  X                                             X  ",
  88.                                      " Y                                               Y ",
  89.                                      "Z                                                 Z",
  90.                                      " Y                                               Y ",
  91.                                      "  X                                             X  ",
  92.                                      "   W                                           W   ",
  93.                                      "    V                                         V    ",
  94.                                      "     U                                       U     ",
  95.                                      "      T                                     T      ",
  96.                                      "       S                                   S       ",
  97.                                      "        R                                 R        ",
  98.                                      "         Q                               Q         ",
  99.                                      "          P                             P          ",
  100.                                      "           O                           O           ",
  101.                                      "            N                         N            ",
  102.                                      "             M                       M             ",
  103.                                      "              L                     L              ",
  104.                                      "               K                   K               ",
  105.                                      "                J                 J                ",
  106.                                      "                 I               I                 ",
  107.                                      "                  H             H                  ",
  108.                                      "                   G           G                   ",
  109.                                      "                    F         F                    ",
  110.                                      "                     E       E                     ",
  111.                                      "                      D     D                      ",
  112.                                      "                       C   C                       ",
  113.                                      "                        B B                        ",
  114.                                      "                         A                         ")));
  115.     }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement