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

BobTest.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import org.junit.Before;
  4. import static org.junit.Assert.*;
  5. public class BobTest {
  6. private Bob bob;
  7. @Before
  8. public void setUp() {
  9. bob = new Bob();
  10. }
  11. @Test
  12. public void saySomething() {
  13. assertEquals(
  14. "Whatever.",
  15. bob.hey("Tom-ay-to, tom-aaaah-to.")
  16. );
  17. }
  18. @Ignore("Remove to run test")
  19. @Test
  20. public void shouting() {
  21. assertEquals(
  22. "Whoa, chill out!",
  23. bob.hey("WATCH OUT!")
  24. );
  25. }
  26. @Ignore("Remove to run test")
  27. @Test
  28. public void askingAQuestion() {
  29. assertEquals(
  30. "Sure.",
  31. bob.hey("Does this cryogenic chamber make me look fat?")
  32. );
  33. }
  34. @Ignore("Remove to run test")
  35. @Test
  36. public void askingANumericQuestion() {
  37. assertEquals(
  38. "Sure.",
  39. bob.hey("You are, what, like 15?")
  40. );
  41. }
  42. @Ignore("Remove to run test")
  43. @Test
  44. public void talkingForcefully() {
  45. assertEquals(
  46. "Whatever.",
  47. bob.hey("Let's go make out behind the gym!")
  48. );
  49. }
  50. @Ignore("Remove to run test")
  51. @Test
  52. public void usingAcronymsInRegularSpeech() {
  53. assertEquals(
  54. "Whatever.", bob.hey("It's OK if you don't want to go to the DMV.")
  55. );
  56. }
  57. @Ignore("Remove to run test")
  58. @Test
  59. public void forcefulQuestions() {
  60. assertEquals(
  61. "Whoa, chill out!", bob.hey("WHAT THE HELL WERE YOU THINKING?")
  62. );
  63. }
  64. @Ignore("Remove to run test")
  65. @Test
  66. public void shoutingNumbers() {
  67. assertEquals(
  68. "Whoa, chill out!", bob.hey("1, 2, 3 GO!")
  69. );
  70. }
  71. @Ignore("Remove to run test")
  72. @Test
  73. public void onlyNumbers() {
  74. assertEquals(
  75. "Whatever.", bob.hey("1, 2, 3")
  76. );
  77. }
  78. @Ignore("Remove to run test")
  79. @Test
  80. public void questionWithOnlyNumbers() {
  81. assertEquals(
  82. "Sure.", bob.hey("4?")
  83. );
  84. }
  85. @Ignore("Remove to run test")
  86. @Test
  87. public void shoutingWithSpecialCharacters() {
  88. assertEquals(
  89. "Whoa, chill out!", bob.hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
  90. );
  91. }
  92. @Ignore("Remove to run test")
  93. @Test
  94. public void shoutingWithUmlauts() {
  95. assertEquals(
  96. "Whoa, chill out!", bob.hey("\u00dcML\u00c4\u00dcTS!")
  97. );
  98. }
  99. @Ignore("Remove to run test")
  100. @Test
  101. public void calmlySpeakingWithUmlauts() {
  102. assertEquals(
  103. "Whatever.", bob.hey("\u00dcML\u00e4\u00dcTS!")
  104. );
  105. }
  106. @Ignore("Remove to run test")
  107. @Test
  108. public void shoutingWithNoExclamationMark() {
  109. assertEquals(
  110. "Whoa, chill out!", bob.hey("I HATE YOU")
  111. );
  112. }
  113. @Ignore("Remove to run test")
  114. @Test
  115. public void statementContainingQuestionMark() {
  116. assertEquals(
  117. "Whatever.", bob.hey("Ending with ? means a question.")
  118. );
  119. }
  120. @Ignore("Remove to run test")
  121. @Test
  122. public void prattlingOn() {
  123. assertEquals(
  124. "Sure.", bob.hey("Wait! Hang on. Are you going to be OK?")
  125. );
  126. }
  127. @Ignore("Remove to run test")
  128. @Test
  129. public void silence() {
  130. assertEquals(
  131. "Fine. Be that way!", bob.hey("")
  132. );
  133. }
  134. @Ignore("Remove to run test")
  135. @Test
  136. public void prolongedSilence() {
  137. assertEquals(
  138. "Fine. Be that way!", bob.hey(" ")
  139. );
  140. }
  141. }