DMYCompareTest.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2025. Andrew Grant Carrick Software. All rights reserved
  3. *
  4. */
  5. package scot.carricksoftware.grantswriter.data;
  6. import org.junit.jupiter.api.BeforeEach;
  7. import org.junit.jupiter.api.Test;
  8. import static org.junit.jupiter.api.Assertions.assertEquals;
  9. class DMYCompareTest {
  10. private DMY dmy;
  11. @BeforeEach
  12. void setUp() {
  13. dmy = new DMYImpl();
  14. String sunday = "25/01/1953";
  15. dmy.parse(sunday);
  16. }
  17. @Test
  18. void equalityTest() {
  19. DMY dmySunday2 = new DMYImpl();
  20. String sunday2 = "25/01/1953";
  21. dmySunday2.parse(sunday2);
  22. assertEquals(0, dmy.compareTo(dmySunday2));
  23. }
  24. @Test
  25. void nextDayTest() {
  26. String monday = "26/01/1953";
  27. DMY dmyMonday = new DMYImpl();
  28. dmyMonday.parse(monday);
  29. assertEquals(-1, dmy.compareTo(dmyMonday));
  30. }
  31. @Test
  32. void previousDayTest() {
  33. String saturday = "24/01/1953";
  34. DMY dmySaturday = new DMYImpl();
  35. dmySaturday.parse(saturday);
  36. assertEquals(1, dmy.compareTo(dmySaturday));
  37. }
  38. }