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

TwelveDaysTest.java 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import org.junit.Before;
  2. import org.junit.Ignore;
  3. import org.junit.Test;
  4. import static org.junit.Assert.assertEquals;
  5. public class TwelveDaysTest {
  6. private TwelveDays twelveDays;
  7. @Before
  8. public void setup() {
  9. twelveDays = new TwelveDays();
  10. }
  11. @Test
  12. public void testVerseOne() {
  13. String expectedVerseOne = "On the first day of Christmas my true love gave to me, " +
  14. "a Partridge in a Pear Tree.\n";
  15. assertEquals(expectedVerseOne, twelveDays.verse(1));
  16. }
  17. @Ignore
  18. @Test
  19. public void testVerseTwo() {
  20. String expectedVerseTwo = "On the second day of Christmas my true love gave to me, two Turtle Doves, " +
  21. "and a Partridge in a Pear Tree.\n";
  22. assertEquals(expectedVerseTwo, twelveDays.verse(2));
  23. }
  24. @Ignore
  25. @Test
  26. public void testVerseThree() {
  27. String expectedVerseThree = "On the third day of Christmas my true love gave to me, three French Hens, " +
  28. "two Turtle Doves, and a Partridge in a Pear Tree.\n";
  29. assertEquals(expectedVerseThree, twelveDays.verse(3));
  30. }
  31. @Ignore
  32. @Test
  33. public void testVerseFour() {
  34. String expectedVerseFour = "On the fourth day of Christmas my true love gave to me, four Calling Birds, " +
  35. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  36. assertEquals(expectedVerseFour, twelveDays.verse(4));
  37. }
  38. @Ignore
  39. @Test
  40. public void testVerseFive() {
  41. String expectedVerseFive = "On the fifth day of Christmas my true love gave to me, five Gold Rings, " +
  42. "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  43. assertEquals(expectedVerseFive, twelveDays.verse(5));
  44. }
  45. @Ignore
  46. @Test
  47. public void testVerseSix() {
  48. String expectedVerseSix = "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, " +
  49. "five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
  50. "and a Partridge in a Pear Tree.\n";
  51. assertEquals(expectedVerseSix, twelveDays.verse(6));
  52. }
  53. @Ignore
  54. @Test
  55. public void testVerseSeven() {
  56. String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me, " +
  57. "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " +
  58. "two Turtle Doves, and a Partridge in a Pear Tree.\n";
  59. assertEquals(expectedVerseSeven, twelveDays.verse(7));
  60. }
  61. @Ignore
  62. @Test
  63. public void testVerseEight() {
  64. String expectedVerseEight = "On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking," +
  65. " seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
  66. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  67. assertEquals(expectedVerseEight, twelveDays.verse(8));
  68. }
  69. @Ignore
  70. @Test
  71. public void testVerseNine() {
  72. String expectedVerseNine = "On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, " +
  73. "eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
  74. "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  75. assertEquals(expectedVerseNine, twelveDays.verse(9));
  76. }
  77. @Ignore
  78. @Test
  79. public void testVerseTen() {
  80. String expectedVerseTen = "On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, " +
  81. "nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " +
  82. "five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
  83. "and a Partridge in a Pear Tree.\n";
  84. assertEquals(expectedVerseTen, twelveDays.verse(10));
  85. }
  86. @Ignore
  87. @Test
  88. public void testVerseEleven() {
  89. String expectedVerseEleven = "On the eleventh day of Christmas my true love gave to me, " +
  90. "eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
  91. "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
  92. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  93. assertEquals(expectedVerseEleven, twelveDays.verse(11));
  94. }
  95. @Ignore
  96. @Test
  97. public void testVerseTwelve() {
  98. String expectedVerseTwelve = "On the twelfth day of Christmas my true love gave to me, " +
  99. "twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, " +
  100. "eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
  101. "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  102. assertEquals(expectedVerseTwelve, twelveDays.verse(12));
  103. }
  104. @Ignore
  105. @Test
  106. public void testMultipleVerses() {
  107. String expectedVerseOneToThree = "On the first day of Christmas my true love gave to me, " +
  108. "a Partridge in a Pear Tree.\n\n" +
  109. "On the second day of Christmas my true love gave to me, two Turtle Doves, " +
  110. "and a Partridge in a Pear Tree.\n\n" +
  111. "On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, " +
  112. "and a Partridge in a Pear Tree.\n";
  113. assertEquals(expectedVerseOneToThree, twelveDays.verses(1, 3));
  114. }
  115. @Ignore
  116. @Test
  117. public void testSingWholeSong() {
  118. String expectedSong = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n" +
  119. "\n" +
  120. "On the second day of Christmas my true love gave to me, two Turtle Doves, " +
  121. "and a Partridge in a Pear Tree.\n" +
  122. "\n" +
  123. "On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, " +
  124. "and a Partridge in a Pear Tree.\n" +
  125. "\n" +
  126. "On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, " +
  127. "two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  128. "\n" +
  129. "On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, " +
  130. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  131. "\n" +
  132. "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, " +
  133. "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  134. "\n" +
  135. "On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, " +
  136. "six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
  137. "and a Partridge in a Pear Tree.\n" +
  138. "\n" +
  139. "On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, " +
  140. "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
  141. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  142. "\n" +
  143. "On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking," +
  144. " seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
  145. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  146. "\n" +
  147. "On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing," +
  148. " eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
  149. "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n" +
  150. "\n" +
  151. "On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, " +
  152. "ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, " +
  153. "six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
  154. "and a Partridge in a Pear Tree.\n" +
  155. "\n" +
  156. "On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, " +
  157. "eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
  158. "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
  159. "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
  160. assertEquals(expectedSong, twelveDays.sing());
  161. }
  162. }