Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
Add test to verify parser handles \r\n.
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 authored and Peltoche committed Jan 17, 2024
1 parent 79b0e65 commit 6c265a5
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ pub mod parser {
}
}

#[test]
// same as ical_example_1 but with \r\n endings instead of \n.
fn ical_example_2() {
let input = BufReader::new(File::open("./tests/ressources/ical_example_2.ics").unwrap());

let valids = std::fs::read_to_string("./tests/ressources/ical_example_2.res")
.unwrap()
.replace('\n', "");

let reader = ical::IcalParser::new(input);

for res in reader {
let calendar = match res {
Ok(res) => res,
Err(err) => panic!("{}", err),
};

let output = format!("{:?}", calendar);

assert_eq!(output, valids);
}
}

#[test]
fn vcard() {
let input = BufReader::new(File::open("./tests/ressources/vcard_input.vcf").unwrap());
Expand Down
47 changes: 47 additions & 0 deletions tests/ressources/ical_example_2.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:16011028T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010325T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20210511T063845Z
DESCRIPTION:Einwahldaten folgen in der Veranstaltungswoche \nSeminartitel:
Software-QS-Cast - Application Performance Monitoring\nDatum: 27.Mai 2021\
nUhrzeit: 10:30 - ca.12:00 Uhr \n \n
DTEND;TZID="W. Europe Standard Time":20210527T120000
DTSTAMP:20210511T063845Z
DTSTART;TZID="W. Europe Standard Time":20210527T103000
LAST-MODIFIED:20210511T063845Z
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=de:Software-QS-Cast Application Performance Monitoring
TRANSP:OPAQUE
UID:040000008200E000*************00800000000*****************00000000000000
010000000********************************
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-CONFTYPE:0
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
35 changes: 35 additions & 0 deletions tests/ressources/ical_example_2.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
IcalCalendar {
properties: [
Property { name: "PRODID", params: None, value: Some("-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN") },
Property { name: "VERSION", params: None, value: Some("2.0") },
Property { name: "METHOD", params: None, value: Some("PUBLISH") },
Property { name: "X-MS-OLK-FORCEINSPECTOROPEN", params: None, value: Some("TRUE") }],
events: [
IcalEvent { properties: [
Property { name: "CLASS", params: None, value: Some("PUBLIC") },
Property { name: "CREATED", params: None, value: Some("20210511T063845Z") },
Property { name: "DESCRIPTION", params: None, value: Some("Einwahldaten folgen in der Veranstaltungswoche \\nSeminartitel:Software-QS-Cast - Application Performance Monitoring\\nDatum: 27.Mai 2021\\nUhrzeit: 10:30 - ca.12:00 Uhr \\n \\n") },
Property { name: "DTEND", params: Some([("TZID", ["W. Europe Standard Time"])]), value: Some("20210527T120000") },
Property { name: "DTSTAMP", params: None, value: Some("20210511T063845Z") },
Property { name: "DTSTART", params: Some([("TZID", ["W. Europe Standard Time"])]), value: Some("20210527T103000") },
Property { name: "LAST-MODIFIED", params: None, value: Some("20210511T063845Z") },
Property { name: "PRIORITY", params: None, value: Some("5") }, Property { name: "SEQUENCE", params: None, value: Some("0") },
Property { name: "SUMMARY", params: Some([("LANGUAGE", ["de"])]), value: Some("Software-QS-Cast Application Performance Monitoring") },
Property { name: "TRANSP", params: None, value: Some("OPAQUE") },
Property { name: "UID", params: None, value: Some("040000008200E000*************00800000000*****************00000000000000010000000********************************") },
Property { name: "X-MICROSOFT-CDO-BUSYSTATUS", params: None, value: Some("BUSY") },
Property { name: "X-MICROSOFT-CDO-IMPORTANCE", params: None, value: Some("1") },
Property { name: "X-MICROSOFT-DISALLOW-COUNTER", params: None, value: Some("FALSE") },
Property { name: "X-MS-OLK-CONFTYPE", params: None, value: Some("0") }],
alarms: [
IcalAlarm { properties: [
Property { name: "TRIGGER", params: None, value: Some("-PT15M") },
Property { name: "ACTION", params: None, value: Some("DISPLAY") },
Property { name: "DESCRIPTION", params: None, value: Some("Reminder") }] }] }],
alarms: [], todos: [], journals: [], free_busys: [],
timezones: [IcalTimeZone { properties: [Property { name: "TZID", params: None, value: Some("W. Europe Standard Time") }],
transitions: [IcalTimeZoneTransition { transition: STANDARD, properties: [Property { name: "DTSTART", params: None, value: Some("16011028T030000") },
Property { name: "RRULE", params: None, value: Some("FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10") },
Property { name: "TZOFFSETFROM", params: None, value: Some("+0200") },
Property { name: "TZOFFSETTO", params: None, value: Some("+0100") }] },
IcalTimeZoneTransition { transition: DAYLIGHT, properties: [Property { name: "DTSTART", params: None, value: Some("16010325T020000") }, Property { name: "RRULE", params: None, value: Some("FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3") }, Property { name: "TZOFFSETFROM", params: None, value: Some("+0100") }, Property { name: "TZOFFSETTO", params: None, value: Some("+0200") }] }] }] }

0 comments on commit 6c265a5

Please sign in to comment.