diff options
author | dfhoughton <dfhoughton@gmail.com> | 2018-12-23 16:32:24 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2018-12-23 16:32:24 -0500 |
commit | 1a757d53ca33cfa15e622a1483a999c78bf88544 (patch) | |
tree | f097a0c63fd70dd3156e72091c0e7215f94db52b /tests/tests.rs | |
parent | 76a9737079a2d99b18855335d4cd361192def177 (diff) | |
download | two-timer-1a757d53ca33cfa15e622a1483a999c78bf88544.zip |
removed unnecessary main.rs; added time of day handling
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 81 |
1 files changed, 75 insertions, 6 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index e49ec38..f263dc7 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -65,18 +65,87 @@ fn today() { } #[test] -fn ymd_5_6_69() { - let then = Utc.ymd(1969, 5, 6).and_hms(0, 0, 0); +fn day_5_6_69_at_3_30_pm() { + let then = Utc.ymd(1969, 5, 6).and_hms(15, 30, 0); for phrase in [ - "5-6-69", "5/6/69", "5.6.69", "5/6/1969", "5-6-1969", "5.6.1969", "69-5-6", "69/5/6", - "69.5.6", "1969/5/6", "1969-5-6", "1969.5.6", "5-6-'69", "5/6/'69", "5.6.'69", "'69-5-6", - "'69/5/6", "'69.5.6", + "at 3:30 PM on 5-6-69", + "3:30 p.m. on 5-6-69", + "at 15:30 on 5-6-69", + "15:30 on 5-6-69", ] .iter() { let (start, end) = parse(phrase, None, None).unwrap(); assert_eq!(then, start); - assert_eq!(then + Duration::days(1), end); + assert_eq!(then + Duration::minutes(1), end); + } +} + +#[test] +fn day_5_6_69_at_3_pm() { + let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0); + for phrase in [ + "at 3 PM on 5-6-69", + "3 p.m. on 5-6-69", + "at 15 on 5-6-69", + "15 on 5-6-69", + ] + .iter() + { + let (start, end) = parse(phrase, None, None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::hours(1), end); + } +} + +#[test] +fn day_5_6_69_at_3_30_00_pm() { + let then = Utc.ymd(1969, 5, 6).and_hms(15, 30, 0); + for phrase in [ + "at 3:30:00 PM on 5-6-69", + "3:30:00 p.m. on 5-6-69", + "at 15:30:00 on 5-6-69", + "15:30:00 on 5-6-69", + ] + .iter() + { + let (start, end) = parse(phrase, None, None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::seconds(1), end); + } +} + +#[test] +fn day_5_6_69_at_3_30_01_pm() { + let then = Utc.ymd(1969, 5, 6).and_hms(15, 30, 1); + for phrase in [ + "at 3:30:01 PM on 5-6-69", + "3:30:01 p.m. on 5-6-69", + "at 15:30:01 on 5-6-69", + "15:30:01 on 5-6-69", + ] + .iter() + { + let (start, end) = parse(phrase, None, None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::seconds(1), end); + } +} + +#[test] +fn day_5_6_69_at_3_30_01_am() { + let then = Utc.ymd(1969, 5, 6).and_hms(3, 30, 1); + for phrase in [ + "at 3:30:01 AM on 5-6-69", + "3:30:01 a.m. on 5-6-69", + "at 3:30:01 on 5-6-69", + "3:30:01 on 5-6-69", + ] + .iter() + { + let (start, end) = parse(phrase, None, None).unwrap(); + assert_eq!(then, start); + assert_eq!(then + Duration::seconds(1), end); } } |