summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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");
+ }
+ }
+ }
+}