Debian Codegraph @

src/tests/serde.rs

raw symbols SCIP
1 use craterust-analyzer cargo rrule 0.14.0 crate/::RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
3
4 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5 fn rrule_set_to_and_from_strrust-analyzer cargo rrule 0.14.0 tests/serde/rrule_set_to_and_from_str().() {
6 let test_cases = [
7 "DTSTART:20120201T093000Z\nRRULE:FREQ=YEARLY;COUNT=3",
8 "DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;BYDAY=-2MO,FR",
9 "DTSTART;TZID=America/New_York:19000201T093000Z\nRRULE:UNTIL=19990404T110000Z;FREQ=WEEKLY;BYDAY=TU,WE",
10 ];
11
12 for test_str in test_cases {
13 let test_obj = RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#::from_strrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet][FromStr]from_str().(test_str).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
14 let test_str = test_obj.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
15 let test_obj2 = RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#::from_strrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet][FromStr]from_str().(&test_str).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
16
17 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(test_obj, test_obj2);
18 }
19 }
20
21 #[cfg(feature = "serde")]
22 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
23 fn serialize_deserialize_json_to_and_from_rrule_setrust-analyzer cargo rrule 0.14.0 tests/serde/serialize_deserialize_json_to_and_from_rrule_set().() {
24 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(orig_serderust-analyzer cargo serde 1.0.219 crate/::Deserializerust-analyzer cargo serde_derive 1.0.219 Deserialize:, orig_serderust-analyzer cargo serde 1.0.219 crate/::Serializerust-analyzer cargo serde_derive 1.0.219 Serialize:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
25 #[serde(crate = "orig_serde")]
26 struct RruleTestrust-analyzer cargo rrule 0.14.0 tests/serde/RruleTest# {
27 rrulerust-analyzer cargo rrule 0.14.0 tests/serde/RruleTest#rrule.: RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#,
28 }
29
30 let test_cases = [
31 "DTSTART:20120201T093000Z\nRRULE:FREQ=DAILY;COUNT=5",
32 "DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;BYDAY=-2MO,FR",
33 "DTSTART;TZID=America/New_York:19000201T093000Z\nRRULE:UNTIL=19990404T110000Z;FREQ=WEEKLY;BYDAY=TU,WE",
34 ];
35
36 for test_str in test_cases {
37 let rrule = RRuleSetrust-analyzer cargo rrule 0.14.0 core/rruleset/RRuleSet#::from_strrust-analyzer cargo rrule 0.14.0 core/rruleset/impl#[RRuleSet][FromStr]from_str().(test_str).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
38 let src_obj = RruleTestrust-analyzer cargo rrule 0.14.0 tests/serde/RruleTest# { rrulerust-analyzer cargo rrule 0.14.0 tests/serde/RruleTest#rrule. };
39
40 let test_str = serde_jsonrust-analyzer cargo serde_json 1.0.140 crate/::to_stringrust-analyzer cargo serde_json 1.0.140 ser/to_string().(&src_obj).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
41 let final_obj = serde_jsonrust-analyzer cargo serde_json 1.0.140 crate/::from_strrust-analyzer cargo serde_json 1.0.140 de/from_str().::<RruleTestrust-analyzer cargo rrule 0.14.0 tests/serde/RruleTest#>(&test_str).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
42
43 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_obj, final_obj);
44 }
45 }