From b663d054d266ebea589ad38a28d7fbb17c44d7db Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 23 Aug 2018 23:06:09 +0200 Subject: Add test to Date parser --- src/event.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/event.rs') diff --git a/src/event.rs b/src/event.rs index 92b91ed..b43f28d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -121,3 +121,22 @@ fn cmp_date_time(date: &chrono::Date, time: &chrono::DateTime } date.cmp(&d2) } + +#[cfg(test)] +mod tests { + use super::Date; + use chrono::Datelike; + use chrono::Timelike; + + #[test] + fn date_parse_time() { + match Date::parse(&String::from("19361020T120000"), &String::new()).unwrap() { + Date::Time(time) => { + assert_eq!(time.year(), 1936); + assert_eq!(time.hour(), 12); + assert_eq!(time.day(), 20); + } + _ => assert!(true), + } + } +} -- cgit v1.2.3