summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-01-27 13:59:50 -0500
committerdfhoughton <dfhoughton@gmail.com>2019-01-27 13:59:50 -0500
commit0b37f5a7381430d74569e4fcb76a50ec250d7e0e (patch)
tree391e9f0481af0320196f45010aa1d8c32c8a05a9
parent4857262b4f90491e9016c2861708bd571949ad45 (diff)
downloadtwo-timer-0b37f5a7381430d74569e4fcb76a50ec250d7e0e.zip
test for kalends, nones, ides
-rw-r--r--CHANGES.md4
-rw-r--r--tests/tests.rs67
2 files changed, 70 insertions, 1 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 4e5ee4d..8e12b1b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -11,4 +11,6 @@
## 1.0.3
* fixed "12 pm" bug
## 1.0.4
-* added `<year>` pattern \ No newline at end of file
+* added `<year>` pattern
+* added ordinals for days of the month
+* added kalends, nones, ides \ No newline at end of file
diff --git a/tests/tests.rs b/tests/tests.rs
index bd39a70..5f9494a 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1130,3 +1130,70 @@ fn ordinals() {
}
}
}
+
+#[test]
+fn kalends_nones_ids() {
+ let months = [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December",
+ ];
+ for (i, m) in months.iter().enumerate() {
+ let i = (i + 1) as u32;
+ let big_month = match i {
+ 3 | 5 | 7 | 10 => true,
+ _ => false,
+ };
+ // kalends
+ let d1 = NaiveDate::from_ymd(2018, i, 1).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the kalends of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ // nones
+ let d1 = NaiveDate::from_ymd(2018, i, if big_month { 7 } else { 5 }).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the nones of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ // ides
+ let d1 = NaiveDate::from_ymd(2018, i, if big_month { 15 } else { 13 }).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the ides of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+}