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

TwelveDaysTest.java 8.9KB

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