aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan2018-08-23 23:06:09 +0200
committerRuben Pollan2018-08-23 23:06:09 +0200
commitb663d054d266ebea589ad38a28d7fbb17c44d7db (patch)
treeece2da4e0d7daef7ee693eae8883a358a950b273
parent26ddc4889560ea1e63e7fec674fbd87bb394acfb (diff)
Add test to Date parser
-rw-r--r--src/event.rs19
1 files changed, 19 insertions, 0 deletions
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<T: TimeZone>(date: &chrono::Date<T>, time: &chrono::DateTime<T>
}
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),
+ }
+ }
+}