summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 3db7520..a398fba 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1222,3 +1222,58 @@ fn day_and_month() {
}
}
}
+
+#[test]
+fn one_week_before_may_6_1969() {
+ let d1 = NaiveDate::from_ymd(1969, 5, 6).and_hms(0, 0, 0) - Duration::days(7);
+ let patterns = ["one week before May 6, 1969", "1 week before May 6, 1969"];
+ for p in patterns.iter() {
+ match parse(p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d1, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+}
+
+#[test]
+fn one_week_after_may_6_1969() {
+ let d1 = NaiveDate::from_ymd(1969, 5, 7).and_hms(0, 0, 0) + Duration::days(7);
+ let patterns = ["one week after May 6, 1969", "1 week after May 6, 1969"];
+ for p in patterns.iter() {
+ match parse(p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d1, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+}
+
+#[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 d2 = d1 + Duration::days(7);
+ let patterns = ["one week around May 6, 1969", "1 week around May 6, 1969"];
+ for p in patterns.iter() {
+ match parse(p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+} \ No newline at end of file