From 0b37f5a7381430d74569e4fcb76a50ec250d7e0e Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sun, 27 Jan 2019 13:59:50 -0500 Subject: test for kalends, nones, ides --- CHANGES.md | 4 +++- tests/tests.rs | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) 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 `` pattern \ No newline at end of file +* added `` 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"); + } + } + } +} -- cgit v1.2.3