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

HandshakeCalculatorTest.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import org.junit.Ignore;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4. import static java.util.Arrays.asList;
  5. import static java.util.Collections.emptyList;
  6. import static java.util.Collections.singletonList;
  7. import static org.junit.Assert.assertEquals;
  8. public final class HandshakeCalculatorTest {
  9. private HandshakeCalculator handshakeCalculator;
  10. @Before
  11. public void setUp() {
  12. handshakeCalculator = new HandshakeCalculator();
  13. }
  14. @Test
  15. public void testThatInput1YieldsAWink() {
  16. assertEquals(
  17. singletonList(Signal.WINK),
  18. handshakeCalculator.calculateHandshake(1));
  19. }
  20. @Ignore
  21. @Test
  22. public void testThatInput2YieldsADoubleBlink() {
  23. assertEquals(
  24. singletonList(Signal.DOUBLE_BLINK),
  25. handshakeCalculator.calculateHandshake(2));
  26. }
  27. @Ignore
  28. @Test
  29. public void testThatInput4YieldsACloseYourEyes() {
  30. assertEquals(
  31. singletonList(Signal.CLOSE_YOUR_EYES),
  32. handshakeCalculator.calculateHandshake(4));
  33. }
  34. @Ignore
  35. @Test
  36. public void testThatInput8YieldsAJump() {
  37. assertEquals(
  38. singletonList(Signal.JUMP),
  39. handshakeCalculator.calculateHandshake(8));
  40. }
  41. @Ignore
  42. @Test
  43. public void testAnInputThatYieldsTwoActions() {
  44. assertEquals(
  45. asList(Signal.WINK, Signal.DOUBLE_BLINK),
  46. handshakeCalculator.calculateHandshake(3));
  47. }
  48. @Ignore
  49. @Test
  50. public void testAnInputThatYieldsTwoReversedActions() {
  51. assertEquals(
  52. asList(Signal.DOUBLE_BLINK, Signal.WINK),
  53. handshakeCalculator.calculateHandshake(19));
  54. }
  55. @Ignore
  56. @Test
  57. public void testReversingASingleActionYieldsTheSameAction() {
  58. assertEquals(
  59. singletonList(Signal.JUMP),
  60. handshakeCalculator.calculateHandshake(24));
  61. }
  62. @Ignore
  63. @Test
  64. public void testReversingNoActionsYieldsNoActions() {
  65. assertEquals(
  66. emptyList(),
  67. handshakeCalculator.calculateHandshake(16));
  68. }
  69. @Ignore
  70. @Test
  71. public void testInputThatYieldsAllActions() {
  72. assertEquals(
  73. asList(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP),
  74. handshakeCalculator.calculateHandshake(15));
  75. }
  76. @Ignore
  77. @Test
  78. public void testInputThatYieldsAllActionsReversed() {
  79. assertEquals(
  80. asList(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK),
  81. handshakeCalculator.calculateHandshake(31));
  82. }
  83. @Ignore
  84. @Test
  85. public void testThatInput0YieldsNoActions() {
  86. assertEquals(
  87. emptyList(),
  88. handshakeCalculator.calculateHandshake(0));
  89. }
  90. @Ignore
  91. @Test
  92. public void testThatInputWithLower5BitsNotSetYieldsNoActions() {
  93. assertEquals(
  94. emptyList(),
  95. handshakeCalculator.calculateHandshake(32));
  96. }
  97. }