summaryrefslogtreecommitdiff
path: root/tests/rrule.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rrule.rs')
-rw-r--r--tests/rrule.rs548
1 files changed, 548 insertions, 0 deletions
diff --git a/tests/rrule.rs b/tests/rrule.rs
index abab79a..35746ba 100644
--- a/tests/rrule.rs
+++ b/tests/rrule.rs
@@ -2234,4 +2234,552 @@ mod test {
],
);
}
+
+ #[test]
+ fn weekly_by_monthday_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_month_monthday_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_yearday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_month_yearday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_weekno() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_weekno_and_weekday() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_weekno_and_weekday_large() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_weekno_and_weekday_last() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_weekno_and_weekday53() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ 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 weekly_by_hour() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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, 9, 6, 0, 0),
+ ymd_hms(1997, 9, 9, 18, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_minute() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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, 9, 9, 6, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_second() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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, 9, 9, 0, 6),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_hour_and_minute() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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, 9, 6, 6, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_hour_and_second() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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, 9, 6, 0, 6),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_minute_and_second() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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 weekly_by_hour_and_minute_and_second() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(5),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1],
+ 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),
+ ymd_hms(1997, 9, 2, 18, 18, 18),
+ ymd_hms(1997, 9, 9, 6, 6, 6),
+ ],
+ );
+ }
+
+ #[test]
+ fn weekly_by_setpos() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ byweekday: vec![1, 3],
+ byhour: vec![6, 18],
+ bysetpos: vec![3, -3],
+ 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, 4, 6, 0, 0),
+ ymd_hms(1997, 9, 9, 18, 0, 0),
+ ],
+ );
+ }
}