summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-01-05 14:10:25 -0500
committerdfhoughton <dfhoughton@gmail.com>2019-01-05 14:10:25 -0500
commit4d885eff8c4c745348126e96cf7cf46d478f30bb (patch)
tree2f0d6ec7b3a41fc693c8f2495102edd0e9d7b131 /tests
parent4fcdb36cf675d9f0c772486b38f43032265a07c9 (diff)
downloadtwo-timer-4d885eff8c4c745348126e96cf7cf46d478f30bb.zip
a few more tests; removed more unused imports
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index f4460b2..31ef9fb 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -3,7 +3,7 @@ extern crate two_timer;
use two_timer::{parse, Config};
extern crate chrono;
use chrono::naive::NaiveDate;
-use chrono::{Duration, Local, TimeZone, Utc};
+use chrono::{Duration, Local};
#[test]
fn always() {
@@ -982,3 +982,45 @@ fn next_weekend_on_sunday_when_sunday_starts_week() {
assert_eq!(d1, start);
assert_eq!(d2, end);
}
+
+#[test]
+fn this_weekend_on_saturday_when_sunday_starts_week() {
+ let now = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0);
+ let d1 = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0);
+ let d2 = NaiveDate::from_ymd(1969, 5, 12).and_hms(0, 0, 0);
+ let (start, end, _) = parse(
+ "this weekend",
+ Some(Config::new().now(now).monday_starts_week(false)),
+ )
+ .unwrap();
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+}
+
+#[test]
+fn last_weekend_on_saturday_when_sunday_starts_week() {
+ let now = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0);
+ let d1 = NaiveDate::from_ymd(1969, 5, 3).and_hms(0, 0, 0);
+ let d2 = NaiveDate::from_ymd(1969, 5, 5).and_hms(0, 0, 0);
+ let (start, end, _) = parse(
+ "last weekend",
+ Some(Config::new().now(now).monday_starts_week(false)),
+ )
+ .unwrap();
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+}
+
+#[test]
+fn next_weekend_on_saturday_when_sunday_starts_week() {
+ let now = NaiveDate::from_ymd(1969, 5, 10).and_hms(0, 0, 0);
+ let d1 = NaiveDate::from_ymd(1969, 5, 17).and_hms(0, 0, 0);
+ let d2 = NaiveDate::from_ymd(1969, 5, 19).and_hms(0, 0, 0);
+ let (start, end, _) = parse(
+ "next weekend",
+ Some(Config::new().now(now).monday_starts_week(false)),
+ )
+ .unwrap();
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+}