]>
git.proxmox.com Git - rustc.git/blob - vendor/ciborium/tests/recursion.rs
1 // SPDX-License-Identifier: Apache-2.0
3 //! This test validates that we don't get stack overflows.
5 //! If container types cause recursion, then a long list of prefixes which
6 //! indicate nested container types could cause the stack to overflow. We
7 //! test each of these types here to ensure there is no stack overflow.
10 de
::{from_reader, Error}
,
16 let bytes
= [0x9f; 128 * 1024];
17 match from_reader
::<Value
, _
>(&bytes
[..]).unwrap_err() {
18 Error
::RecursionLimitExceeded
=> (),
19 e
=> panic
!("incorrect error: {:?}", e
),
25 let bytes
= [0xbf; 128 * 1024];
26 match from_reader
::<Value
, _
>(&bytes
[..]).unwrap_err() {
27 Error
::RecursionLimitExceeded
=> (),
28 e
=> panic
!("incorrect error: {:?}", e
),
34 let bytes
= [0x5f; 128 * 1024];
35 match from_reader
::<Value
, _
>(&bytes
[..]).unwrap_err() {
37 e
=> panic
!("incorrect error: {:?}", e
),
43 let bytes
= [0x7f; 128 * 1024];
44 match from_reader
::<Value
, _
>(&bytes
[..]).unwrap_err() {
46 e
=> panic
!("incorrect error: {:?}", e
),