summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFredrik Meringdal <fmeringdal@hotmail.com>2020-10-17 14:22:10 +0200
committerFredrik Meringdal <fmeringdal@hotmail.com>2020-10-17 14:22:10 +0200
commit0c164891c5fcf26b6b5ca6a36ad0263aae8eadb2 (patch)
tree9456d41141625989cf453da7e84a233d7d80cecb /tests
parent5e6bd01bb9c847838ea9f3d5f648a3bc629efb3f (diff)
downloadrust_rrule-0c164891c5fcf26b6b5ca6a36ad0263aae8eadb2.zip
wkst tests and some other tests
Diffstat (limited to 'tests')
-rw-r--r--tests/rrule.rs210
1 files changed, 210 insertions, 0 deletions
diff --git a/tests/rrule.rs b/tests/rrule.rs
index 29c1317..fd1fb7c 100644
--- a/tests/rrule.rs
+++ b/tests/rrule.rs
@@ -4398,4 +4398,214 @@ mod test {
],
);
}
+
+ #[test]
+ fn until_not_matching() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::DAILY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: Some(ymd_hms(1997, 9, 5, 8, 0, 0)),
+ wkst: 0,
+ byweekday: vec![],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ 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 until_matching() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::DAILY,
+ count: Some(4),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: Some(ymd_hms(1997, 9, 4, 9, 0, 0)),
+ wkst: 0,
+ byweekday: vec![],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ 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 until_single() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::DAILY,
+ count: Some(1),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: Some(ymd_hms(1997, 9, 2, 9, 0, 0)),
+ wkst: 0,
+ byweekday: vec![],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ tzid: None,
+ interval: 1,
+ };
+ test_recurring(&mut options, &vec![ymd_hms(1997, 9, 2, 9, 0, 0)]);
+ }
+
+ #[test]
+ fn until_empty() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::DAILY,
+ count: Some(1),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: Some(ymd_hms(1997, 9, 1, 9, 0, 0)),
+ wkst: 0,
+ byweekday: vec![],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ tzid: None,
+ interval: 1,
+ };
+ test_recurring(&mut options, &vec![]);
+ }
+
+ #[test]
+ fn until_with_date() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::DAILY,
+ count: Some(4),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: Some(ymd_hms(1997, 9, 5, 0, 0, 0)),
+ wkst: 0,
+ byweekday: vec![],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ 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 wkst_interval_mo() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: None,
+ wkst: 0,
+ byweekday: vec![1, 6],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ tzid: None,
+ interval: 2,
+ };
+ test_recurring(
+ &mut options,
+ &vec![
+ ymd_hms(1997, 9, 2, 9, 0, 0),
+ ymd_hms(1997, 9, 7, 9, 0, 0),
+ ymd_hms(1997, 9, 16, 9, 0, 0),
+ ],
+ );
+ }
+
+ #[test]
+ fn wkst_interval_su() {
+ let mut options = ParsedOptions {
+ freq: Frequenzy::WEEKLY,
+ count: Some(3),
+ bymonth: vec![],
+ dtstart: ymd_hms(1997, 9, 2, 9, 0, 0),
+ until: None,
+ wkst: 6,
+ byweekday: vec![1, 6],
+ byhour: vec![9],
+ bysetpos: vec![],
+ byweekno: vec![],
+ byminute: vec![0],
+ bysecond: vec![0],
+ byyearday: vec![],
+ bymonthday: vec![],
+ bynweekday: vec![],
+ bynmonthday: vec![],
+ tzid: None,
+ interval: 2,
+ };
+ test_recurring(
+ &mut options,
+ &vec![
+ ymd_hms(1997, 9, 2, 9, 0, 0),
+ ymd_hms(1997, 9, 14, 9, 0, 0),
+ ymd_hms(1997, 9, 16, 9, 0, 0),
+ ],
+ );
+ }
}