| 1 | #[macro_use] |
| 2 | extern crate serderust-analyzer cargo serde_cbor_2 0.13.0 serde/; |
| 3 | |
| 4 | use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::derust-analyzer cargo serde_cbor_2 0.13.0 de/; |
| 5 | |
| 6 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 7 | fn test_strrust-analyzer cargo serde_cbor_2 0.13.0 test_str().() { |
| 8 | let s: &str = |
| 9 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(&[0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72], &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 10 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "foobar"); |
| 11 | } |
| 12 | |
| 13 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 14 | fn test_bytesrust-analyzer cargo serde_cbor_2 0.13.0 test_bytes().() { |
| 15 | let s: &[u8] = |
| 16 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(&[0x46, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72], &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 17 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, b"foobar"); |
| 18 | } |
| 19 | |
| 20 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 21 | fn test_intrust-analyzer cargo serde_cbor_2 0.13.0 test_int().() { |
| 22 | let num: i64 = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(&[0x39, 0x07, 0xde], &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 23 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(num, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().2015); |
| 24 | } |
| 25 | |
| 26 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 27 | fn test_floatrust-analyzer cargo serde_cbor_2 0.13.0 test_float().() { |
| 28 | let float: f64 = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(b"\xfa\x47\xc3\x50\x00", &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 29 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(float, 100000.0); |
| 30 | } |
| 31 | |
| 32 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 33 | fn test_indefinite_objectrust-analyzer cargo serde_cbor_2 0.13.0 test_indefinite_object().() { |
| 34 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 35 | struct Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo# { |
| 36 | arust-analyzer cargo serde_cbor_2 0.13.0 Foo#a.: u64, |
| 37 | brust-analyzer cargo serde_cbor_2 0.13.0 Foo#b.: [u64; 2], |
| 38 | } |
| 39 | let expected = Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo# { arust-analyzer cargo serde_cbor_2 0.13.0 Foo#a.: 1, brust-analyzer cargo serde_cbor_2 0.13.0 Foo#b.: [2, 3] }; |
| 40 | let actual: Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo# = |
| 41 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(b"\xbfaa\x01ab\x9f\x02\x03\xff\xff", &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 42 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, actual); |
| 43 | } |
| 44 | |
| 45 | #[cfg(feature = "std")] |
| 46 | mod std_testsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/ { |
| 47 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 48 | |
| 49 | use serderust-analyzer cargo serde 1.0.144 crate/::derust-analyzer cargo serde 1.0.144 de/ as serde_derust-analyzer cargo serde 1.0.144 de/; |
| 50 | use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::valuerust-analyzer cargo serde_cbor_2 0.13.0 value/::Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#; |
| 51 | use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::{derust-analyzer cargo serde_cbor_2 0.13.0 de/, errorrust-analyzer cargo serde_cbor_2 0.13.0 error/, to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec()., Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#}; |
| 52 | |
| 53 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 54 | fn test_string1rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_string1().() { |
| 55 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = |
| 56 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]); |
| 57 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("foobar".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 58 | } |
| 59 | |
| 60 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 61 | fn test_string2rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_string2().() { |
| 62 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[ |
| 63 | 0x71, 0x49, 0x20, 0x6d, 0x65, 0x74, 0x20, 0x61, 0x20, 0x74, 0x72, 0x61, 0x76, 0x65, |
| 64 | 0x6c, 0x6c, 0x65, 0x72, |
| 65 | ]); |
| 66 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("I met a traveller".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 67 | } |
| 68 | |
| 69 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 70 | fn test_string3rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_string3().() { |
| 71 | let slice = b"\x78\x2fI met a traveller from an antique land who said"; |
| 72 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(slice); |
| 73 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 74 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 75 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("I met a traveller from an antique land who said".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 80 | fn test_byte_stringrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_byte_string().() { |
| 81 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = |
| 82 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0x46, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]); |
| 83 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Bytesrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bytes#(b"foobar".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().())); |
| 84 | } |
| 85 | |
| 86 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 87 | fn test_numbers1rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_numbers1().() { |
| 88 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0x00]); |
| 89 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(0)); |
| 90 | } |
| 91 | |
| 92 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 93 | fn test_numbers2rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_numbers2().() { |
| 94 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0x1a, 0x00, 0xbc, 0x61, 0x4e]); |
| 95 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(12345678)); |
| 96 | } |
| 97 | |
| 98 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 99 | fn test_numbers3rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_numbers3().() { |
| 100 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0x39, 0x07, 0xde]); |
| 101 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().2015)); |
| 102 | } |
| 103 | |
| 104 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 105 | fn test_boolrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_bool().() { |
| 106 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xf4"); |
| 107 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Boolrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bool#(false)); |
| 108 | } |
| 109 | |
| 110 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 111 | fn test_trailing_bytesrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_trailing_bytes().() { |
| 112 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xf4trailing"); |
| 113 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(value.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 114 | } |
| 115 | |
| 116 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 117 | fn test_list1rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_list1().() { |
| 118 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\x83\x01\x02\x03"); |
| 119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 120 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 121 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 122 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1), |
| 123 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(2), |
| 124 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(3) |
| 125 | ]) |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 130 | fn test_list2rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_list2().() { |
| 131 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\x82\x01\x82\x02\x81\x03"); |
| 132 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 133 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 134 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 135 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1), |
| 136 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 137 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(2), |
| 138 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(3)]) |
| 139 | ]) |
| 140 | ]) |
| 141 | ); |
| 142 | } |
| 143 | |
| 144 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 145 | fn test_objectrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_object().() { |
| 146 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xa5aaaAabaBacaCadaDaeaE"); |
| 147 | let mut object = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 148 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("a".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("A".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 149 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("b".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("B".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 150 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("c".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("C".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 151 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("d".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("D".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 152 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("e".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("E".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 153 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Maprust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Map#(object)); |
| 154 | } |
| 155 | |
| 156 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 157 | fn test_indefinite_objectrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_indefinite_object().() { |
| 158 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xbfaa\x01ab\x9f\x02\x03\xff\xff"); |
| 159 | let mut object = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 160 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("a".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1)); |
| 161 | object.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().( |
| 162 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("b".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 163 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(2), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(3)]), |
| 164 | ); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Maprust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Map#(object)); |
| 166 | } |
| 167 | |
| 168 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 169 | fn test_indefinite_listrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_indefinite_list().() { |
| 170 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\x9f\x01\x02\x03\xff"); |
| 171 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 172 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 173 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 174 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1), |
| 175 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(2), |
| 176 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(3) |
| 177 | ]) |
| 178 | ); |
| 179 | } |
| 180 | |
| 181 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 182 | fn test_indefinite_stringrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_indefinite_string().() { |
| 183 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = |
| 184 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\x7f\x65Mary \x64Had \x62a \x67Little \x60\x64Lamb\xff"); |
| 185 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 186 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 187 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("Mary Had a Little Lamb".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 188 | ); |
| 189 | } |
| 190 | |
| 191 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 192 | fn test_indefinite_byte_stringrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_indefinite_byte_string().() { |
| 193 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\x5f\x42\x01\x23\x42\x45\x67\xff"); |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Bytesrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bytes#(b"\x01#Eg".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().())); |
| 195 | } |
| 196 | |
| 197 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 198 | fn test_multiple_indefinite_stringsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_multiple_indefinite_strings().() { |
| 199 | let input = b"\x82\x7f\x65Mary \x64Had \x62a \x67Little \x60\x64Lamb\xff\x5f\x42\x01\x23\x42\x45\x67\xff"; |
| 200 | _test_multiple_indefinite_stringsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/_test_multiple_indefinite_strings().(derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(input)); |
| 201 | _test_multiple_indefinite_stringsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/_test_multiple_indefinite_strings().(derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_mut_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_mut_slice().(input.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().().as_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsMut<[T]>`]as_mut().())); |
| 202 | let mut buf = [0u8; 64]; |
| 203 | _test_multiple_indefinite_stringsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/_test_multiple_indefinite_strings().(derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(input, &mut buf)); |
| 204 | } |
| 205 | fn _test_multiple_indefinite_stringsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/_test_multiple_indefinite_strings().(value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>) { |
| 206 | // This assures that buffer rewinding in infinite buffers works as intended. |
| 207 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 208 | value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 209 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Arrayrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Array#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 210 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("Mary Had a Little Lamb".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 211 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Bytesrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bytes#(b"\x01#Eg".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()) |
| 212 | ]) |
| 213 | ); |
| 214 | } |
| 215 | |
| 216 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 217 | fn test_floatrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_float().() { |
| 218 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xfa\x47\xc3\x50\x00"); |
| 219 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(100000.0)); |
| 220 | } |
| 221 | |
| 222 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 223 | fn test_self_describingrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_self_describing().() { |
| 224 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = |
| 225 | derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0xd9, 0xd9, 0xf7, 0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]); |
| 226 | let expected = Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("foobar".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 227 | let strip_tags = |x: Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#| { |
| 228 | if let Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Tagrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Tag#(_, inner) = x { |
| 229 | *rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().inner |
| 230 | } else { |
| 231 | x |
| 232 | } |
| 233 | }; |
| 234 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(strip_tags(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), expected); |
| 235 | } |
| 236 | |
| 237 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 238 | fn test_f16rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_f16().() { |
| 239 | let mut x: Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value# = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0xf9, 0x41, 0x00]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 240 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(2.5)); |
| 241 | x = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0xf9, 0x41, 0x90]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 242 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(2.78125)); |
| 243 | x = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0xf9, 0x50, 0x90]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 244 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(36.5)); |
| 245 | x = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&[0xf9, 0xd0, 0x90]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 246 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().36.5)); |
| 247 | } |
| 248 | |
| 249 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 250 | fn test_crazy_listrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_crazy_list().() { |
| 251 | let slice = b"\x88\x1b\x00\x00\x00\x1c\xbe\x99\x1d\xc7\x3b\x00\x7a\xcf\x51\xdc\x51\x70\xdb\x3a\x1b\x3a\x06\xdd\xf5\xf6\xf7\xfb\x41\x76\x5e\xb1\xf8\x00\x00\x00\xf9\x7c\x00"; |
| 252 | let value: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(slice).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 253 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 254 | value, |
| 255 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 256 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(123456789959), |
| 257 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().34567897654325468), |
| 258 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][Neg]neg().456787678), |
| 259 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Boolrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Bool#(true), |
| 260 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Nullrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Null#, |
| 261 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Nullrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Null#, |
| 262 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(23456543.5), |
| 263 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Floatrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Float#(f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.) |
| 264 | ] |
| 265 | ); |
| 266 | } |
| 267 | |
| 268 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 269 | fn test_nanrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_nan().() { |
| 270 | let value: f64 = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xf9\x7e\x00").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 271 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(value.is_nanrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_nan().()); |
| 272 | } |
| 273 | |
| 274 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 275 | fn test_32f16rust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_32f16().() { |
| 276 | let value: f32 = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(b"\xf9\x50\x00").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 277 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, 32.0f32); |
| 278 | } |
| 279 | |
| 280 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 281 | // The file was reported as not working by user kie0tauB |
| 282 | // but it parses to a cbor value. |
| 283 | fn test_kietaub_filerust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_kietaub_file().() { |
| 284 | let file = include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("kietaub.cbor"); |
| 285 | let value_result: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(file); |
| 286 | value_result.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 287 | } |
| 288 | |
| 289 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 290 | fn test_option_roundtriprust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_option_roundtrip().() { |
| 291 | let obj1 = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(10u32); |
| 292 | |
| 293 | let v = to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec().(&obj1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 294 | let obj2: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, _> = serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_readerrust-analyzer cargo serde_cbor_2 0.13.0 de/from_reader().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 295 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{obj2:?}"); |
| 296 | |
| 297 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj1, obj2.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 298 | } |
| 299 | |
| 300 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 301 | fn test_option_none_roundtriprust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_option_none_roundtrip().() { |
| 302 | let obj1 = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 303 | |
| 304 | let v = to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec().(&obj1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 305 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{v:?}"); |
| 306 | let obj2: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, _> = serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_readerrust-analyzer cargo serde_cbor_2 0.13.0 de/from_reader().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 307 | |
| 308 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj1, obj2.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 309 | } |
| 310 | |
| 311 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 312 | fn test_variable_length_maprust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_variable_length_map().() { |
| 313 | let slice = b"\xbf\x67\x6d\x65\x73\x73\x61\x67\x65\x64\x70\x6f\x6e\x67\xff"; |
| 314 | let value: Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value# = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(slice).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 315 | let mut map = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 316 | map.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().( |
| 317 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("message".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 318 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("pong".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 319 | ); |
| 320 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Maprust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Map#(map)) |
| 321 | } |
| 322 | |
| 323 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 324 | fn test_object_determinism_roundtriprust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_object_determinism_roundtrip().() { |
| 325 | let expected = b"\xa2aa\x01ab\x82\x02\x03"; |
| 326 | |
| 327 | // 0.1% chance of not catching failure |
| 328 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10 { |
| 329 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 330 | &to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec().(&derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(expected).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 331 | expected |
| 332 | ); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 337 | fn stream_deserializerrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/stream_deserializer().() { |
| 338 | let slice = b"\x01\x66foobar"; |
| 339 | let mut it = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceRead<'a>>`]from_slice().(slice).into_iterrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]into_iter().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(); |
| 340 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1), it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 341 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 342 | Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Textrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Text#("foobar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 343 | it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 344 | ); |
| 345 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 346 | } |
| 347 | |
| 348 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 349 | fn stream_deserializer_eofrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/stream_deserializer_eof().() { |
| 350 | let slice = b"\x01\x66foob"; |
| 351 | let mut it = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceRead<'a>>`]from_slice().(slice).into_iterrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]into_iter().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(); |
| 352 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#::Integerrust-analyzer cargo serde_cbor_2 0.13.0 value/Value#Integer#(1), it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 353 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().is_eofrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_eof().()); |
| 354 | } |
| 355 | |
| 356 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 357 | fn stream_deserializer_eof_in_indefiniterust-analyzer cargo serde_cbor_2 0.13.0 std_tests/stream_deserializer_eof_in_indefinite().() { |
| 358 | let slice = b"\x7f\x65Mary \x64Had \x62a \x60\x67Little \x60\x64Lamb\xff"; |
| 359 | let indices: &[usize] = &[ |
| 360 | 2, // announcement but no data |
| 361 | 10, // mid-buffer EOF |
| 362 | 12, // neither new element nor end marker |
| 363 | ]; |
| 364 | for end_of_slice in indices { |
| 365 | let mut it = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceRead<'a>>`]from_slice().(&slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_of_slice]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).into_iterrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]into_iter().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(); |
| 366 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().is_eofrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_eof().()); |
| 367 | |
| 368 | let mut mutcopy = slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_of_slice]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().(); |
| 369 | let mut it = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_mut_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<MutSliceRead<'a>>`]from_mut_slice().(mutcopy.as_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsMut<[T]>`]as_mut().()).into_iterrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]into_iter().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(); |
| 370 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().is_eofrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_eof().()); |
| 371 | |
| 372 | let mut buf = [0u8; 64]; |
| 373 | let mut it = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceReadFixed<'a, 'b>>`]from_slice_with_scratch().(&slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().end_of_slice]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &mut buf) |
| 374 | .into_iterrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]into_iter().::<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(); |
| 375 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`StreamDeserializer<'de, R, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().is_eofrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_eof().()); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 380 | fn crashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/crash().() { |
| 381 | let file = include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("crash.cbor"); |
| 382 | let value_result: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#> = derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(file); |
| 383 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 384 | value_result.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 385 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 386 | ); |
| 387 | } |
| 388 | |
| 389 | fn from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().<'a, T>(slice: &'a [u8]) -> errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&'a [u8], T)> |
| 390 | where |
| 391 | T: serde_derust-analyzer cargo serde 1.0.144 de/::Deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#<'a>, |
| 392 | { |
| 393 | let mut deserializer = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceRead<'a>>`]from_slice().(slice); |
| 394 | let value = serde_derust-analyzer cargo serde 1.0.144 de/::Deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#::deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#deserialize().(&mut deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 395 | let rest = &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().deserializer.byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]byte_offset().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 396 | |
| 397 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((rest, value)) |
| 398 | } |
| 399 | |
| 400 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 401 | fn test_slice_offsetrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_slice_offset().() { |
| 402 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 403 | 0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72, 0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72, |
| 404 | ]; |
| 405 | let (rest, value): (&[u8], Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 406 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "foobar"); |
| 407 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rest, &[0x66, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72]); |
| 408 | let (rest, value): (&[u8], Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(rest).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 409 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, "foobar"); |
| 410 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rest, &[]); |
| 411 | } |
| 412 | |
| 413 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 414 | struct Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 415 | standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#standard.: bool, |
| 416 | legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#legacy.: bool, |
| 417 | packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#packed.: bool, |
| 418 | namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#named.: bool, |
| 419 | } |
| 420 | |
| 421 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 422 | fn defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().() -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default] { |
| 423 | Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 424 | standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#standard.: true, |
| 425 | legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#legacy.: true, |
| 426 | packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#packed.: true, |
| 427 | namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#named.: true, |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | impl Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 433 | fn no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().(self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options] { |
| 434 | Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 435 | standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#standard.: false, |
| 436 | ..self |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | fn no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().(self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options] { |
| 441 | Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 442 | legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#legacy.: false, |
| 443 | ..self |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | fn no_packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_packed().(self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options] { |
| 448 | Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 449 | packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#packed.: false, |
| 450 | ..self |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | fn no_namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_named().(self) -> Selfrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options] { |
| 455 | Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options# { |
| 456 | namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#named.: false, |
| 457 | ..self |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | fn from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().<'a, T>( |
| 463 | slice: &'a [u8], |
| 464 | options: Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#, |
| 465 | ) -> errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&'a [u8], T)> |
| 466 | where |
| 467 | T: serde_derust-analyzer cargo serde 1.0.144 de/::Deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#<'a>, |
| 468 | { |
| 469 | let deserializer = Deserializerrust-analyzer cargo serde_cbor_2 0.13.0 de/Deserializer#::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<SliceRead<'a>>`]from_slice().(slice); |
| 470 | let deserializer = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().options.packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#packed. { |
| 471 | deserializer.disable_packed_formatrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]disable_packed_format().() |
| 472 | } else { |
| 473 | deserializer |
| 474 | }; |
| 475 | let deserializer = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().options.namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#named. { |
| 476 | deserializer.disable_named_formatrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]disable_named_format().() |
| 477 | } else { |
| 478 | deserializer |
| 479 | }; |
| 480 | let deserializer = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().options.standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#standard. { |
| 481 | deserializer.disable_standard_enumsrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]disable_standard_enums().() |
| 482 | } else { |
| 483 | deserializer |
| 484 | }; |
| 485 | let mut deserializer = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().options.legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#legacy. { |
| 486 | deserializer.disable_legacy_enumsrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]disable_legacy_enums().() |
| 487 | } else { |
| 488 | deserializer |
| 489 | }; |
| 490 | let value = serde_derust-analyzer cargo serde 1.0.144 de/::Deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#::deserializerust-analyzer cargo serde 1.0.144 de/Deserialize#deserialize().(&mut deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 491 | let rest = &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().deserializer.byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 de/impl#[`Deserializer<R>`]byte_offset().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 492 | |
| 493 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((rest, value)) |
| 494 | } |
| 495 | |
| 496 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 497 | fn test_deserializer_enumsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_deserializer_enums().() { |
| 498 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:)] |
| 499 | enum Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum# { |
| 500 | Unitrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Unit#, |
| 501 | NewTyperust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#NewType#(i32), |
| 502 | Tuplerust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Tuple#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, bool), |
| 503 | Structrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Struct# { xrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Struct#x.: i32, yrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Struct#y.: i32 }, |
| 504 | } |
| 505 | |
| 506 | // This is the format used in serde >= 0.10 |
| 507 | // |
| 508 | // Serialization of Enum::NewType(10) |
| 509 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 510 | 0xa1, // map 1pair |
| 511 | 0x67, 0x4e, 0x65, 0x77, 0x54, 0x79, 0x70, 0x65, // utf8 string: NewType |
| 512 | 0x1a, // u32 |
| 513 | 0x00, 0x00, 0x00, 0x0a, // 10 (dec) |
| 514 | ]; |
| 515 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 516 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::NewTyperust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#NewType#(10)); |
| 517 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = |
| 518 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 519 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::NewTyperust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#NewType#(10)); |
| 520 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 521 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().()); |
| 522 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 523 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 524 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 525 | ); |
| 526 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 527 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().()); |
| 528 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 529 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 530 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 531 | ); |
| 532 | // Serialization of Enum::Unit |
| 533 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 534 | 0x64, 0x55, 0x6e, 0x69, 0x74, // utf8 string: Unit |
| 535 | ]; |
| 536 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 537 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::Unitrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Unit#); |
| 538 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = |
| 539 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 540 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::Unitrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Unit#); |
| 541 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = |
| 542 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 543 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::Unitrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#Unit#); |
| 544 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 545 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().()); |
| 546 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 547 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 548 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 549 | ); |
| 550 | |
| 551 | // This is the format used in serde <= 0.9 |
| 552 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 553 | 0x82, // array 2 items |
| 554 | 0x67, 0x4e, 0x65, 0x77, 0x54, 0x79, 0x70, 0x65, // utf8 string: NewType |
| 555 | 0x1a, // u32 |
| 556 | 0x00, 0x00, 0x00, 0x0a, // 10 (dec) |
| 557 | ]; |
| 558 | let (_rest, value): (&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 559 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::NewTyperust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#NewType#(10)); |
| 560 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 561 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().()); |
| 562 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 563 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 564 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 565 | ); |
| 566 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 567 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().()); |
| 568 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().1, Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#::NewTyperust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#NewType#(10)); |
| 569 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Enumrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Enum#)> = |
| 570 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_standardrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_standard().().no_legacyrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_legacy().()); |
| 571 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 572 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 573 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 574 | ); |
| 575 | } |
| 576 | |
| 577 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 578 | fn test_packed_deserializationrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_packed_deserialization().() { |
| 579 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:)] |
| 580 | struct Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 581 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: u32, |
| 582 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [u8; 4], |
| 583 | } |
| 584 | |
| 585 | // unpacked |
| 586 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 587 | 0xa2, // map 2pair |
| 588 | 0x67, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, // utf8 string: user_id |
| 589 | 0x0a, // integer: 10 |
| 590 | // utf8 string: password_hash |
| 591 | 0x6d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, |
| 592 | 0x84, 0x01, 0x02, 0x03, 0x04, // 4 byte array [1, 2, 3, 4] |
| 593 | ]; |
| 594 | |
| 595 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 596 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 597 | value, |
| 598 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 599 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 600 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 601 | } |
| 602 | ); |
| 603 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = |
| 604 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_packed().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 605 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 606 | value, |
| 607 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 608 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 609 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 610 | } |
| 611 | ); |
| 612 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#)> = |
| 613 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_named().()); |
| 614 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 615 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 616 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 617 | ); |
| 618 | |
| 619 | // unpacked - indefinite length |
| 620 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 621 | 0xbf, // map to be followed by a break |
| 622 | 0x67, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, // utf8 string: user_id |
| 623 | 0x0a, // integer: 10 |
| 624 | // utf8 string: password_hash |
| 625 | 0x6d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, |
| 626 | 0x84, 0x01, 0x02, 0x03, 0x04, // 4 byte array [1, 2, 3, 4] |
| 627 | 0xff, // break |
| 628 | ]; |
| 629 | |
| 630 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 631 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 632 | value, |
| 633 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 634 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 635 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 636 | } |
| 637 | ); |
| 638 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = |
| 639 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_packed().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 640 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 641 | value, |
| 642 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 643 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 644 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 645 | } |
| 646 | ); |
| 647 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#)> = |
| 648 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_named().()); |
| 649 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 650 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 651 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 652 | ); |
| 653 | |
| 654 | // packed |
| 655 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 656 | 0xa2, // map 2pair |
| 657 | 0x00, // index 0 |
| 658 | 0x0a, // integer: 10 |
| 659 | 0x01, // index 1 |
| 660 | 0x84, 0x01, 0x02, 0x03, 0x04, // 4 byte array [1, 2, 3, 4] |
| 661 | ]; |
| 662 | |
| 663 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 664 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 665 | value, |
| 666 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 667 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 668 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 669 | } |
| 670 | ); |
| 671 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = |
| 672 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_named().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 673 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 674 | value, |
| 675 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 676 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 677 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 678 | } |
| 679 | ); |
| 680 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#)> = |
| 681 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_packed().()); |
| 682 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 683 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 684 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 685 | ); |
| 686 | |
| 687 | // packed - indefinite length |
| 688 | let v: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 689 | 0xbf, // map, to be followed by a break |
| 690 | 0x00, // index 0 |
| 691 | 0x0a, // integer: 10 |
| 692 | 0x01, // index 1 |
| 693 | 0x84, 0x01, 0x02, 0x03, 0x04, // 4 byte array [1, 2, 3, 4] |
| 694 | 0xff, // break |
| 695 | ]; |
| 696 | |
| 697 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = from_slice_streamrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 698 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 699 | value, |
| 700 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 701 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 702 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 703 | } |
| 704 | ); |
| 705 | let (_rest, value): (&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#) = |
| 706 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_namedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_named().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 707 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 708 | value, |
| 709 | Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User# { |
| 710 | user_idrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#user_id.: 10, |
| 711 | password_hashrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#password_hash.: [1, 2, 3, 4], |
| 712 | } |
| 713 | ); |
| 714 | let value: errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<(&[u8], Userrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/User#)> = |
| 715 | from_slice_stream_optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/from_slice_stream_options().(&v[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Optionsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/Options#::defaultrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options][Default]default().().no_packedrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/impl#[Options]no_packed().()); |
| 716 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 717 | value.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().classifyrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]classify().(), |
| 718 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::Categoryrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#::Syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/Category#Syntax# |
| 719 | ); |
| 720 | } |
| 721 | |
| 722 | use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::{derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice()., serrust-analyzer cargo serde_cbor_2 0.13.0 ser/::to_vec_packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec_packed().}; |
| 723 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#}; |
| 724 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 725 | fn test_ipaddr_deserializationrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test_ipaddr_deserialization().() { |
| 726 | let ip = IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr]new().(127, 0, 0, 1)); |
| 727 | let buf = to_vec_packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec_packed().(&ip).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 728 | let deserialized_ip = from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().::<IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#>(&buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 729 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ip, deserialized_ip); |
| 730 | |
| 731 | let buf = to_vecrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec().(&ip).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 732 | let deserialized_ip = from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().::<IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#>(&buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 733 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ip, deserialized_ip); |
| 734 | } |
| 735 | |
| 736 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 737 | fn attempt_stack_overflowrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/attempt_stack_overflow().() { |
| 738 | // Create a tag 17, followed by 999 more tag 17: |
| 739 | // 17(17(17(17(17(17(17(17(17(17(17(17(17(17(17(17(17(17(... |
| 740 | // This causes deep recursion in the decoder and may |
| 741 | // exhaust the stack and therfore result in a stack overflow. |
| 742 | let input = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0xd1; 1000]; |
| 743 | let err = |
| 744 | serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().::<serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::Valuerust-analyzer cargo serde_cbor_2 0.13.0 value/Value#>(&input).expect_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect_err().("recursion limit"); |
| 745 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.is_syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_syntax().()); |
| 746 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.offsetrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]offset().() >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). 0); |
| 747 | |
| 748 | 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().err.is_iorust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_io().()); |
| 749 | 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().err.is_eofrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_eof().()); |
| 750 | 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().err.is_datarust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_data().()); |
| 751 | 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().err.is_scratch_too_smallrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_scratch_too_small().()); |
| 752 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.is_syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]is_syntax().()); |
| 753 | } |
| 754 | } |