From 633289a9febc61eaf19aa2412fefc1c1dc91946a Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Mon, 24 Dec 2018 16:48:24 -0500 Subject: added simple times --- tests/tests.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/tests.rs') diff --git a/tests/tests.rs b/tests/tests.rs index f263dc7..fd2c82d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -149,6 +149,50 @@ fn day_5_6_69_at_3_30_01_am() { } } +#[test] +fn at_3_pm() { + let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0); + let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0); + for phrase in ["3 PM", "3 pm", "15"].iter() { + let (start, end) = parse(phrase, Some(&now), None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::hours(1), end); + } +} + +#[test] +fn at_3_00_pm() { + let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0); + let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0); + for phrase in ["3:00 PM", "3:00 pm", "15:00"].iter() { + let (start, end) = parse(phrase, Some(&now), None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::minutes(1), end); + } +} + +#[test] +fn at_3_00_00_pm() { + let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0); + let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0); + for phrase in ["3:00:00 PM", "3:00:00 pm", "15:00:00"].iter() { + let (start, end) = parse(phrase, Some(&now), None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::seconds(1), end); + } +} + +#[test] +fn at_3_pm_yesterday() { + let now = Utc.ymd(1969, 5, 6).and_hms(14, 0, 0); + let then = Utc.ymd(1969, 5, 5).and_hms(15, 0, 0); + for phrase in ["3 PM", "3 pm", "15"].iter() { + let (start, end) = parse(phrase, Some(&now), None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::hours(1), end); + } +} + #[test] fn alphabetic_5_6_69() { let then = Utc.ymd(1969, 5, 6).and_hms(0, 0, 0); -- cgit v1.2.3