aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-12-18 13:15:24 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-12-18 13:15:24 +0100
commit9925eeefbe864b81b96dffdb67b69b2572eca679 (patch)
tree131927fd0b5e77a8e6fa5122b08f45abb797f875
parent20a3b4e71b3706e1ee15a8f3d3d9640fd3a8b460 (diff)
downloadicaltool-9925eeefbe864b81b96dffdb67b69b2572eca679.tar.gz
icaltool-9925eeefbe864b81b96dffdb67b69b2572eca679.tar.bz2
icaltool-9925eeefbe864b81b96dffdb67b69b2572eca679.zip
Add minimal function to match all events.
-rw-r--r--src/main.rs12
-rw-r--r--test/fixtures/events.ics51
2 files changed, 63 insertions, 0 deletions
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<Vec<ical::parser:
.collect())
}
+fn match_event(_event: &ical::parser::ical::component::IcalEvent, _pattern: &str) -> 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