Debian Codegraph @

src/tests/regression.rs

raw symbols SCIP
1 use chrono::Month;
2
3 use crate::tests::common;
4 use crate::{Frequency, RRule, RRuleSet, Unvalidated};
5
6 #[test]
7 fn issue_34() {
8 let dates = "DTSTART;TZID=America/New_York:19970929T090000
9 RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2"
10 .parse::<RRuleSet>()
11 .unwrap()
12 .all(7)
13 .dates;
14 common::check_occurrences(
15 &dates,
16 &[
17 "1997-09-29T09:00:00-04:00",
18 "1997-10-30T09:00:00-05:00",
19 "1997-11-27T09:00:00-05:00",
20 "1997-12-30T09:00:00-05:00",
21 "1998-01-29T09:00:00-05:00",
22 "1998-02-26T09:00:00-05:00",
23 "1998-03-30T09:00:00-05:00",
24 ],
25 );
26 }
27
28 #[test]
29 fn issue_49() {
30 let rrule_set = "DTSTART:20211214T091500\nEXDATE:20211228T091500,20220104T091500\nRRULE:FREQ=WEEKLY;UNTIL=20220906T091500;INTERVAL=1;BYDAY=TU;WKST=MO"
31 .parse::<RRuleSet>()
32 .expect("The RRule is not valid");
33
34 let res = rrule_set.all(1).dates;
35 assert!(!res.is_empty());
36 let res_str = format!("{}", res[0]);
37 // Check that result datetime is not in UTC
38 assert!(!res_str.contains("UTC"));
39 }
40
41 #[test]
42 fn issue_61() {
43 let rrule_set = "DTSTART;TZID=Europe/Berlin:18930401T010000\nRRULE:FREQ=DAILY"
44 .parse::<RRuleSet>()
45 .expect("The RRule is not valid");
46
47 let res = rrule_set.all(10).dates;
48 assert_eq!(res.len(), 10);
49 }
50
51 // Frequency should be capitalized
52 #[test]
53 fn issue_97() {
54 let rrule = RRule::new(Frequency::Yearly)
55 .by_month_day((24..=26).collect())
56 .by_month(&[Month::December]);
57
58 assert_eq!(
59 rrule.to_string(),
60 "FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=24,25,26"
61 );
62 }
63
64 #[test]
65 fn issue_111() {
66 let rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;WKST=SU".parse::<RRule<Unvalidated>>();
67
68 // Convert to string...
69 let rrule_str = format!("{}", rrule.unwrap());
70 assert!(rrule_str.contains("WKST=SU"));
71 }