diff options
author | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-10-16 21:33:13 +0200 |
---|---|---|
committer | Fredrik Meringdal <fmeringdal@hotmail.com> | 2020-10-16 21:33:13 +0200 |
commit | 72c172c322e65b112bb6aa4419177ed70fcf4d6f (patch) | |
tree | 6c97b65ae8c014dc7307b59bd785e154dd41899e | |
parent | 0110f26e330c223e83b021f7c7ace0b59d2afcec (diff) | |
download | rust_rrule-72c172c322e65b112bb6aa4419177ed70fcf4d6f.zip |
most daily tests migrated and passes
-rw-r--r-- | tests/rrule.rs | 806 |
1 files changed, 806 insertions, 0 deletions
diff --git a/tests/rrule.rs b/tests/rrule.rs index 35746ba..ce382ea 100644 --- a/tests/rrule.rs +++ b/tests/rrule.rs @@ -2782,4 +2782,810 @@ mod test { ], ); } + + #[test] + fn daily() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 0, 0), + ymd_hms(1997, 9, 3, 9, 0, 0), + ymd_hms(1997, 9, 4, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_interval() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 2, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 0, 0), + ymd_hms(1997, 9, 4, 9, 0, 0), + ymd_hms(1997, 9, 6, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_interval_large() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 92, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 0, 0), + ymd_hms(1997, 12, 3, 9, 0, 0), + ymd_hms(1998, 3, 5, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_month() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![1, 3], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 1, 2, 9, 0, 0), + ymd_hms(1998, 1, 3, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_monthday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![1, 3], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 3, 9, 0, 0), + ymd_hms(1997, 10, 1, 9, 0, 0), + ymd_hms(1997, 10, 3, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_month_and_monthday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![1, 3], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![5, 7], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 5, 9, 0, 0), + ymd_hms(1998, 1, 7, 9, 0, 0), + ymd_hms(1998, 3, 5, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![1, 3], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 0, 0), + ymd_hms(1997, 9, 4, 9, 0, 0), + ymd_hms(1997, 9, 9, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_month_and_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![1, 3], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![1, 3], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 1, 6, 9, 0, 0), + ymd_hms(1998, 1, 8, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_monthday_and_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![1, 3], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![1, 3], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 2, 3, 9, 0, 0), + ymd_hms(1998, 3, 3, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_month_and_monthday_and_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![1, 3], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![1, 3], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![1, 3], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 3, 3, 9, 0, 0), + ymd_hms(2001, 3, 1, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_yearday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(4), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![1, 100, 200, 365], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 31, 9, 0, 0), + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 4, 10, 9, 0, 0), + ymd_hms(1998, 7, 19, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_month_and_yearday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(4), + bymonth: vec![1, 7], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![1, 100, 200, 365], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 1, 1, 9, 0, 0), + ymd_hms(1998, 7, 19, 9, 0, 0), + ymd_hms(1999, 1, 1, 9, 0, 0), + ymd_hms(1999, 7, 19, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_weekno() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![20], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 5, 11, 9, 0, 0), + ymd_hms(1998, 5, 12, 9, 0, 0), + ymd_hms(1998, 5, 13, 9, 0, 0), + ], + ); + } + + // That's a nice one. The first days of week number one + // may be in the last year. + #[test] + fn daily_by_weekno_and_weekday() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![0], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![1], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 29, 9, 0, 0), + ymd_hms(1999, 1, 4, 9, 0, 0), + ymd_hms(2000, 1, 3, 9, 0, 0), + ], + ); + } + + // Another nice test. The last days of week number 52/53 + // may be in the next year. + #[test] + fn daily_by_weekno_and_weekday_large() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![6], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![52], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 28, 9, 0, 0), + ymd_hms(1998, 12, 27, 9, 0, 0), + ymd_hms(2000, 1, 2, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_weekno_and_weekday_last() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![6], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![-1], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 12, 28, 9, 0, 0), + ymd_hms(1999, 1, 3, 9, 0, 0), + ymd_hms(2000, 1, 2, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_weekno_and_weekday53() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![0], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![53], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1998, 12, 28, 9, 0, 0), + ymd_hms(2004, 12, 27, 9, 0, 0), + ymd_hms(2009, 12, 28, 9, 0, 0), + ], + ); + } + + #[test] + fn daily_by_hour() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![6, 18], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 18, 0, 0), + ymd_hms(1997, 9, 3, 6, 0, 0), + ymd_hms(1997, 9, 3, 18, 0, 0), + ], + ); + } + + #[test] + fn daily_by_minute() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![6, 18], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 6, 0), + ymd_hms(1997, 9, 2, 9, 18, 0), + ymd_hms(1997, 9, 3, 9, 6, 0), + ], + ); + } + + #[test] + fn daily_by_second() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![6, 18], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 0, 6), + ymd_hms(1997, 9, 2, 9, 0, 18), + ymd_hms(1997, 9, 3, 9, 0, 6), + ], + ); + } + + #[test] + fn daily_by_hour_and_minute() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![6, 18], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![6, 18], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 18, 6, 0), + ymd_hms(1997, 9, 2, 18, 18, 0), + ymd_hms(1997, 9, 3, 6, 6, 0), + ], + ); + } + + #[test] + fn daily_by_hour_and_second() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![6, 18], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![0], + bysecond: vec![6, 18], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 18, 0, 6), + ymd_hms(1997, 9, 2, 18, 0, 18), + ymd_hms(1997, 9, 3, 6, 0, 6), + ], + ); + } + + #[test] + fn daily_by_minute_and_second() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![9], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![6, 18], + bysecond: vec![6, 18], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 9, 6, 6), + ymd_hms(1997, 9, 2, 9, 6, 18), + ymd_hms(1997, 9, 2, 9, 18, 6), + ], + ); + } + + #[test] + fn daily_by_hour_and_minute_and_second() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![6, 18], + bysetpos: vec![], + byweekno: vec![], + byminute: vec![6, 18], + bysecond: vec![6, 18], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 18, 6, 6), + ymd_hms(1997, 9, 2, 18, 6, 18), + ymd_hms(1997, 9, 2, 18, 18, 6), + ], + ); + } + + #[test] + fn daily_by_setpos() { + let mut options = ParsedOptions { + freq: Frequenzy::DAILY, + count: Some(3), + bymonth: vec![], + dtstart: ymd_hms(1997, 9, 2, 9, 0, 0), + byweekday: vec![], + byhour: vec![6, 18], + bysetpos: vec![3, -3], + byweekno: vec![], + byminute: vec![15, 45], + bysecond: vec![0], + byyearday: vec![], + bymonthday: vec![], + bynweekday: vec![], + bynmonthday: vec![], + until: None, + wkst: 0, + tzid: None, + interval: 1, + }; + test_recurring( + &mut options, + &vec![ + ymd_hms(1997, 9, 2, 18, 15, 0), + ymd_hms(1997, 9, 3, 6, 45, 0), + ymd_hms(1997, 9, 3, 18, 15, 0), + ], + ); + } } |