diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-01-27 15:49:30 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-01-27 15:49:30 -0500 |
commit | 20aad02a8e255d18a8a5416212028b18708d6218 (patch) | |
tree | a1641566c4f8b05fa7ea18855143181ab9e397bf /tests/tests.rs | |
parent | 0b37f5a7381430d74569e4fcb76a50ec250d7e0e (diff) | |
download | two-timer-20aad02a8e255d18a8a5416212028b18708d6218.zip |
added the month-day pattern
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 5f9494a..3db7520 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -5,6 +5,11 @@ extern crate chrono; use chrono::naive::NaiveDate; use chrono::{Duration, Local}; +// a debugging method to print out the parse tree +fn show_me(p: &str) { + println!("{}", two_timer::MATCHER.parse(p).unwrap()); +} + #[test] fn always() { let alpha = chrono::naive::MIN_DATE.and_hms_milli(0, 0, 0, 0); @@ -1197,3 +1202,23 @@ fn kalends_nones_ids() { } } } + +#[test] +fn day_and_month() { + let now = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0); + let d1 = NaiveDate::from_ymd(1969, 5, 15).and_hms(0, 0, 0); + let d2 = d1 + Duration::days(1); + let patterns = ["the ides of May", "5-15", "the fifteenth", "May fifteenth"]; + for p in patterns.iter() { + match parse(p, Some(Config::new().now(now))) { + Ok((start, end, _)) => { + assert_eq!(d1, start); + assert_eq!(d2, end); + } + Err(e) => { + println!("{:?}", e); + assert!(false, "didn't match"); + } + } + } +} |