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

BobTest.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import org.junit.Test;
  2. import static org.junit.Assert.*;
  3. public class BobTest {
  4. private final Bob bob = new Bob();
  5. @Test
  6. public void say_something() {
  7. assertEquals(
  8. "Whatever.",
  9. bob.hey("Tom-ay-to, tom-aaaah-to.")
  10. );
  11. }
  12. @Test
  13. public void shouting() {
  14. assertEquals(
  15. "Woah, chill out!",
  16. bob.hey("WATCH OUT!")
  17. );
  18. }
  19. @Test
  20. public void asking_a_question() {
  21. assertEquals(
  22. "Sure.",
  23. bob.hey("Does this cryogenic chamber make me look fat?")
  24. );
  25. }
  26. @Test
  27. public void asking_a_numeric_question() {
  28. assertEquals(
  29. "Sure.",
  30. bob.hey("You are, what, like 15?")
  31. );
  32. }
  33. @Test
  34. public void talking_forcefully() {
  35. assertEquals(
  36. "Whatever.",
  37. bob.hey("Let's go make out behind the gym!")
  38. );
  39. }
  40. @Test
  41. public void using_acronyms_in_regular_speech() {
  42. assertEquals(
  43. "Whatever.", bob.hey("It's OK if you don't want to go to the DMV.")
  44. );
  45. }
  46. @Test
  47. public void forceful_questions() {
  48. assertEquals(
  49. "Woah, chill out!", bob.hey("WHAT THE HELL WERE YOU THINKING?")
  50. );
  51. }
  52. @Test
  53. public void shouting_numbers() {
  54. assertEquals(
  55. "Woah, chill out!", bob.hey("1, 2, 3 GO!")
  56. );
  57. }
  58. @Test
  59. public void only_numbers() {
  60. assertEquals(
  61. "Whatever.", bob.hey("1, 2, 3")
  62. );
  63. }
  64. @Test
  65. public void question_with_only_numbers() {
  66. assertEquals(
  67. "Sure.", bob.hey("4?")
  68. );
  69. }
  70. @Test
  71. public void shouting_with_special_characters() {
  72. assertEquals(
  73. "Woah, chill out!", bob.hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
  74. );
  75. }
  76. @Test
  77. public void shouting_with_umlauts() {
  78. assertEquals(
  79. "Woah, chill out!", bob.hey("\u00dcML\u00c4\u00dcTS!")
  80. );
  81. }
  82. @Test
  83. public void calmly_speaking_with_umlauts() {
  84. assertEquals(
  85. "Whatever.", bob.hey("\u00dcML\u00e4\u00dcTS!")
  86. );
  87. }
  88. @Test
  89. public void shouting_with_no_exclamation_mark() {
  90. assertEquals(
  91. "Woah, chill out!", bob.hey("I HATE YOU")
  92. );
  93. }
  94. @Test
  95. public void statement_containing_question_mark() {
  96. assertEquals(
  97. "Whatever.", bob.hey("Ending with ? means a question.")
  98. );
  99. }
  100. @Test
  101. public void prattling_on() {
  102. assertEquals(
  103. "Sure.", bob.hey("Wait! Hang on. Are you going to be OK?")
  104. );
  105. }
  106. @Test
  107. public void silence() {
  108. assertEquals(
  109. "Fine. Be that way!", bob.hey("")
  110. );
  111. }
  112. @Test
  113. public void prolonged_silence() {
  114. assertEquals(
  115. "Fine. Be that way!", bob.hey(" ")
  116. );
  117. }
  118. }