summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarkus Unterwaditzer <markus@unterwaditzer.net>2014-11-09 23:22:14 +0100
committerMarkus Unterwaditzer <markus@unterwaditzer.net>2014-11-09 23:22:14 +0100
commit9a85b7de3568074a0d06d6e8541e4c5ef053e040 (patch)
tree04227969e985e7668edc23edc617db6b44b1c611 /tests
parent1759a2b041b49c9ccf20a5963c3d3d638b46d98d (diff)
Add support for subcomponents
See #4 It is unclear whether properties after subcomponents are allowed. I've never seen a file like that.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/lib.rs b/tests/lib.rs
index 2a73c46..80070d1 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -8,7 +8,7 @@ macro_rules! s(
#[test]
-fn test_wikipedia_1() {
+fn test_vcard_basic() {
let item = parse_component(s!(
"BEGIN:VCARD\n\
VERSION:2.1\n\
@@ -45,6 +45,37 @@ fn test_line_cont() {
4444\n\
END:VCARD")).unwrap();
+ assert_eq!(&item.name, s!("VCARD"));
assert_eq!(item.single_prop(s!("TEL")).unwrap().get_raw_value(), s!("55554444"));
assert_eq!(item.single_prop(s!("N")).unwrap().get_raw_value(), s!("Nikdo;Nikdo=vic"));
}
+
+#[test]
+fn test_icalendar_basic() {
+ let item = parse_component(s!(
+ "BEGIN:VCALENDAR\n\
+ VERSION:2.0\n\
+ PRODID:http://www.example.com/calendarapplication/\n\
+ METHOD:PUBLISH\n\
+ BEGIN:VEVENT\n\
+ UID:461092315540@example.com\n\
+ ORGANIZER;CN=\"Alice Balder, Example Inc.\":MAILTO:alice@example.com\n\
+ LOCATION:Somewhere\n\
+ SUMMARY:Eine Kurzinfo\n\
+ DESCRIPTION:Beschreibung des Termines\n\
+ CLASS:PUBLIC\n\
+ DTSTART:20060910T220000Z\n\
+ DTEND:20060919T215900Z\n\
+ DTSTAMP:20060812T125900Z\n\
+ END:VEVENT\n\
+ END:VCALENDAR\n")).unwrap();
+
+ assert_eq!(&item.name, s!("VCALENDAR"));
+ assert!(item.single_prop(s!("LOCATION")).is_none());
+ assert!(item.single_prop(s!("ORGANIZER")).is_none());
+
+ let event = &item.subcomponents[0];
+ assert_eq!(&event.name, s!("VEVENT"));
+ assert!(event.single_prop(s!("ORGANIZER")).is_some());
+ assert_eq!(event.single_prop(s!("LOCATION")).unwrap().get_raw_value(), s!("Somewhere"));
+}