summaryrefslogtreecommitdiff
path: root/tests/tests.rs
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 /tests/tests.rs
parent4857262b4f90491e9016c2861708bd571949ad45 (diff)
downloadtwo-timer-0b37f5a7381430d74569e4fcb76a50ec250d7e0e.zip
test for kalends, nones, ides
Diffstat (limited to 'tests/tests.rs')
-rw-r--r--tests/tests.rs67
1 files changed, 67 insertions, 0 deletions
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");
+ }
+ }
+ }
+}