From 20aad02a8e255d18a8a5416212028b18708d6218 Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sun, 27 Jan 2019 15:49:30 -0500 Subject: added the month-day pattern --- tests/tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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"); + } + } + } +} -- cgit v1.2.3