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

ClockEqualTest.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import org.junit.Ignore;
  2. import org.junit.Test;
  3. import static org.junit.Assert.assertFalse;
  4. import static org.junit.Assert.assertTrue;
  5. public class ClockEqualTest {
  6. @Ignore("Remove to run test")
  7. @Test
  8. public void clocksWithSameTimeAreEqual() {
  9. assertTrue(new Clock(15, 37).equals(new Clock(15, 37)));
  10. }
  11. @Ignore("Remove to run test")
  12. @Test
  13. public void clocksAMinuteApartAreNotEqual() {
  14. assertFalse(new Clock(15, 36).equals(new Clock(15, 37)));
  15. }
  16. @Ignore("Remove to run test")
  17. @Test
  18. public void clocksAnHourApartAreNotEqual() {
  19. assertFalse(new Clock(14, 37).equals(new Clock(15, 37)));
  20. }
  21. @Ignore("Remove to run test")
  22. @Test
  23. public void clocksWithHourOverflow() {
  24. assertTrue(new Clock(10, 37).equals(new Clock(34, 37)));
  25. }
  26. @Ignore("Remove to run test")
  27. @Test
  28. public void clocksWithHourOverflowBySeveralDays() {
  29. assertTrue(new Clock(3, 11).equals(new Clock(99, 11)));
  30. }
  31. @Ignore("Remove to run test")
  32. @Test
  33. public void clocksWithNegateHour() {
  34. assertTrue(new Clock(22, 40).equals(new Clock(-2, 40)));
  35. }
  36. @Ignore("Remove to run test")
  37. @Test
  38. public void clocksWithNegativeHourThatWraps() {
  39. assertTrue(new Clock(17, 3).equals(new Clock(-31, 3)));
  40. }
  41. @Ignore("Remove to run test")
  42. @Test
  43. public void clocksWithNegativeHourThatWrapsMultipleTimes() {
  44. assertTrue(new Clock(13, 49).equals(new Clock(-83, 49)));
  45. }
  46. @Ignore("Remove to run test")
  47. @Test
  48. public void clocksWithMinuteOverflow() {
  49. assertTrue(new Clock(0, 1).equals(new Clock(0, 1441)));
  50. }
  51. @Ignore("Remove to run test")
  52. @Test
  53. public void clocksWithMinuteOverflowBySeveralDays() {
  54. assertTrue(new Clock(2, 2).equals(new Clock(2, 4322)));
  55. }
  56. @Ignore("Remove to run test")
  57. @Test
  58. public void clocksWithNegativeMinutes() {
  59. assertTrue(new Clock(2, 40).equals(new Clock(3, -20)));
  60. }
  61. @Ignore("Remove to run test")
  62. @Test
  63. public void clocksWithNegativeMinutesThatWraps() {
  64. assertTrue(new Clock(4, 10).equals(new Clock(5, -1490)));
  65. }
  66. @Ignore("Remove to run test")
  67. @Test
  68. public void clocksWithNegativeMinutesThatWrapsMultipleTimes() {
  69. assertTrue(new Clock(6, 15).equals(new Clock(6, -4305)));
  70. }
  71. @Ignore("Remove to run test")
  72. @Test
  73. public void clocksWithNegativeHoursAndMinutes() {
  74. assertTrue(new Clock(7, 32).equals(new Clock(-12, -268)));
  75. }
  76. @Ignore("Remove to run test")
  77. @Test
  78. public void clocksWithNegativeHoursAndMinutesThatWrap() {
  79. assertTrue(new Clock(18, 7).equals(new Clock(-54, -11513)));
  80. }
  81. }