diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-02-02 16:44:17 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-02-02 16:44:17 -0500 |
commit | 42bd15810e323a96fdd684da26bd890de68d5b9c (patch) | |
tree | 14d020643e0b8ca4b386dcd6fdcf133ea3e67976 /tests/tests.rs | |
parent | a2a54246b1b1e992dddfb28d3eae4554a457521d (diff) | |
download | two-timer-42bd15810e323a96fdd684da26bd890de68d5b9c.zip |
added English number test for before/after/around pattern
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index a398fba..4cfe14b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1261,7 +1261,8 @@ fn one_week_after_may_6_1969() { #[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 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() { @@ -1276,4 +1277,26 @@ fn one_week_around_may_6_1969() { } } } -}
\ No newline at end of file +} + +#[test] +fn number_before_test() { + let d = NaiveDate::from_ymd(1969, 5, 6).and_hms(13, 0, 0); + let nums = [ + "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", + ]; + for (i, p) in nums.iter().enumerate() { + let d = d - Duration::seconds((i + 2) as i64); + let p = format!("{} seconds before May 6, 1969 at 1:00 PM", p); + match parse(&p, None) { + Ok((start, end, _)) => { + assert_eq!(d, start); + assert_eq!(d, end); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } + } +} |