summaryrefslogtreecommitdiff
path: root/tests/rrule.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rrule.rs')
-rw-r--r--tests/rrule.rs585
1 files changed, 584 insertions, 1 deletions
diff --git a/tests/rrule.rs b/tests/rrule.rs
index 85c819b..8ecbe56 100644
--- a/tests/rrule.rs
+++ b/tests/rrule.rs
@@ -5,7 +5,6 @@ use chrono::prelude::*;
use rrule::iter::*;
use rrule::options::*;
-
#[cfg(test)]
mod test {
use super::*;
@@ -3589,4 +3588,588 @@ mod test {
],
);
}
+
+ #[test]
+ fn hourly() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 2, 10, 0, 0),
+ ymd_hms(1997, 9, 2, 11, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_interval() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 2, 11, 0, 0),
+ ymd_hms(1997, 9, 2, 13, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_interval_large() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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: 769,
+ };
+ test_recurring(
+ &mut options,
+ &vec![
+ ymd_hms(1997, 9, 2, 9, 0, 0),
+ ymd_hms(1997, 10, 4, 10, 0, 0),
+ ymd_hms(1997, 11, 5, 11, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_month() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 1, 1, 1, 0, 0),
+ ymd_hms(1998, 1, 1, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_monthday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1997, 9, 3, 1, 0, 0),
+ ymd_hms(1997, 9, 3, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_month_and_monthday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 1, 5, 1, 0, 0),
+ ymd_hms(1998, 1, 5, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ count: Some(5),
+ 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: 5,
+ };
+ test_recurring(
+ &mut options,
+ &vec![
+ ymd_hms(1997, 9, 2, 9, 0, 0),
+ ymd_hms(1997, 9, 2, 14, 0, 0),
+ ymd_hms(1997, 9, 2, 19, 0, 0),
+ ymd_hms(1997, 9, 4, 1, 0, 0),
+ ymd_hms(1997, 9, 4, 6, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_month_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 1, 1, 1, 0, 0),
+ ymd_hms(1998, 1, 1, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_monthday_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 1, 1, 1, 0, 0),
+ ymd_hms(1998, 1, 1, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_month_and_monthday_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 1, 1, 1, 0, 0),
+ ymd_hms(1998, 1, 1, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_yearday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ count: Some(8),
+ 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: 12,
+ };
+ test_recurring(
+ &mut options,
+ &vec![
+ ymd_hms(1997, 12, 31, 9, 0, 0),
+ ymd_hms(1997, 12, 31, 21, 0, 0),
+ ymd_hms(1998, 1, 1, 9, 0, 0),
+ ymd_hms(1998, 1, 1, 21, 0, 0),
+ ymd_hms(1998, 4, 10, 9, 0, 0),
+ ymd_hms(1998, 4, 10, 21, 0, 0),
+ ymd_hms(1998, 7, 19, 9, 0, 0),
+ ymd_hms(1998, 7, 19, 21, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_month_and_yearday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ count: Some(4),
+ bymonth: vec![4, 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, 4, 10, 0, 0, 0),
+ ymd_hms(1998, 4, 10, 1, 0, 0),
+ ymd_hms(1998, 4, 10, 2, 0, 0),
+ ymd_hms(1998, 4, 10, 3, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekno() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 5, 11, 1, 0, 0),
+ ymd_hms(1998, 5, 11, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekno_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1997, 12, 29, 1, 0, 0),
+ ymd_hms(1997, 12, 29, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekno_and_weekday_large() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1997, 12, 28, 1, 0, 0),
+ ymd_hms(1997, 12, 28, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekno_and_weekday_last() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1997, 12, 28, 1, 0, 0),
+ ymd_hms(1997, 12, 28, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_weekno_and_weekday53() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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, 0, 0, 0),
+ ymd_hms(1998, 12, 28, 1, 0, 0),
+ ymd_hms(1998, 12, 28, 2, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn hourly_by_hour() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::HOURLY,
+ 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),
+ ],
+ );
+ }
}