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

ClockCreationTest.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import org.junit.Ignore;
  2. import org.junit.Test;
  3. import static org.junit.Assert.assertEquals;
  4. public class ClockCreationTest {
  5. @Test
  6. public void canPrintTimeOnTheHour() {
  7. assertEquals("08:00", new Clock(8, 0).toString());
  8. }
  9. @Ignore("Remove to run test")
  10. @Test
  11. public void canPrintTimeWithMinutes() {
  12. assertEquals("11:09", new Clock(11, 9).toString());
  13. }
  14. @Ignore("Remove to run test")
  15. @Test
  16. public void midnightPrintsAsZero() {
  17. assertEquals("00:00", new Clock(24, 0).toString());
  18. }
  19. @Ignore("Remove to run test")
  20. @Test
  21. public void hourRollsOver() {
  22. assertEquals("01:00", new Clock(25, 0).toString());
  23. }
  24. @Ignore("Remove to run test")
  25. @Test
  26. public void hourRollsOverContinuously() {
  27. assertEquals("04:00", new Clock(100, 0).toString());
  28. }
  29. @Ignore("Remove to run test")
  30. @Test
  31. public void sixtyMinutesIsNextHour() {
  32. assertEquals("02:00", new Clock(1, 60).toString());
  33. }
  34. @Ignore("Remove to run test")
  35. @Test
  36. public void minutesRollOver() {
  37. assertEquals("02:40", new Clock(0, 160).toString());
  38. }
  39. @Ignore("Remove to run test")
  40. @Test
  41. public void minutesRollOverContinuously() {
  42. assertEquals("04:43", new Clock(0, 1723).toString());
  43. }
  44. @Ignore("Remove to run test")
  45. @Test
  46. public void hourAndMinutesRollOver() {
  47. assertEquals("03:40", new Clock(25, 160).toString());
  48. }
  49. @Ignore("Remove to run test")
  50. @Test
  51. public void hourAndMinutesRollOverContinuously() {
  52. assertEquals("11:01", new Clock(201, 3001).toString());
  53. }
  54. @Ignore("Remove to run test")
  55. @Test
  56. public void hourAndMinutesRollOverToExactlyMidnight() {
  57. assertEquals("00:00", new Clock(72, 8640).toString());
  58. }
  59. @Ignore("Remove to run test")
  60. @Test
  61. public void negativeHour() {
  62. assertEquals("23:15", new Clock(-1, 15).toString());
  63. }
  64. @Ignore("Remove to run test")
  65. @Test
  66. public void negativeHourRollsOver() {
  67. assertEquals("23:00", new Clock(-25, 0).toString());
  68. }
  69. @Ignore("Remove to run test")
  70. @Test
  71. public void negativeHourRollsOverContinuously() {
  72. assertEquals("05:00", new Clock(-91, 0).toString());
  73. }
  74. @Ignore("Remove to run test")
  75. @Test
  76. public void negativeMinutes() {
  77. assertEquals("00:20", new Clock(1, -40).toString());
  78. }
  79. @Ignore("Remove to run test")
  80. @Test
  81. public void negativeMinutesRollOver() {
  82. assertEquals("22:20", new Clock(1, -160).toString());
  83. }
  84. @Ignore("Remove to run test")
  85. @Test
  86. public void negativeMinutesRollOverContinuously() {
  87. assertEquals("16:40", new Clock(1, -4820).toString());
  88. }
  89. @Ignore("Remove to run test")
  90. @Test
  91. public void negativeHourAndMinutesBothRollOver() {
  92. assertEquals("20:20", new Clock(-25, -160).toString());
  93. }
  94. @Ignore("Remove to run test")
  95. @Test
  96. public void negativeHourAndMinutesBothRollOverContinuously() {
  97. assertEquals("22:10", new Clock(-121, -5810).toString());
  98. }
  99. }