From 9925eeefbe864b81b96dffdb67b69b2572eca679 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 18 Dec 2018 13:15:24 +0100 Subject: Add minimal function to match all events. --- src/main.rs | 12 ++++++++++++ test/fixtures/events.ics | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/fixtures/events.ics diff --git a/src/main.rs b/src/main.rs index af10ccb..28575d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,6 +62,18 @@ fn read_icalendar_from_file(filename: &str) -> std::io::Result bool { + true +} + +#[test] +fn match_all_events() { + let cal = read_icalendar_from_file("test/fixtures/events.ics").unwrap(); + let num_events = cal[0].events.len(); + let events:Vec<_> = cal[0].events.iter().filter(|ref event| match_event(&event, "*")).collect(); + assert_eq!(num_events, events.len()); +} + fn main() { let calendars = read_icalendar_from_file("test.ics").unwrap(); println!("Found {} calendard in file...", calendars.len()); diff --git a/test/fixtures/events.ics b/test/fixtures/events.ics new file mode 100644 index 0000000..c55bfc7 --- /dev/null +++ b/test/fixtures/events.ics @@ -0,0 +1,51 @@ +BEGIN:VCALENDAR +VERSION:2.0 +CALSCALE:GREGORIAN +PRODID:-//SabreDAV//SabreDAV//EN +BEGIN:VEVENT +CREATED:20180322T132017Z +UID:57ece320-0356-4414-9b47-85081558cfa2 +DTEND;VALUE=DATE:20180403 +TRANSP:OPAQUE +SUMMARY:All day event #1 +DTSTART;VALUE=DATE:20180324 +DTSTAMP:20180323T080006Z +LAST-MODIFIED:20180323T070051Z +SEQUENCE:0 +BEGIN:VALARM +UID:c4e86f58-e52e-41fc-812e-9d965f005934 +TRIGGER:-PT15H +ATTACH;VALUE=URI:Basso +ACTION:AUDIO +ACKNOWLEDGED:20180323T080006Z +END:VALARM +END:VEVENT +BEGIN:VEVENT +CREATED:20170424T102200Z +UID:1ef050b0-29d2-40f0-8740-832e7c57fcc8 +DTEND;VALUE=DATE:20170506 +TRANSP:TRANSPARENT +SUMMARY:All day event #2 +DTSTART;VALUE=DATE:20170502 +DTSTAMP:20170501T082505Z +SEQUENCE:0 +LAST-MODIFIED:20170501T082505Z +BEGIN:VALARM +UID:af60bb7a-9d35-4f0d-b0b3-48b09e6047a2 +TRIGGER:-PT15H +ATTACH:Basso +ACTION:AUDIO +ACKNOWLEDGED:20170501T082505Z +END:VALARM +END:VEVENT +BEGIN:VEVENT +CREATED:20180124T102605Z +UID:e9387460-417d-4cb1-b583-ee495cb8582c +DTEND;TZID=Europe/Tallinn:20180126T150000 +TRANSP:OPAQUE +SUMMARY:Event with timezone info +DTSTART;TZID=Europe/Tallinn:20180126T120000 +DTSTAMP:20180124T102652Z +SEQUENCE:0 +END:VEVENT +END:VCALENDAR -- cgit v1.2.3