lots of exercises in java... from https://github.com/exercism/java

DiamondPrinterTest.java 6.6KB

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