summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-02-02 16:44:17 -0500
committerdfhoughton <dfhoughton@gmail.com>2019-02-02 16:44:17 -0500
commit42bd15810e323a96fdd684da26bd890de68d5b9c (patch)
tree14d020643e0b8ca4b386dcd6fdcf133ea3e67976
parenta2a54246b1b1e992dddfb28d3eae4554a457521d (diff)
downloadtwo-timer-42bd15810e323a96fdd684da26bd890de68d5b9c.zip
added English number test for before/after/around pattern
-rw-r--r--CHANGES.md3
-rw-r--r--tests/tests.rs27
2 files changed, 27 insertions, 3 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 53f10a0..18e4442 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -14,4 +14,5 @@
* added `<year>` pattern
* added ordinals for days of the month
* added kalends, nones, ides
-* added March 5th, the fifth, etc. \ No newline at end of file
+* added March 5th, the fifth, etc.
+* added period before/after/around time \ No newline at end of file
diff --git a/tests/tests.rs b/tests/tests.rs
index a398fba..4cfe14b 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1261,7 +1261,8 @@ fn one_week_after_may_6_1969() {
#[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 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() {
@@ -1276,4 +1277,26 @@ fn one_week_around_may_6_1969() {
}
}
}
-} \ No newline at end of file
+}
+
+#[test]
+fn number_before_test() {
+ let d = NaiveDate::from_ymd(1969, 5, 6).and_hms(13, 0, 0);
+ let nums = [
+ "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
+ ];
+ for (i, p) in nums.iter().enumerate() {
+ let d = d - Duration::seconds((i + 2) as i64);
+ let p = format!("{} seconds before May 6, 1969 at 1:00 PM", p);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d, start);
+ assert_eq!(d, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+}