| 1 | use chronorust-analyzer cargo chrono 0.4.40 crate/::Monthrust-analyzer cargo chrono 0.4.40 month/Month#; |
| 2 | |
| 3 | use craterust-analyzer cargo rrule 0.14.0 crate/::testsrust-analyzer cargo rrule 0.14.0 tests/::commonrust-analyzer cargo rrule 0.14.0 tests/common/; |
| 4 | use craterust-analyzer cargo rrule 0.14.0 crate/::{Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#, RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#, RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#, Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#}; |
| 5 | |
| 6 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 7 | fn issue_34rust-analyzer cargo rrule 0.14.0 tests/regression/issue_34().() { |
| 8 | let dates = "DTSTART;TZID=America/New_York:19970929T090000 |
| 9 | RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2" |
| 10 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#>() |
| 11 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 12 | .allrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet]all().(7) |
| 13 | .datesrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#dates.; |
| 14 | commonrust-analyzer cargo rrule 0.14.0 tests/common/::check_occurrencesrust-analyzer cargo rrule 0.14.0 tests/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 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 29 | fn issue_49rust-analyzer cargo rrule 0.14.0 tests/regression/issue_49().() { |
| 30 | let rrule_set = "DTSTART:20211214T091500\nEXDATE:20211228T091500,20220104T091500\nRRULE:FREQ=WEEKLY;UNTIL=20220906T091500;INTERVAL=1;BYDAY=TU;WKST=MO" |
| 31 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#>() |
| 32 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("The RRule is not valid"); |
| 33 | |
| 34 | let res = rrule_set.allrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet]all().(1).datesrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#dates.; |
| 35 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().res.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 36 | let res_str = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", res[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 37 | // Check that result datetime is not in UTC |
| 38 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().res_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("UTC")); |
| 39 | } |
| 40 | |
| 41 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 42 | fn issue_61rust-analyzer cargo rrule 0.14.0 tests/regression/issue_61().() { |
| 43 | let rrule_set = "DTSTART;TZID=Europe/Berlin:18930401T010000\nRRULE:FREQ=DAILY" |
| 44 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#>() |
| 45 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("The RRule is not valid"); |
| 46 | |
| 47 | let res = rrule_set.allrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet]all().(10).datesrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleResult#dates.; |
| 48 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 10); |
| 49 | } |
| 50 | |
| 51 | // Frequency should be capitalized |
| 52 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 53 | fn issue_97rust-analyzer cargo rrule 0.14.0 tests/regression/issue_97().() { |
| 54 | let rrule = RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#::newrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]new().(Frequencyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#::Yearlyrust-analyzer cargo rrule 0.14.0 core/rrule/Frequency#Yearly#) |
| 55 | .by_month_dayrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]by_month_day().((24..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#26).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 56 | .by_monthrust-analyzer cargo rrule 0.14.0 core/rrule/impl#[`RRule<Unvalidated>`]by_month().(&[Monthrust-analyzer cargo chrono 0.4.40 month/Month#::Decemberrust-analyzer cargo chrono 0.4.40 month/Month#December#]); |
| 57 | |
| 58 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 59 | rrule.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 60 | "FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=24,25,26" |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 65 | fn issue_111rust-analyzer cargo rrule 0.14.0 tests/regression/issue_111().() { |
| 66 | let rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;WKST=SU".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<RRulerust-analyzer cargo rrule 0.14.0 core/rrule/RRule#<Unvalidatedrust-analyzer cargo rrule 0.14.0 core/Unvalidated#>>(); |
| 67 | |
| 68 | // Convert to string... |
| 69 | let rrule_str = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", rrule.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 70 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(rrule_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("WKST=SU")); |
| 71 | } |