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

ClockCreationTest.java 3.1KB

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