diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-02-02 14:28:22 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-02-02 14:28:22 -0500 |
commit | a2a54246b1b1e992dddfb28d3eae4554a457521d (patch) | |
tree | 8704bcd9d848cd3c7e12ae89489ee2fb1da98291 /tests | |
parent | 20aad02a8e255d18a8a5416212028b18708d6218 (diff) | |
download | two-timer-a2a54246b1b1e992dddfb28d3eae4554a457521d.zip |
added time around pattern
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 3db7520..a398fba 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1222,3 +1222,58 @@ fn day_and_month() { } } } + +#[test] +fn one_week_before_may_6_1969() { + let d1 = NaiveDate::from_ymd(1969, 5, 6).and_hms(0, 0, 0) - Duration::days(7); + let patterns = ["one week before May 6, 1969", "1 week before May 6, 1969"]; + for p in patterns.iter() { + match parse(p, None) { + Ok((start, end, _)) => { + assert_eq!(d1, start); + assert_eq!(d1, end); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } + } +} + +#[test] +fn one_week_after_may_6_1969() { + let d1 = NaiveDate::from_ymd(1969, 5, 7).and_hms(0, 0, 0) + Duration::days(7); + let patterns = ["one week after May 6, 1969", "1 week after May 6, 1969"]; + for p in patterns.iter() { + match parse(p, None) { + Ok((start, end, _)) => { + assert_eq!(d1, start); + assert_eq!(d1, end); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } + } +} + +#[test] +fn one_week_around_may_6_1969() { + let d1 = NaiveDate::from_ymd(1969, 5, 6).and_hms(0, 0, 0) - Duration::milliseconds( 7 * 24 * 60 * 60 * 1000 / 2); + let d2 = d1 + Duration::days(7); + let patterns = ["one week around May 6, 1969", "1 week around May 6, 1969"]; + for p in patterns.iter() { + match parse(p, None) { + Ok((start, end, _)) => { + assert_eq!(d1, start); + assert_eq!(d2, end); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } + } +}
\ No newline at end of file |