summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2018-12-24 16:48:24 -0500
committerdfhoughton <dfhoughton@gmail.com>2018-12-24 16:48:24 -0500
commit633289a9febc61eaf19aa2412fefc1c1dc91946a (patch)
tree070aac3e838dbe4194c854d790e4de52491a0f51 /tests
parent8d03fd35e590f704663817a89ba502def7126ac5 (diff)
downloadtwo-timer-633289a9febc61eaf19aa2412fefc1c1dc91946a.zip
added simple times
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index f263dc7..fd2c82d 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -150,6 +150,50 @@ fn day_5_6_69_at_3_30_01_am() {
}
#[test]
+fn at_3_pm() {
+ let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0);
+ let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0);
+ for phrase in ["3 PM", "3 pm", "15"].iter() {
+ let (start, end) = parse(phrase, Some(&now), None).unwrap();
+ assert_eq!(then, start);
+ assert_eq!(then + Duration::hours(1), end);
+ }
+}
+
+#[test]
+fn at_3_00_pm() {
+ let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0);
+ let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0);
+ for phrase in ["3:00 PM", "3:00 pm", "15:00"].iter() {
+ let (start, end) = parse(phrase, Some(&now), None).unwrap();
+ assert_eq!(then, start);
+ assert_eq!(then + Duration::minutes(1), end);
+ }
+}
+
+#[test]
+fn at_3_00_00_pm() {
+ let now = Utc.ymd(1969, 5, 6).and_hms(16, 0, 0);
+ let then = Utc.ymd(1969, 5, 6).and_hms(15, 0, 0);
+ for phrase in ["3:00:00 PM", "3:00:00 pm", "15:00:00"].iter() {
+ let (start, end) = parse(phrase, Some(&now), None).unwrap();
+ assert_eq!(then, start);
+ assert_eq!(then + Duration::seconds(1), end);
+ }
+}
+
+#[test]
+fn at_3_pm_yesterday() {
+ let now = Utc.ymd(1969, 5, 6).and_hms(14, 0, 0);
+ let then = Utc.ymd(1969, 5, 5).and_hms(15, 0, 0);
+ for phrase in ["3 PM", "3 pm", "15"].iter() {
+ let (start, end) = parse(phrase, Some(&now), None).unwrap();
+ assert_eq!(then, start);
+ assert_eq!(then + Duration::hours(1), end);
+ }
+}
+
+#[test]
fn alphabetic_5_6_69() {
let then = Utc.ymd(1969, 5, 6).and_hms(0, 0, 0);
for phrase in [