| 1 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/}; |
| 2 | |
| 3 | use serde_deriverust-analyzer cargo serde_derive 1.0.228 crate/::Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:; |
| 4 | |
| 5 | use craterust-analyzer cargo ron 0.12.0 crate/::Numberrust-analyzer cargo ron 0.12.0 value/number/Number#; |
| 6 | |
| 7 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 8 | struct EmptyStruct1rust-analyzer cargo ron 0.12.0 ser/tests/EmptyStruct1#; |
| 9 | |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 11 | struct EmptyStruct2rust-analyzer cargo ron 0.12.0 ser/tests/EmptyStruct2# {} |
| 12 | |
| 13 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 14 | struct NewTyperust-analyzer cargo ron 0.12.0 ser/tests/NewType#(i32); |
| 15 | |
| 16 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 17 | struct TupleStructrust-analyzer cargo ron 0.12.0 ser/tests/TupleStruct#(f32, f32); |
| 18 | |
| 19 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 20 | struct MyStructrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct# { |
| 21 | xrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct#x.: f32, |
| 22 | yrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct#y.: f32, |
| 23 | } |
| 24 | |
| 25 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 26 | enum MyEnumrust-analyzer cargo ron 0.12.0 ser/tests/MyEnum# { |
| 27 | Arust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#A#, |
| 28 | Brust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#B#(bool), |
| 29 | Crust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#C#(bool, f32), |
| 30 | Drust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D# { arust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D#a.: i32, brust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D#b.: i32 }, |
| 31 | } |
| 32 | |
| 33 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 34 | fn test_empty_structrust-analyzer cargo ron 0.12.0 ser/tests/test_empty_struct().() { |
| 35 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&EmptyStruct1rust-analyzer cargo ron 0.12.0 ser/tests/EmptyStruct1#, "()", "EmptyStruct1"); |
| 36 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&EmptyStruct2rust-analyzer cargo ron 0.12.0 ser/tests/EmptyStruct2# {}, "()", "EmptyStruct2()"); |
| 37 | } |
| 38 | |
| 39 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 40 | fn test_structrust-analyzer cargo ron 0.12.0 ser/tests/test_struct().() { |
| 41 | let my_struct = MyStructrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct# { xrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct#x.: 4.0, yrust-analyzer cargo ron 0.12.0 ser/tests/MyStruct#y.: 7.0 }; |
| 42 | |
| 43 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&my_struct, "(x:4.0,y:7.0)", "MyStruct(x: 4.0, y: 7.0)"); |
| 44 | |
| 45 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&NewTyperust-analyzer cargo ron 0.12.0 ser/tests/NewType#(42), "(42)", "NewType(42)"); |
| 46 | |
| 47 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&TupleStructrust-analyzer cargo ron 0.12.0 ser/tests/TupleStruct#(2.0, 5.0), "(2.0,5.0)", "TupleStruct(2.0, 5.0)"); |
| 48 | } |
| 49 | |
| 50 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 51 | fn test_optionrust-analyzer cargo ron 0.12.0 ser/tests/test_option().() { |
| 52 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1u8), "Some(1)", "Some(1)"); |
| 53 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<u8>, "None", "None"); |
| 54 | } |
| 55 | |
| 56 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 57 | fn test_enumrust-analyzer cargo ron 0.12.0 ser/tests/test_enum().() { |
| 58 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&MyEnumrust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#::Arust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#A#, "A", "A"); |
| 59 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&MyEnumrust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#::Brust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#B#(true), "B(true)", "B(true)"); |
| 60 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&MyEnumrust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#::Crust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#C#(true, 3.5), "C(true,3.5)", "C(true, 3.5)"); |
| 61 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&MyEnumrust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#::Drust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D# { arust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D#a.: 2, brust-analyzer cargo ron 0.12.0 ser/tests/MyEnum#D#b.: 3 }, "D(a:2,b:3)", "D(a: 2, b: 3)"); |
| 62 | } |
| 63 | |
| 64 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 65 | fn test_arrayrust-analyzer cargo ron 0.12.0 ser/tests/test_array().() { |
| 66 | let empty: [i32; 0] = []; |
| 67 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&empty, "()", "()"); |
| 68 | let empty_ref: &[i32] = ∅ |
| 69 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&empty_ref, "[]", "[]"); |
| 70 | |
| 71 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&[2, 3, 4i32], "(2,3,4)", "(2, 3, 4)"); |
| 72 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 73 | &(&[2, 3, 4i32] as &[i32]), |
| 74 | "[2,3,4]", |
| 75 | "[\n 2,\n 3,\n 4,\n]", |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 80 | fn test_slicerust-analyzer cargo ron 0.12.0 ser/tests/test_slice().() { |
| 81 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 82 | &[0, 1, 2, 3, 4, 5][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., |
| 83 | "[0,1,2,3,4,5]", |
| 84 | "[\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n]", |
| 85 | ); |
| 86 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 87 | &[0, 1, 2, 3, 4, 5][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., |
| 88 | "[1,2,3]", |
| 89 | "[\n 1,\n 2,\n 3,\n]", |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 94 | fn test_vecrust-analyzer cargo ron 0.12.0 ser/tests/test_vec().() { |
| 95 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 96 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 3, 4, 5], |
| 97 | "[0,1,2,3,4,5]", |
| 98 | "[\n 0,\n 1,\n 2,\n 3,\n 4,\n 5,\n]", |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 103 | fn test_maprust-analyzer cargo ron 0.12.0 ser/tests/test_map().() { |
| 104 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 105 | |
| 106 | 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().(); |
| 107 | map.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().((true, false), 4); |
| 108 | map.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().((false, false), 123); |
| 109 | |
| 110 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 111 | &map, |
| 112 | "{(false,false):123,(true,false):4}", |
| 113 | "{\n (false, false): 123,\n (true, false): 4,\n}", |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 118 | fn test_stringrust-analyzer cargo ron 0.12.0 ser/tests/test_string().() { |
| 119 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&"Some string", "\"Some string\"", "\"Some string\""); |
| 120 | } |
| 121 | |
| 122 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 123 | fn test_charrust-analyzer cargo ron 0.12.0 ser/tests/test_char().() { |
| 124 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&'c', "'c'", "'c'"); |
| 125 | } |
| 126 | |
| 127 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 128 | fn test_escaperust-analyzer cargo ron 0.12.0 ser/tests/test_escape().() { |
| 129 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&r#""Quoted""#, r#""\"Quoted\"""#, r#""\"Quoted\"""#); |
| 130 | } |
| 131 | |
| 132 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 133 | fn test_byte_streamrust-analyzer cargo ron 0.12.0 ser/tests/test_byte_stream().() { |
| 134 | use serde_bytesrust-analyzer cargo serde_bytes 0.11.16 crate/; |
| 135 | |
| 136 | let small: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; |
| 137 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 138 | &small, |
| 139 | "(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)", |
| 140 | "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)", |
| 141 | ); |
| 142 | |
| 143 | let large = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0x01, 0x02, 0x03, 0x04]; |
| 144 | let large = serde_bytesrust-analyzer cargo serde_bytes 0.11.16 crate/::Bytesrust-analyzer cargo serde_bytes 0.11.16 bytes/Bytes#::newrust-analyzer cargo serde_bytes 0.11.16 bytes/impl#[Bytes]new().(&large); |
| 145 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 146 | &large, |
| 147 | "b\"\\x01\\x02\\x03\\x04\"", |
| 148 | "b\"\\x01\\x02\\x03\\x04\"", |
| 149 | ); |
| 150 | |
| 151 | let large = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0x01, 0x02, 0x03, 0x04, 0x05, 0x06]; |
| 152 | let large = serde_bytesrust-analyzer cargo serde_bytes 0.11.16 crate/::Bytesrust-analyzer cargo serde_bytes 0.11.16 bytes/Bytes#::newrust-analyzer cargo serde_bytes 0.11.16 bytes/impl#[Bytes]new().(&large); |
| 153 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 154 | &large, |
| 155 | "b\"\\x01\\x02\\x03\\x04\\x05\\x06\"", |
| 156 | "b\"\\x01\\x02\\x03\\x04\\x05\\x06\"", |
| 157 | ); |
| 158 | |
| 159 | let large = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![255u8; 64]; |
| 160 | let large = serde_bytesrust-analyzer cargo serde_bytes 0.11.16 crate/::Bytesrust-analyzer cargo serde_bytes 0.11.16 bytes/Bytes#::newrust-analyzer cargo serde_bytes 0.11.16 bytes/impl#[Bytes]new().(&large); |
| 161 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().( |
| 162 | &large, |
| 163 | concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!( |
| 164 | "b\"\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 165 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 166 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 167 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 168 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\"" |
| 169 | ), |
| 170 | concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!( |
| 171 | "b\"\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 172 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 173 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 174 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff", |
| 175 | "\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\"" |
| 176 | ), |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 181 | fn renamerust-analyzer cargo ron 0.12.0 ser/tests/rename().() { |
| 182 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, 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:)] |
| 183 | enum Foorust-analyzer cargo ron 0.12.0 ser/tests/Foo# { |
| 184 | #[serderust-analyzer cargo serde_derive 1.0.228 serde:(rename = "2d")] |
| 185 | D2rust-analyzer cargo ron 0.12.0 ser/tests/Foo#D2#, |
| 186 | #[serderust-analyzer cargo serde_derive 1.0.228 serde:(rename = "triangle-list")] |
| 187 | TriangleListrust-analyzer cargo ron 0.12.0 ser/tests/Foo#TriangleList#, |
| 188 | } |
| 189 | |
| 190 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Foorust-analyzer cargo ron 0.12.0 ser/tests/Foo#::D2rust-analyzer cargo ron 0.12.0 ser/tests/Foo#D2#, "r#2d", "r#2d"); |
| 191 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Foorust-analyzer cargo ron 0.12.0 ser/tests/Foo#::TriangleListrust-analyzer cargo ron 0.12.0 ser/tests/Foo#TriangleList#, "r#triangle-list", "r#triangle-list"); |
| 192 | } |
| 193 | |
| 194 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 195 | fn test_any_number_precisionrust-analyzer cargo ron 0.12.0 ser/tests/test_any_number_precision().() { |
| 196 | check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().(1_u8); |
| 197 | check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1_i8); |
| 198 | check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().(1_f32); |
| 199 | check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1_f32); |
| 200 | check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().(0.3_f64); |
| 201 | |
| 202 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(f32::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NAN.), "NaN", "NaN"); |
| 203 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&f32::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NAN., "NaN", "NaN"); |
| 204 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().f32::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NAN.), "-NaN", "-NaN"); |
| 205 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().f32::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NAN.), "-NaN", "-NaN"); |
| 206 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(f32::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]INFINITY.), "inf", "inf"); |
| 207 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&f32::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]INFINITY., "inf", "inf"); |
| 208 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&Numberrust-analyzer cargo ron 0.12.0 value/number/Number#::newrust-analyzer cargo ron 0.12.0 value/number/impl#[Number]new().(f32::NEG_INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NEG_INFINITY.), "-inf", "-inf"); |
| 209 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&f32::NEG_INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]NEG_INFINITY., "-inf", "-inf"); |
| 210 | |
| 211 | macro_rules! test_min_maxrust-analyzer cargo ron 0.12.0 ser/tests/test_min_max! { |
| 212 | ($ty:ty) => { |
| 213 | check_ser_any_number(<$ty>::MIN); |
| 214 | check_ser_any_number(<$ty>::MAX); |
| 215 | }; |
| 216 | ($($ty:ty),*) => { |
| 217 | $(test_min_max! { $ty })* |
| 218 | }; |
| 219 | } |
| 220 | |
| 221 | test_min_maxrust-analyzer cargo ron 0.12.0 ser/tests/test_min_max!! { i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 } |
| 222 | #[cfg(feature = "integer128")] |
| 223 | test_min_maxrust-analyzer cargo ron 0.12.0 ser/tests/test_min_max!! { i128, u128 } |
| 224 | } |
| 225 | |
| 226 | fn check_ser_any_numberrust-analyzer cargo ron 0.12.0 ser/tests/check_ser_any_number().<T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Numberrust-analyzer cargo ron 0.12.0 value/number/Number#> + corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#>(n: T) { |
| 227 | let mut fmt = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", n); |
| 228 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().fmt.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('.') && corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name().::<T>().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('f') { |
| 229 | fmt.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(".0"); |
| 230 | } |
| 231 | |
| 232 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&n.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), &fmt, &fmt); |
| 233 | check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().(&n, &fmt, &fmt); |
| 234 | } |
| 235 | |
| 236 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 237 | fn recursion_limitrust-analyzer cargo ron 0.12.0 ser/tests/recursion_limit().() { |
| 238 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 239 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 240 | .with_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_recursion_limit().(0) |
| 241 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[42]), |
| 242 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(craterust-analyzer cargo ron 0.12.0 crate/::Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExceededRecursionLimitrust-analyzer cargo ron 0.12.0 error/Error#ExceededRecursionLimit#), |
| 243 | ); |
| 244 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 245 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 246 | .with_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_recursion_limit().(1) |
| 247 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[42]) |
| 248 | .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_deref().(), |
| 249 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("(42)"), |
| 250 | ); |
| 251 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 252 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 253 | .without_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]without_recursion_limit().() |
| 254 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[42]) |
| 255 | .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_deref().(), |
| 256 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("(42)"), |
| 257 | ); |
| 258 | |
| 259 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 260 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 261 | .with_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_recursion_limit().(1) |
| 262 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[[42]]), |
| 263 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(craterust-analyzer cargo ron 0.12.0 crate/::Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExceededRecursionLimitrust-analyzer cargo ron 0.12.0 error/Error#ExceededRecursionLimit#), |
| 264 | ); |
| 265 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 266 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 267 | .with_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]with_recursion_limit().(2) |
| 268 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[[42]]) |
| 269 | .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_deref().(), |
| 270 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("((42))"), |
| 271 | ); |
| 272 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 273 | craterust-analyzer cargo ron 0.12.0 crate/::Optionsrust-analyzer cargo ron 0.12.0 options/Options#::defaultrust-analyzer cargo ron 0.12.0 options/impl#[Options][Default]default().() |
| 274 | .without_recursion_limitrust-analyzer cargo ron 0.12.0 options/impl#[Options]without_recursion_limit().() |
| 275 | .to_stringrust-analyzer cargo ron 0.12.0 options/impl#[Options]to_string().(&[[42]]) |
| 276 | .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_deref().(), |
| 277 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("((42))"), |
| 278 | ); |
| 279 | } |
| 280 | |
| 281 | fn check_to_string_writerrust-analyzer cargo ron 0.12.0 ser/tests/check_to_string_writer().<T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#>(val: &T, check: &str, check_pretty: &str) { |
| 282 | let ron_str = superrust-analyzer cargo ron 0.12.0 ser/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(val).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 283 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ron_str, check); |
| 284 | |
| 285 | let ron_str_pretty = superrust-analyzer cargo ron 0.12.0 ser/::to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty().( |
| 286 | val, |
| 287 | superrust-analyzer cargo ron 0.12.0 ser/::PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::defaultrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig][Default]default().() |
| 288 | .struct_namesrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]struct_names().(true) |
| 289 | .compact_structsrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]compact_structs().(true), |
| 290 | ) |
| 291 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 292 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ron_str_pretty, check_pretty); |
| 293 | |
| 294 | #[cfg(feature = "std")] |
| 295 | { |
| 296 | let mut ron_writer = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]new().(); |
| 297 | superrust-analyzer cargo ron 0.12.0 ser/::to_writerrust-analyzer cargo ron 0.12.0 ser/to_writer().(&mut ron_writer, val).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 298 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ron_writer, check); |
| 299 | |
| 300 | let mut ron_writer_pretty = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]new().(); |
| 301 | superrust-analyzer cargo ron 0.12.0 ser/::to_writer_prettyrust-analyzer cargo ron 0.12.0 ser/to_writer_pretty().( |
| 302 | &mut ron_writer_pretty, |
| 303 | val, |
| 304 | superrust-analyzer cargo ron 0.12.0 ser/::PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::defaultrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig][Default]default().() |
| 305 | .struct_namesrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]struct_names().(true) |
| 306 | .compact_structsrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]compact_structs().(true), |
| 307 | ) |
| 308 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 309 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ron_writer_pretty, check_pretty); |
| 310 | } |
| 311 | } |