1// SPDX-License-Identifier: Apache-2.0
2
3extern crate alloc;
4
5use ciborium::{
6 cbor,
7 value::{Integer, Value, Value::Null},
8};
9
10use rstest::rstest;
11use serde_bytes::Bytes;
12
13macro_rules! map {
14 ($($key:expr => $val:expr),* $(,)*) => {
15 Value::Map(vec![$(
16 (
17 Value::serialized(&$key).unwrap(),
18 Value::serialized(&$val).unwrap()
19 )
20 ),*])
21 };
22}
23
24macro_rules! arr {
25 ($($val:expr),*) => {
26 Value::Array(vec![$(
27 Value::serialized(&$val).unwrap()
28 ),*])
29 };
30}
31
32#[rstest(answer, question,
33 // Non-numeric simple types
34 case(Value::Null, cbor!(null).unwrap()),
35 case(Value::Bool(true), cbor!(true).unwrap()),
36 case(Value::Bool(false), cbor!(false).unwrap()),
37 case(Value::Text("foo".into()), cbor!("foo").unwrap()),
38 case(Value::Bytes(vec![0, 1, 2]), cbor!(Bytes::new(b"\x00\x01\x02")).unwrap()),
39
40 // Numeric simple types
41 case(Value::Integer(Integer::from(123)), cbor!(123).unwrap()),
42 case(Value::Integer(Integer::from(-123)), cbor!(-123).unwrap()),
43 case(Value::Float(1.23), cbor!(1.23).unwrap()),
44 case(Value::Float(-1.23), cbor!(-1.23).unwrap()),
45 case(Value::Float(2.5e+1), cbor!(2.5e+1).unwrap()),
46 case(Value::Float(-2.5e+1), cbor!(-2.5e+1).unwrap()),
47
48 // Simple array formulations
49 case(arr![], cbor!([]).unwrap()),
50 case(arr![Null], cbor!([null]).unwrap()),
51 case(arr![true], cbor!([true]).unwrap()),
52 case(arr![false], cbor!([false]).unwrap()),
53 case(arr!["foo"], cbor!(["foo"]).unwrap()),
54 case(arr![123], cbor!([123]).unwrap()),
55 case(arr![-123], cbor!([-123]).unwrap()),
56 case(arr![1.23], cbor!([1.23]).unwrap()),
57 case(arr![-1.23], cbor!([-1.23]).unwrap()),
58 case(arr![2.5e+1], cbor!([2.5e+1]).unwrap()),
59 case(arr![2.5e+1], cbor!([2.5e+1]).unwrap()),
60 case(arr![[1, 2]], cbor!([[1, 2]]).unwrap()),
61 case(arr![map! {1=>2,3=>4}], cbor!([{1=>2,3=>4}]).unwrap()),
62
63 // Two-item array formluations
64 case(arr![Null, Null], cbor!([null, null]).unwrap()),
65 case(arr![Null, true], cbor!([null, true]).unwrap()),
66 case(arr![Null, false], cbor!([null, false]).unwrap()),
67 case(arr![Null, "foo"], cbor!([null, "foo"]).unwrap()),
68 case(arr![Null, 123], cbor!([null, 123]).unwrap()),
69 case(arr![Null, -123], cbor!([null, -123]).unwrap()),
70 case(arr![Null, 1.23], cbor!([null, 1.23]).unwrap()),
71 case(arr![Null, -1.23], cbor!([null, -1.23]).unwrap()),
72 case(arr![Null, 2.5e+1], cbor!([null, 2.5e+1]).unwrap()),
73 case(arr![Null, 2.5e+1], cbor!([null, 2.5e+1]).unwrap()),
74 case(arr![Null, [1, 2]], cbor!([null, [1, 2]]).unwrap()),
75 case(arr![Null, map! {1=>2,3=>4}], cbor!([null, {1=>2,3=>4}]).unwrap()),
76 case(arr![true, Null], cbor!([true, null]).unwrap()),
77 case(arr![true, true], cbor!([true, true]).unwrap()),
78 case(arr![true, false], cbor!([true, false]).unwrap()),
79 case(arr![true, "foo"], cbor!([true, "foo"]).unwrap()),
80 case(arr![true, 123], cbor!([true, 123]).unwrap()),
81 case(arr![true, -123], cbor!([true, -123]).unwrap()),
82 case(arr![true, 1.23], cbor!([true, 1.23]).unwrap()),
83 case(arr![true, -1.23], cbor!([true, -1.23]).unwrap()),
84 case(arr![true, 2.5e+1], cbor!([true, 2.5e+1]).unwrap()),
85 case(arr![true, 2.5e+1], cbor!([true, 2.5e+1]).unwrap()),
86 case(arr![true, [1, 2]], cbor!([true, [1, 2]]).unwrap()),
87 case(arr![true, map! {1=>2,3=>4}], cbor!([true, {1=>2,3=>4}]).unwrap()),
88 case(arr![false, Null], cbor!([false, null]).unwrap()),
89 case(arr![false, true], cbor!([false, true]).unwrap()),
90 case(arr![false, false], cbor!([false, false]).unwrap()),
91 case(arr![false, "foo"], cbor!([false, "foo"]).unwrap()),
92 case(arr![false, 123], cbor!([false, 123]).unwrap()),
93 case(arr![false, -123], cbor!([false, -123]).unwrap()),
94 case(arr![false, 1.23], cbor!([false, 1.23]).unwrap()),
95 case(arr![false, -1.23], cbor!([false, -1.23]).unwrap()),
96 case(arr![false, 2.5e+1], cbor!([false, 2.5e+1]).unwrap()),
97 case(arr![false, 2.5e+1], cbor!([false, 2.5e+1]).unwrap()),
98 case(arr![false, [1, 2]], cbor!([false, [1, 2]]).unwrap()),
99 case(arr![false, map! {1=>2,3=>4}], cbor!([false, {1=>2,3=>4}]).unwrap()),
100 case(arr!["foo", Null], cbor!(["foo", null]).unwrap()),
101 case(arr!["foo", true], cbor!(["foo", true]).unwrap()),
102 case(arr!["foo", false], cbor!(["foo", false]).unwrap()),
103 case(arr!["foo", "foo"], cbor!(["foo", "foo"]).unwrap()),
104 case(arr!["foo", 123], cbor!(["foo", 123]).unwrap()),
105 case(arr!["foo", -123], cbor!(["foo", -123]).unwrap()),
106 case(arr!["foo", 1.23], cbor!(["foo", 1.23]).unwrap()),
107 case(arr!["foo", -1.23], cbor!(["foo", -1.23]).unwrap()),
108 case(arr!["foo", 2.5e+1], cbor!(["foo", 2.5e+1]).unwrap()),
109 case(arr!["foo", 2.5e+1], cbor!(["foo", 2.5e+1]).unwrap()),
110 case(arr!["foo", [1, 2]], cbor!(["foo", [1, 2]]).unwrap()),
111 case(arr!["foo", map! {1=>2,3=>4}], cbor!(["foo", {1=>2,3=>4}]).unwrap()),
112 case(arr![123, Null], cbor!([123, null]).unwrap()),
113 case(arr![123, true], cbor!([123, true]).unwrap()),
114 case(arr![123, false], cbor!([123, false]).unwrap()),
115 case(arr![123, "foo"], cbor!([123, "foo"]).unwrap()),
116 case(arr![123, 123], cbor!([123, 123]).unwrap()),
117 case(arr![123, -123], cbor!([123, -123]).unwrap()),
118 case(arr![123, 1.23], cbor!([123, 1.23]).unwrap()),
119 case(arr![123, -1.23], cbor!([123, -1.23]).unwrap()),
120 case(arr![123, 2.5e+1], cbor!([123, 2.5e+1]).unwrap()),
121 case(arr![123, 2.5e+1], cbor!([123, 2.5e+1]).unwrap()),
122 case(arr![123, [1, 2]], cbor!([123, [1, 2]]).unwrap()),
123 case(arr![123, map! {1=>2,3=>4}], cbor!([123, {1=>2,3=>4}]).unwrap()),
124 case(arr![-123, Null], cbor!([-123, null]).unwrap()),
125 case(arr![-123, true], cbor!([-123, true]).unwrap()),
126 case(arr![-123, false], cbor!([-123, false]).unwrap()),
127 case(arr![-123, "foo"], cbor!([-123, "foo"]).unwrap()),
128 case(arr![-123, 123], cbor!([-123, 123]).unwrap()),
129 case(arr![-123, -123], cbor!([-123, -123]).unwrap()),
130 case(arr![-123, 1.23], cbor!([-123, 1.23]).unwrap()),
131 case(arr![-123, -1.23], cbor!([-123, -1.23]).unwrap()),
132 case(arr![-123, 2.5e+1], cbor!([-123, 2.5e+1]).unwrap()),
133 case(arr![-123, 2.5e+1], cbor!([-123, 2.5e+1]).unwrap()),
134 case(arr![-123, [1, 2]], cbor!([-123, [1, 2]]).unwrap()),
135 case(arr![-123, map! {1=>2,3=>4}], cbor!([-123, {1=>2,3=>4}]).unwrap()),
136 case(arr![1.23, Null], cbor!([1.23, null]).unwrap()),
137 case(arr![1.23, true], cbor!([1.23, true]).unwrap()),
138 case(arr![1.23, false], cbor!([1.23, false]).unwrap()),
139 case(arr![1.23, "foo"], cbor!([1.23, "foo"]).unwrap()),
140 case(arr![1.23, 123], cbor!([1.23, 123]).unwrap()),
141 case(arr![1.23, -123], cbor!([1.23, -123]).unwrap()),
142 case(arr![1.23, 1.23], cbor!([1.23, 1.23]).unwrap()),
143 case(arr![1.23, -1.23], cbor!([1.23, -1.23]).unwrap()),
144 case(arr![1.23, 2.5e+1], cbor!([1.23, 2.5e+1]).unwrap()),
145 case(arr![1.23, 2.5e+1], cbor!([1.23, 2.5e+1]).unwrap()),
146 case(arr![1.23, [1, 2]], cbor!([1.23, [1, 2]]).unwrap()),
147 case(arr![1.23, map! {1=>2,3=>4}], cbor!([1.23, {1=>2,3=>4}]).unwrap()),
148 case(arr![-1.23, Null], cbor!([-1.23, null]).unwrap()),
149 case(arr![-1.23, true], cbor!([-1.23, true]).unwrap()),
150 case(arr![-1.23, false], cbor!([-1.23, false]).unwrap()),
151 case(arr![-1.23, "foo"], cbor!([-1.23, "foo"]).unwrap()),
152 case(arr![-1.23, 123], cbor!([-1.23, 123]).unwrap()),
153 case(arr![-1.23, -123], cbor!([-1.23, -123]).unwrap()),
154 case(arr![-1.23, 1.23], cbor!([-1.23, 1.23]).unwrap()),
155 case(arr![-1.23, -1.23], cbor!([-1.23, -1.23]).unwrap()),
156 case(arr![-1.23, 2.5e+1], cbor!([-1.23, 2.5e+1]).unwrap()),
157 case(arr![-1.23, 2.5e+1], cbor!([-1.23, 2.5e+1]).unwrap()),
158 case(arr![-1.23, [1, 2]], cbor!([-1.23, [1, 2]]).unwrap()),
159 case(arr![-1.23, map! {1=>2,3=>4}], cbor!([-1.23, {1=>2,3=>4}]).unwrap()),
160 case(arr![2.5e+1, Null], cbor!([2.5e+1, null]).unwrap()),
161 case(arr![2.5e+1, true], cbor!([2.5e+1, true]).unwrap()),
162 case(arr![2.5e+1, false], cbor!([2.5e+1, false]).unwrap()),
163 case(arr![2.5e+1, "foo"], cbor!([2.5e+1, "foo"]).unwrap()),
164 case(arr![2.5e+1, 123], cbor!([2.5e+1, 123]).unwrap()),
165 case(arr![2.5e+1, -123], cbor!([2.5e+1, -123]).unwrap()),
166 case(arr![2.5e+1, 1.23], cbor!([2.5e+1, 1.23]).unwrap()),
167 case(arr![2.5e+1, -1.23], cbor!([2.5e+1, -1.23]).unwrap()),
168 case(arr![2.5e+1, 2.5e+1], cbor!([2.5e+1, 2.5e+1]).unwrap()),
169 case(arr![2.5e+1, 2.5e+1], cbor!([2.5e+1, 2.5e+1]).unwrap()),
170 case(arr![2.5e+1, [1, 2]], cbor!([2.5e+1, [1, 2]]).unwrap()),
171 case(arr![2.5e+1, map! {1=>2,3=>4}], cbor!([2.5e+1, {1=>2,3=>4}]).unwrap()),
172 case(arr![2.5e+1, Null], cbor!([2.5e+1, null]).unwrap()),
173 case(arr![2.5e+1, true], cbor!([2.5e+1, true]).unwrap()),
174 case(arr![2.5e+1, false], cbor!([2.5e+1, false]).unwrap()),
175 case(arr![2.5e+1, "foo"], cbor!([2.5e+1, "foo"]).unwrap()),
176 case(arr![2.5e+1, 123], cbor!([2.5e+1, 123]).unwrap()),
177 case(arr![2.5e+1, -123], cbor!([2.5e+1, -123]).unwrap()),
178 case(arr![2.5e+1, 1.23], cbor!([2.5e+1, 1.23]).unwrap()),
179 case(arr![2.5e+1, -1.23], cbor!([2.5e+1, -1.23]).unwrap()),
180 case(arr![2.5e+1, 2.5e+1], cbor!([2.5e+1, 2.5e+1]).unwrap()),
181 case(arr![2.5e+1, 2.5e+1], cbor!([2.5e+1, 2.5e+1]).unwrap()),
182 case(arr![2.5e+1, [1, 2]], cbor!([2.5e+1, [1, 2]]).unwrap()),
183 case(arr![2.5e+1, map! {1=>2,3=>4}], cbor!([2.5e+1, {1=>2,3=>4}]).unwrap()),
184 case(arr![[1, 2], Null], cbor!([[1, 2], null]).unwrap()),
185 case(arr![[1, 2], true], cbor!([[1, 2], true]).unwrap()),
186 case(arr![[1, 2], false], cbor!([[1, 2], false]).unwrap()),
187 case(arr![[1, 2], "foo"], cbor!([[1, 2], "foo"]).unwrap()),
188 case(arr![[1, 2], 123], cbor!([[1, 2], 123]).unwrap()),
189 case(arr![[1, 2], -123], cbor!([[1, 2], -123]).unwrap()),
190 case(arr![[1, 2], 1.23], cbor!([[1, 2], 1.23]).unwrap()),
191 case(arr![[1, 2], -1.23], cbor!([[1, 2], -1.23]).unwrap()),
192 case(arr![[1, 2], 2.5e+1], cbor!([[1, 2], 2.5e+1]).unwrap()),
193 case(arr![[1, 2], 2.5e+1], cbor!([[1, 2], 2.5e+1]).unwrap()),
194 case(arr![[1, 2], [1, 2]], cbor!([[1, 2], [1, 2]]).unwrap()),
195 case(arr![[1, 2], map! {1=>2,3=>4}], cbor!([[1, 2], {1=>2,3=>4}]).unwrap()),
196 case(arr![map! {1=>2,3=>4}, Null], cbor!([{1=>2,3=>4}, null]).unwrap()),
197 case(arr![map! {1=>2,3=>4}, true], cbor!([{1=>2,3=>4}, true]).unwrap()),
198 case(arr![map! {1=>2,3=>4}, false], cbor!([{1=>2,3=>4}, false]).unwrap()),
199 case(arr![map! {1=>2,3=>4}, "foo"], cbor!([{1=>2,3=>4}, "foo"]).unwrap()),
200 case(arr![map! {1=>2,3=>4}, 123], cbor!([{1=>2,3=>4}, 123]).unwrap()),
201 case(arr![map! {1=>2,3=>4}, -123], cbor!([{1=>2,3=>4}, -123]).unwrap()),
202 case(arr![map! {1=>2,3=>4}, 1.23], cbor!([{1=>2,3=>4}, 1.23]).unwrap()),
203 case(arr![map! {1=>2,3=>4}, -1.23], cbor!([{1=>2,3=>4}, -1.23]).unwrap()),
204 case(arr![map! {1=>2,3=>4}, 2.5e+1], cbor!([{1=>2,3=>4}, 2.5e+1]).unwrap()),
205 case(arr![map! {1=>2,3=>4}, 2.5e+1], cbor!([{1=>2,3=>4}, 2.5e+1]).unwrap()),
206 case(arr![map! {1=>2,3=>4}, [1, 2]], cbor!([{1=>2,3=>4}, [1, 2]]).unwrap()),
207 case(arr![map! {1=>2,3=>4}, map! {1=>2,3=>4}], cbor!([{1=>2,3=>4}, {1=>2,3=>4}]).unwrap()),
208
209 // Map formulations
210 case(map! {}, cbor!({}).unwrap()),
211 case(map! {Null => Null}, cbor!({ null => null }).unwrap()),
212 case(map! {Null => true}, cbor!({ null => true }).unwrap()),
213 case(map! {Null => false}, cbor!({ null => false }).unwrap()),
214 case(map! {Null => "foo"}, cbor!({ null => "foo" }).unwrap()),
215 case(map! {Null => 123}, cbor!({ null => 123 }).unwrap()),
216 case(map! {Null => -123}, cbor!({ null => -123 }).unwrap()),
217 case(map! {Null => 1.23}, cbor!({ null => 1.23 }).unwrap()),
218 case(map! {Null => -1.23}, cbor!({ null => -1.23 }).unwrap()),
219 case(map! {Null => 2.5e+1}, cbor!({ null => 2.5e+1 }).unwrap()),
220 case(map! {Null => 2.5e+1}, cbor!({ null => 2.5e+1 }).unwrap()),
221 case(map! {Null => [1, 2]}, cbor!({ null => [1, 2] }).unwrap()),
222 case(map! {Null => map! {1=>2,3=>4}}, cbor!({ null => {1=>2,3=>4} }).unwrap()),
223 case(map! {true => Null}, cbor!({ true => null }).unwrap()),
224 case(map! {true => true}, cbor!({ true => true }).unwrap()),
225 case(map! {true => false}, cbor!({ true => false }).unwrap()),
226 case(map! {true => "foo"}, cbor!({ true => "foo" }).unwrap()),
227 case(map! {true => 123}, cbor!({ true => 123 }).unwrap()),
228 case(map! {true => -123}, cbor!({ true => -123 }).unwrap()),
229 case(map! {true => 1.23}, cbor!({ true => 1.23 }).unwrap()),
230 case(map! {true => -1.23}, cbor!({ true => -1.23 }).unwrap()),
231 case(map! {true => 2.5e+1}, cbor!({ true => 2.5e+1 }).unwrap()),
232 case(map! {true => 2.5e+1}, cbor!({ true => 2.5e+1 }).unwrap()),
233 case(map! {true => [1, 2]}, cbor!({ true => [1, 2] }).unwrap()),
234 case(map! {true => map! {1=>2,3=>4}}, cbor!({ true => {1=>2,3=>4} }).unwrap()),
235 case(map! {false => Null}, cbor!({ false => null }).unwrap()),
236 case(map! {false => true}, cbor!({ false => true }).unwrap()),
237 case(map! {false => false}, cbor!({ false => false }).unwrap()),
238 case(map! {false => "foo"}, cbor!({ false => "foo" }).unwrap()),
239 case(map! {false => 123}, cbor!({ false => 123 }).unwrap()),
240 case(map! {false => -123}, cbor!({ false => -123 }).unwrap()),
241 case(map! {false => 1.23}, cbor!({ false => 1.23 }).unwrap()),
242 case(map! {false => -1.23}, cbor!({ false => -1.23 }).unwrap()),
243 case(map! {false => 2.5e+1}, cbor!({ false => 2.5e+1 }).unwrap()),
244 case(map! {false => 2.5e+1}, cbor!({ false => 2.5e+1 }).unwrap()),
245 case(map! {false => [1, 2]}, cbor!({ false => [1, 2] }).unwrap()),
246 case(map! {false => map! {1=>2,3=>4}}, cbor!({ false => {1=>2,3=>4} }).unwrap()),
247 case(map! {"foo" => Null}, cbor!({ "foo" => null }).unwrap()),
248 case(map! {"foo" => true}, cbor!({ "foo" => true }).unwrap()),
249 case(map! {"foo" => false}, cbor!({ "foo" => false }).unwrap()),
250 case(map! {"foo" => "foo"}, cbor!({ "foo" => "foo" }).unwrap()),
251 case(map! {"foo" => 123}, cbor!({ "foo" => 123 }).unwrap()),
252 case(map! {"foo" => -123}, cbor!({ "foo" => -123 }).unwrap()),
253 case(map! {"foo" => 1.23}, cbor!({ "foo" => 1.23 }).unwrap()),
254 case(map! {"foo" => -1.23}, cbor!({ "foo" => -1.23 }).unwrap()),
255 case(map! {"foo" => 2.5e+1}, cbor!({ "foo" => 2.5e+1 }).unwrap()),
256 case(map! {"foo" => 2.5e+1}, cbor!({ "foo" => 2.5e+1 }).unwrap()),
257 case(map! {"foo" => [1, 2]}, cbor!({ "foo" => [1, 2] }).unwrap()),
258 case(map! {"foo" => map! {1=>2,3=>4}}, cbor!({ "foo" => {1=>2,3=>4} }).unwrap()),
259 case(map! {123 => Null}, cbor!({ 123 => null }).unwrap()),
260 case(map! {123 => true}, cbor!({ 123 => true }).unwrap()),
261 case(map! {123 => false}, cbor!({ 123 => false }).unwrap()),
262 case(map! {123 => "foo"}, cbor!({ 123 => "foo" }).unwrap()),
263 case(map! {123 => 123}, cbor!({ 123 => 123 }).unwrap()),
264 case(map! {123 => -123}, cbor!({ 123 => -123 }).unwrap()),
265 case(map! {123 => 1.23}, cbor!({ 123 => 1.23 }).unwrap()),
266 case(map! {123 => -1.23}, cbor!({ 123 => -1.23 }).unwrap()),
267 case(map! {123 => 2.5e+1}, cbor!({ 123 => 2.5e+1 }).unwrap()),
268 case(map! {123 => 2.5e+1}, cbor!({ 123 => 2.5e+1 }).unwrap()),
269 case(map! {123 => [1, 2]}, cbor!({ 123 => [1, 2] }).unwrap()),
270 case(map! {123 => map! {1=>2,3=>4}}, cbor!({ 123 => {1=>2,3=>4} }).unwrap()),
271 case(map! {-123 => Null}, cbor!({ -123 => null }).unwrap()),
272 case(map! {-123 => true}, cbor!({ -123 => true }).unwrap()),
273 case(map! {-123 => false}, cbor!({ -123 => false }).unwrap()),
274 case(map! {-123 => "foo"}, cbor!({ -123 => "foo" }).unwrap()),
275 case(map! {-123 => 123}, cbor!({ -123 => 123 }).unwrap()),
276 case(map! {-123 => -123}, cbor!({ -123 => -123 }).unwrap()),
277 case(map! {-123 => 1.23}, cbor!({ -123 => 1.23 }).unwrap()),
278 case(map! {-123 => -1.23}, cbor!({ -123 => -1.23 }).unwrap()),
279 case(map! {-123 => 2.5e+1}, cbor!({ -123 => 2.5e+1 }).unwrap()),
280 case(map! {-123 => 2.5e+1}, cbor!({ -123 => 2.5e+1 }).unwrap()),
281 case(map! {-123 => [1, 2]}, cbor!({ -123 => [1, 2] }).unwrap()),
282 case(map! {-123 => map! {1=>2,3=>4}}, cbor!({ -123 => {1=>2,3=>4} }).unwrap()),
283 case(map! {1.23 => Null}, cbor!({ 1.23 => null }).unwrap()),
284 case(map! {1.23 => true}, cbor!({ 1.23 => true }).unwrap()),
285 case(map! {1.23 => false}, cbor!({ 1.23 => false }).unwrap()),
286 case(map! {1.23 => "foo"}, cbor!({ 1.23 => "foo" }).unwrap()),
287 case(map! {1.23 => 123}, cbor!({ 1.23 => 123 }).unwrap()),
288 case(map! {1.23 => -123}, cbor!({ 1.23 => -123 }).unwrap()),
289 case(map! {1.23 => 1.23}, cbor!({ 1.23 => 1.23 }).unwrap()),
290 case(map! {1.23 => -1.23}, cbor!({ 1.23 => -1.23 }).unwrap()),
291 case(map! {1.23 => 2.5e+1}, cbor!({ 1.23 => 2.5e+1 }).unwrap()),
292 case(map! {1.23 => 2.5e+1}, cbor!({ 1.23 => 2.5e+1 }).unwrap()),
293 case(map! {1.23 => [1, 2]}, cbor!({ 1.23 => [1, 2] }).unwrap()),
294 case(map! {1.23 => map! {1=>2,3=>4}}, cbor!({ 1.23 => {1=>2,3=>4} }).unwrap()),
295 case(map! {-1.23 => Null}, cbor!({ -1.23 => null }).unwrap()),
296 case(map! {-1.23 => true}, cbor!({ -1.23 => true }).unwrap()),
297 case(map! {-1.23 => false}, cbor!({ -1.23 => false }).unwrap()),
298 case(map! {-1.23 => "foo"}, cbor!({ -1.23 => "foo" }).unwrap()),
299 case(map! {-1.23 => 123}, cbor!({ -1.23 => 123 }).unwrap()),
300 case(map! {-1.23 => -123}, cbor!({ -1.23 => -123 }).unwrap()),
301 case(map! {-1.23 => 1.23}, cbor!({ -1.23 => 1.23 }).unwrap()),
302 case(map! {-1.23 => -1.23}, cbor!({ -1.23 => -1.23 }).unwrap()),
303 case(map! {-1.23 => 2.5e+1}, cbor!({ -1.23 => 2.5e+1 }).unwrap()),
304 case(map! {-1.23 => 2.5e+1}, cbor!({ -1.23 => 2.5e+1 }).unwrap()),
305 case(map! {-1.23 => [1, 2]}, cbor!({ -1.23 => [1, 2] }).unwrap()),
306 case(map! {-1.23 => map! {1=>2,3=>4}}, cbor!({ -1.23 => {1=>2,3=>4} }).unwrap()),
307 case(map! {2.5e+1 => Null}, cbor!({ 2.5e+1 => null }).unwrap()),
308 case(map! {2.5e+1 => true}, cbor!({ 2.5e+1 => true }).unwrap()),
309 case(map! {2.5e+1 => false}, cbor!({ 2.5e+1 => false }).unwrap()),
310 case(map! {2.5e+1 => "foo"}, cbor!({ 2.5e+1 => "foo" }).unwrap()),
311 case(map! {2.5e+1 => 123}, cbor!({ 2.5e+1 => 123 }).unwrap()),
312 case(map! {2.5e+1 => -123}, cbor!({ 2.5e+1 => -123 }).unwrap()),
313 case(map! {2.5e+1 => 1.23}, cbor!({ 2.5e+1 => 1.23 }).unwrap()),
314 case(map! {2.5e+1 => -1.23}, cbor!({ 2.5e+1 => -1.23 }).unwrap()),
315 case(map! {2.5e+1 => 2.5e+1}, cbor!({ 2.5e+1 => 2.5e+1 }).unwrap()),
316 case(map! {2.5e+1 => 2.5e+1}, cbor!({ 2.5e+1 => 2.5e+1 }).unwrap()),
317 case(map! {2.5e+1 => [1, 2]}, cbor!({ 2.5e+1 => [1, 2] }).unwrap()),
318 case(map! {2.5e+1 => map! {1=>2,3=>4}}, cbor!({ 2.5e+1 => {1=>2,3=>4} }).unwrap()),
319 case(map! {2.5e+1 => Null}, cbor!({ 2.5e+1 => null }).unwrap()),
320 case(map! {2.5e+1 => true}, cbor!({ 2.5e+1 => true }).unwrap()),
321 case(map! {2.5e+1 => false}, cbor!({ 2.5e+1 => false }).unwrap()),
322 case(map! {2.5e+1 => "foo"}, cbor!({ 2.5e+1 => "foo" }).unwrap()),
323 case(map! {2.5e+1 => 123}, cbor!({ 2.5e+1 => 123 }).unwrap()),
324 case(map! {2.5e+1 => -123}, cbor!({ 2.5e+1 => -123 }).unwrap()),
325 case(map! {2.5e+1 => 1.23}, cbor!({ 2.5e+1 => 1.23 }).unwrap()),
326 case(map! {2.5e+1 => -1.23}, cbor!({ 2.5e+1 => -1.23 }).unwrap()),
327 case(map! {2.5e+1 => 2.5e+1}, cbor!({ 2.5e+1 => 2.5e+1 }).unwrap()),
328 case(map! {2.5e+1 => 2.5e+1}, cbor!({ 2.5e+1 => 2.5e+1 }).unwrap()),
329 case(map! {2.5e+1 => [1, 2]}, cbor!({ 2.5e+1 => [1, 2] }).unwrap()),
330 case(map! {2.5e+1 => map! {1=>2,3=>4}}, cbor!({ 2.5e+1 => {1=>2,3=>4} }).unwrap()),
331 case(map! {[1, 2] => Null}, cbor!({ [1, 2] => null }).unwrap()),
332 case(map! {[1, 2] => true}, cbor!({ [1, 2] => true }).unwrap()),
333 case(map! {[1, 2] => false}, cbor!({ [1, 2] => false }).unwrap()),
334 case(map! {[1, 2] => "foo"}, cbor!({ [1, 2] => "foo" }).unwrap()),
335 case(map! {[1, 2] => 123}, cbor!({ [1, 2] => 123 }).unwrap()),
336 case(map! {[1, 2] => -123}, cbor!({ [1, 2] => -123 }).unwrap()),
337 case(map! {[1, 2] => 1.23}, cbor!({ [1, 2] => 1.23 }).unwrap()),
338 case(map! {[1, 2] => -1.23}, cbor!({ [1, 2] => -1.23 }).unwrap()),
339 case(map! {[1, 2] => 2.5e+1}, cbor!({ [1, 2] => 2.5e+1 }).unwrap()),
340 case(map! {[1, 2] => 2.5e+1}, cbor!({ [1, 2] => 2.5e+1 }).unwrap()),
341 case(map! {[1, 2] => [1, 2]}, cbor!({ [1, 2] => [1, 2] }).unwrap()),
342 case(map! {[1, 2] => map! {1=>2,3=>4}}, cbor!({ [1, 2] => {1=>2,3=>4} }).unwrap()),
343 case(map! {map! {1=>2,3=>4} => Null}, cbor!({ {1=>2,3=>4} => null }).unwrap()),
344 case(map! {map! {1=>2,3=>4} => true}, cbor!({ {1=>2,3=>4} => true }).unwrap()),
345 case(map! {map! {1=>2,3=>4} => false}, cbor!({ {1=>2,3=>4} => false }).unwrap()),
346 case(map! {map! {1=>2,3=>4} => "foo"}, cbor!({ {1=>2,3=>4} => "foo" }).unwrap()),
347 case(map! {map! {1=>2,3=>4} => 123}, cbor!({ {1=>2,3=>4} => 123 }).unwrap()),
348 case(map! {map! {1=>2,3=>4} => -123}, cbor!({ {1=>2,3=>4} => -123 }).unwrap()),
349 case(map! {map! {1=>2,3=>4} => 1.23}, cbor!({ {1=>2,3=>4} => 1.23 }).unwrap()),
350 case(map! {map! {1=>2,3=>4} => -1.23}, cbor!({ {1=>2,3=>4} => -1.23 }).unwrap()),
351 case(map! {map! {1=>2,3=>4} => 2.5e+1}, cbor!({ {1=>2,3=>4} => 2.5e+1 }).unwrap()),
352 case(map! {map! {1=>2,3=>4} => 2.5e+1}, cbor!({ {1=>2,3=>4} => 2.5e+1 }).unwrap()),
353 case(map! {map! {1=>2,3=>4} => [1, 2]}, cbor!({ {1=>2,3=>4} => [1, 2] }).unwrap()),
354 case(map! {map! {1=>2,3=>4} => map! {1=>2,3=>4}}, cbor!({ {1=>2,3=>4} => {1=>2,3=>4} }).unwrap()),
355)]
356fn test(answer: Value, question: Value) {
357 assert_eq!(answer, question);
358}
359