diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-02-03 14:46:05 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-02-03 14:46:05 -0500 |
commit | 46b9401a350645472ded762adce28db7545895c0 (patch) | |
tree | 81d41e6af681261d11599ea040bb9b92abf13cc7 /tests/tests.rs | |
parent | 0da507aa04c73c9a1f96107f4082232cd72ade83 (diff) | |
download | two-timer-46b9401a350645472ded762adce28db7545895c0.zip |
fixed 'Friday the 13th' and 'the 31st'
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 9278522..b4c5b5d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1264,7 +1264,10 @@ fn one_week_before_and_after_may_6_1969() { let d = NaiveDate::from_ymd(1969, 5, 6).and_hms(0, 0, 0); let d1 = d - Duration::days(7); let d2 = d + Duration::days(7); - let patterns = ["one week before and after May 6, 1969", "1 week before and after May 6, 1969"]; + let patterns = [ + "one week before and after May 6, 1969", + "1 week before and after May 6, 1969", + ]; for p in patterns.iter() { match parse(p, None) { Ok((start, end, _)) => { @@ -1415,3 +1418,33 @@ fn displacement() { } } } + +#[test] +fn friday_the_13th() { + let now = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0); + let d1 = NaiveDate::from_ymd(1968, 12, 13).and_hms(0, 0, 0); + match parse("Friday the 13th", Some(Config::new().now(now))) { + Ok((start, _, _)) => { + assert_eq!(d1, start); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } +} + +#[test] +fn the_31st() { + let now = NaiveDate::from_ymd(1969, 4, 10).and_hms(0, 0, 0); + let d1 = NaiveDate::from_ymd(1969, 3, 31).and_hms(0, 0, 0); + match parse("the 31st", Some(Config::new().now(now))) { + Ok((start, _, _)) => { + assert_eq!(d1, start); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } +} |