Lines Matching refs:bytes

6 fn test_decoder(bytes: Vec<u8>, expected: CborType) {  in test_decoder()
7 let result = decode(&bytes); in test_decoder()
12 fn test_decoder_error(bytes: Vec<u8>, expected_error: CborError) { in test_decoder_error()
13 let result = decode(&bytes); in test_decoder_error()
18 fn test_integer(bytes: Vec<u8>, expected: u64) { in test_integer()
19 let decoded = decode(&bytes).unwrap(); in test_integer()
26 fn test_integer_all(bytes: Vec<u8>, expected_value: u64) { in test_integer_all()
28 test_decoder(bytes.clone(), expected); in test_integer_all()
29 test_integer(bytes, expected_value); in test_integer_all()
34 let bytes: Vec<u8> = vec![0x00]; in test_integer_objects() localVariable
35 test_integer_all(bytes, 0); in test_integer_objects()
37 let bytes = vec![0x01]; in test_integer_objects() localVariable
38 test_integer_all(bytes, 1); in test_integer_objects()
40 let bytes = vec![0x0A]; in test_integer_objects() localVariable
41 test_integer_all(bytes, 10); in test_integer_objects()
43 let bytes = vec![0x17]; in test_integer_objects() localVariable
44 test_integer_all(bytes, 23); in test_integer_objects()
46 let bytes = vec![0x18, 0x18]; in test_integer_objects() localVariable
47 test_integer_all(bytes, 24); in test_integer_objects()
49 let bytes = vec![0x18, 0x19]; in test_integer_objects() localVariable
50 test_integer_all(bytes, 25); in test_integer_objects()
52 let bytes = vec![0x18, 0x64]; in test_integer_objects() localVariable
53 test_integer_all(bytes, 100); in test_integer_objects()
55 let bytes = vec![0x19, 0x03, 0xe8]; in test_integer_objects() localVariable
56 test_integer_all(bytes, 1000); in test_integer_objects()
58 let bytes = vec![0x1a, 0x00, 0x0f, 0x42, 0x40]; in test_integer_objects() localVariable
59 test_integer_all(bytes, 1000000); in test_integer_objects()
61 let bytes = vec![0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00]; in test_integer_objects() localVariable
62 test_integer_all(bytes, 1000000000000); in test_integer_objects()
64 let bytes = vec![0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]; in test_integer_objects() localVariable
65 test_integer_all(bytes, 18446744073709551615); in test_integer_objects()
69 fn test_tag(bytes: Vec<u8>, expected_tag: u64, expected_value: CborType) { in test_tag()
70 let decoded = decode(&bytes).unwrap(); in test_tag()
82 let bytes: Vec<u8> = vec![0xD2, 0x02]; in test_tagged_objects() localVariable
86 test_decoder(bytes.clone(), expected); in test_tagged_objects()
87 test_tag(bytes, expected_tag_value, expected_value); in test_tagged_objects()
94 let bytes: Vec<u8> = vec![0x80]; in test_arrays() localVariable
96 test_decoder(bytes, expected); in test_arrays()
99 let bytes: Vec<u8> = vec![0x83, 0x01, 0x02, 0x03]; in test_arrays() localVariable
106 test_decoder(bytes, expected); in test_arrays()
109 let bytes: Vec<u8> = vec![0x83, 0x01, 0x82, 0x02, 0x03, 0x82, 0x04, 0x05]; in test_arrays() localVariable
118 test_decoder(bytes, expected); in test_arrays()
121 let bytes: Vec<u8> = vec![0x83, 0x01, 0x81, 0x81, 0x81, 0x81, 0x01, 0x81, 0x02]; in test_arrays() localVariable
132 test_decoder(bytes, expected); in test_arrays()
134 let bytes: Vec<u8> = vec![0x98, 0x1A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, in test_arrays() localVariable
175 test_decoder(bytes, expected); in test_arrays()
180 let bytes: Vec<u8> = vec![0x20]; in test_signed_integer() localVariable
182 test_decoder(bytes, expected); in test_signed_integer()
184 let bytes = vec![0x29]; in test_signed_integer() localVariable
186 test_decoder(bytes, expected); in test_signed_integer()
188 let bytes = vec![0x38, 0x63]; in test_signed_integer() localVariable
190 test_decoder(bytes, expected); in test_signed_integer()
192 let bytes = vec![0x39, 0x03, 0xe7]; in test_signed_integer() localVariable
194 test_decoder(bytes, expected); in test_signed_integer()
196 let bytes = vec![0x39, 0x27, 0x0F]; in test_signed_integer() localVariable
198 test_decoder(bytes, expected); in test_signed_integer()
200 let bytes = vec![0x3A, 0x00, 0x01, 0x86, 0x9F]; in test_signed_integer() localVariable
202 test_decoder(bytes, expected); in test_signed_integer()
204 let bytes = vec![0x3B, 0x00, 0x00, 0x00, 0xE8, 0xD4, 0xA5, 0x0F, 0xFF]; in test_signed_integer() localVariable
206 test_decoder(bytes, expected); in test_signed_integer()
211 let bytes: Vec<u8> = vec![0x40]; in test_byte_strings() localVariable
213 test_decoder(bytes, expected); in test_byte_strings()
216 let bytes: Vec<u8> = vec![0x44, 0x01, 0x02, 0x03, 0x04]; in test_byte_strings() localVariable
218 test_decoder(bytes, expected); in test_byte_strings()
221 let bytes: Vec<u8> = vec![ in test_byte_strings() localVariable
229 test_decoder(bytes, expected); in test_byte_strings()
231 let bytes: Vec<u8> = vec![ in test_byte_strings() localVariable
272 test_decoder(bytes, expected); in test_byte_strings()
278 let bytes: Vec<u8> = vec![0xa0]; in test_maps() localVariable
280 test_decoder(bytes, CborType::Map(expected)); in test_maps()
283 let bytes: Vec<u8> = vec![0xa2, 0x01, 0x02, 0x03, 0x04]; in test_maps() localVariable
287 test_decoder(bytes, CborType::Map(expected)); in test_maps()
309 let bytes: Vec<u8> = vec![0xa4, 0x01, 0x02, 0x02, 0x03, 0x01, 0x03, 0x04, 0x04]; in test_map_duplicate_keys() localVariable
310 test_decoder_error(bytes, CborError::DuplicateMapKey); in test_map_duplicate_keys()
315 let bytes: Vec<u8> = vec![0xc0]; in test_tag_with_no_value() localVariable
316 test_decoder_error(bytes, CborError::TruncatedInput); in test_tag_with_no_value()
321 let bytes: Vec<u8> = vec![0x19, 0x03]; in test_truncated_int() localVariable
322 test_decoder_error(bytes, CborError::TruncatedInput); in test_truncated_int()
327 let bytes: Vec<u8> = vec![0x83, 0x01, 0x02]; in test_truncated_array() localVariable
328 test_decoder_error(bytes, CborError::TruncatedInput); in test_truncated_array()
333 let bytes: Vec<u8> = vec![0xa2, 0x01, 0x02, 0x00]; in test_truncated_map() localVariable
334 test_decoder_error(bytes, CborError::TruncatedInput); in test_truncated_map()
339 let bytes: Vec<u8> = vec![0x1c]; in test_malformed_integer() localVariable
340 test_decoder_error(bytes, CborError::MalformedInput); in test_malformed_integer()
345 let bytes = vec![0x3b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]; in test_signed_integer_too_large() localVariable
346 test_decoder_error(bytes, CborError::InputValueOutOfRange); in test_signed_integer_too_large()
351 let bytes = vec![0xf6]; in test_null() localVariable
352 test_decoder(bytes, CborType::Null); in test_null()
357 let bytes = vec![0x82, 0xf6, 0xf6]; in test_null_in_array() localVariable
358 test_decoder(bytes, CborType::Array(vec![CborType::Null, CborType::Null])); in test_null_in_array()
365 let bytes = vec![0xe0 | i]; in test_major_type_7() localVariable
366 test_decoder_error(bytes, CborError::UnsupportedType); in test_major_type_7()
375 let mut bytes = vec![0x5A, 0x08, 0x00, 0x00, 0x00]; in test_large_input() localVariable
376 bytes.extend_from_slice(&array); in test_large_input()
377 test_decoder(bytes, expected); in test_large_input()
383 let mut bytes = vec![0x5A, 0x08, 0x00, 0x00, 0x01]; in test_too_large_input() localVariable
384 bytes.extend_from_slice(&array); in test_too_large_input()
385 test_decoder_error(bytes, CborError::InputTooLarge); in test_too_large_input()
391 let bytes = vec![0x60]; in test_invalid_input() localVariable
392 test_decoder_error(bytes, CborError::UnsupportedType); in test_invalid_input()
397 let mut bytes: Vec<u8> = Vec::new(); in test_avoid_stack_exhaustion_with_arrays() localVariable
401 bytes.push(0b1000_0001); in test_avoid_stack_exhaustion_with_arrays()
403 bytes.push(0); in test_avoid_stack_exhaustion_with_arrays()
404 test_decoder_error(bytes, CborError::MalformedInput); in test_avoid_stack_exhaustion_with_arrays()
409 let mut bytes: Vec<u8> = Vec::new(); in test_avoid_stack_exhaustion_with_maps_1() localVariable
413 bytes.push(0b1010_0001); in test_avoid_stack_exhaustion_with_maps_1()
414 bytes.push(0); in test_avoid_stack_exhaustion_with_maps_1()
416 bytes.push(0b1010_0000); in test_avoid_stack_exhaustion_with_maps_1()
417 test_decoder_error(bytes, CborError::MalformedInput); in test_avoid_stack_exhaustion_with_maps_1()
422 let mut bytes: Vec<u8> = Vec::new(); in test_avoid_stack_exhaustion_with_maps_2() localVariable
426 bytes.push(0b1010_0001); in test_avoid_stack_exhaustion_with_maps_2()
428 bytes.push(0b1010_0000); in test_avoid_stack_exhaustion_with_maps_2()
430 bytes.push(0); in test_avoid_stack_exhaustion_with_maps_2()
432 test_decoder_error(bytes, CborError::MalformedInput); in test_avoid_stack_exhaustion_with_maps_2()
437 let mut bytes: Vec<u8> = Vec::new(); in test_avoid_stack_exhaustion_with_tags() localVariable
441 bytes.push(0b1100_0110); in test_avoid_stack_exhaustion_with_tags()
443 bytes.push(0); in test_avoid_stack_exhaustion_with_tags()
444 test_decoder_error(bytes, CborError::MalformedInput); in test_avoid_stack_exhaustion_with_tags()