summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-01-27 15:49:30 -0500
committerdfhoughton <dfhoughton@gmail.com>2019-01-27 15:49:30 -0500
commit20aad02a8e255d18a8a5416212028b18708d6218 (patch)
treea1641566c4f8b05fa7ea18855143181ab9e397bf /tests
parent0b37f5a7381430d74569e4fcb76a50ec250d7e0e (diff)
downloadtwo-timer-20aad02a8e255d18a8a5416212028b18708d6218.zip
added the month-day pattern
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs25
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");
+ }
+ }
+ }
+}