[evolution-data-server] I#366 - Calendar: Correct 'occur-in-time-range?' for zero-length events



commit c6c2aeb9ba6b400586686b6eb0c9dd1a2d3be979
Author: Milan Crha <mcrha redhat com>
Date:   Mon Nov 8 16:19:08 2021 +0100

    I#366 - Calendar: Correct 'occur-in-time-range?' for zero-length events
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/366

 src/calendar/libecal/e-cal-recur.c         |  8 ++++++--
 tests/libedata-cal/components/event-0.ics  | 12 ++++++++++++
 tests/libedata-cal/test-cal-cache-search.c | 10 +++++++++-
 tests/libedata-cal/test-cal-cache-utils.c  |  5 ++++-
 tests/libedata-cal/test-cal-cache-utils.h  |  1 +
 5 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/libecal/e-cal-recur.c b/src/calendar/libecal/e-cal-recur.c
index 34b90dab4..a912fc1f4 100644
--- a/src/calendar/libecal/e-cal-recur.c
+++ b/src/calendar/libecal/e-cal-recur.c
@@ -343,8 +343,12 @@ intersects_interval (const ICalTime *tt,
                i_cal_time_adjust (ttend, default_duration_days, 0, 0, default_duration_seconds);
        }
 
-       res = e_timetype_compare_without_date (ttstart, interval_end) < 0 &&
-             e_timetype_compare_without_date (interval_start, ttend) < 0;
+       if (i_cal_time_compare (ttstart, ttend) == 0)
+               res = e_timetype_compare_without_date (ttstart, interval_end) < 0 &&
+                     e_timetype_compare_without_date (interval_start, ttend) <= 0;
+       else
+               res = e_timetype_compare_without_date (ttstart, interval_end) < 0 &&
+                     e_timetype_compare_without_date (interval_start, ttend) < 0;
 
        g_clear_object (&ttstart);
        g_clear_object (&ttend);
diff --git a/tests/libedata-cal/components/event-0.ics b/tests/libedata-cal/components/event-0.ics
new file mode 100644
index 000000000..0934961e3
--- /dev/null
+++ b/tests/libedata-cal/components/event-0.ics
@@ -0,0 +1,12 @@
+BEGIN:VEVENT
+UID:event-0
+DTSTAMP:20170130T000000Z
+CREATED:20170216T155507Z
+LAST-MODIFIED:20170216T155543Z
+SEQUENCE:1
+DTSTART:20170209T013000Z
+SUMMARY:Zero length
+DESCRIPTION:No DTEND/DUE properties
+CLASS:PUBLIC
+TRANSP:OPACHE
+END:VEVENT
diff --git a/tests/libedata-cal/test-cal-cache-search.c b/tests/libedata-cal/test-cal-cache-search.c
index a008915bc..8c046bc45 100644
--- a/tests/libedata-cal/test-cal-cache-search.c
+++ b/tests/libedata-cal/test-cal-cache-search.c
@@ -275,6 +275,13 @@ test_search_occur_in_time_range (TCUFixture *fixture,
        test_search (fixture, "(occur-in-time-range? (make-time \"20170221T180000Z\") (make-time 
\"20170221T190000Z\") \"America/New_York\")", "event-6");
        test_search (fixture, "(occur-in-time-range? (make-time \"20170221T200000Z\") (make-time 
\"20170221T210000Z\") \"Europe/Berlin\")", "!event-6");
        test_search (fixture, "(occur-in-time-range? (make-time \"20170221T180000Z\") (make-time 
\"20170221T190000Z\") \"Europe/Berlin\")", "event-6");
+
+       /* event-0 */
+       test_search (fixture, "(occur-in-time-range? (make-time \"20170209T000000Z\") (make-time 
\"20170209T012900Z\"))", "!event-0");
+       test_search (fixture, "(occur-in-time-range? (make-time \"20170209T000000Z\") (make-time 
\"20170209T013000Z\"))", "!event-0");
+       test_search (fixture, "(occur-in-time-range? (make-time \"20170209T010000Z\") (make-time 
\"20170209T020000Z\"))", "event-0");
+       test_search (fixture, "(occur-in-time-range? (make-time \"20170209T013000Z\") (make-time 
\"20170209T020000Z\"))", "event-0");
+       test_search (fixture, "(occur-in-time-range? (make-time \"20170209T013100Z\") (make-time 
\"20170209T020000Z\"))", "!event-0");
 }
 
 static void
@@ -474,6 +481,7 @@ main (gint argc,
       gchar **argv)
 {
        TCUClosure closure_events = { TCU_LOAD_COMPONENT_SET_EVENTS };
+       TCUClosure closure_events0 = { TCU_LOAD_COMPONENT_SET_EVENTS_WITH_0 };
        TCUClosure closure_tasks = { TCU_LOAD_COMPONENT_SET_TASKS };
 
 #if !GLIB_CHECK_VERSION (2, 35, 1)
@@ -490,7 +498,7 @@ main (gint argc,
 
        g_test_add ("/ECalCache/Search/Uid", TCUFixture, &closure_events,
                tcu_fixture_setup, test_search_uid, tcu_fixture_teardown);
-       g_test_add ("/ECalCache/Search/OccurInTimeRange", TCUFixture, &closure_events,
+       g_test_add ("/ECalCache/Search/OccurInTimeRange", TCUFixture, &closure_events0,
                tcu_fixture_setup, test_search_occur_in_time_range, tcu_fixture_teardown);
        g_test_add ("/ECalCache/Search/DueInTimeRange", TCUFixture, &closure_tasks,
                tcu_fixture_setup, test_search_due_in_time_range, tcu_fixture_teardown);
diff --git a/tests/libedata-cal/test-cal-cache-utils.c b/tests/libedata-cal/test-cal-cache-utils.c
index 767e8894c..33fd12949 100644
--- a/tests/libedata-cal/test-cal-cache-utils.c
+++ b/tests/libedata-cal/test-cal-cache-utils.c
@@ -93,7 +93,7 @@ tcu_fixture_setup (TCUFixture *fixture,
        g_free (filename);
 
        if (closure) {
-               if (closure->load_set == TCU_LOAD_COMPONENT_SET_EVENTS) {
+               if (closure->load_set == TCU_LOAD_COMPONENT_SET_EVENTS || closure->load_set == 
TCU_LOAD_COMPONENT_SET_EVENTS_WITH_0) {
                        tcu_add_component_from_test_case (fixture, "event-1", NULL);
                        tcu_add_component_from_test_case (fixture, "event-2", NULL);
                        tcu_add_component_from_test_case (fixture, "event-3", NULL);
@@ -104,6 +104,9 @@ tcu_fixture_setup (TCUFixture *fixture,
                        tcu_add_component_from_test_case (fixture, "event-7", NULL);
                        tcu_add_component_from_test_case (fixture, "event-8", NULL);
                        tcu_add_component_from_test_case (fixture, "event-9", NULL);
+
+                       if (closure->load_set == TCU_LOAD_COMPONENT_SET_EVENTS_WITH_0)
+                               tcu_add_component_from_test_case (fixture, "event-0", NULL);
                } else if (closure->load_set == TCU_LOAD_COMPONENT_SET_TASKS) {
                        tcu_add_component_from_test_case (fixture, "task-1", NULL);
                        tcu_add_component_from_test_case (fixture, "task-2", NULL);
diff --git a/tests/libedata-cal/test-cal-cache-utils.h b/tests/libedata-cal/test-cal-cache-utils.h
index 7d62148e2..42dfa1866 100644
--- a/tests/libedata-cal/test-cal-cache-utils.h
+++ b/tests/libedata-cal/test-cal-cache-utils.h
@@ -28,6 +28,7 @@ void          tcu_read_args                           (gint argc,
 typedef enum {
        TCU_LOAD_COMPONENT_SET_NONE,
        TCU_LOAD_COMPONENT_SET_EVENTS,
+       TCU_LOAD_COMPONENT_SET_EVENTS_WITH_0,
        TCU_LOAD_COMPONENT_SET_TASKS
 } TCULoadComponentSet;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]