| 1 | use craterust-analyzer cargo zstd 0.13.3 crate/::streamrust-analyzer cargo zstd 0.13.3 stream/::readrust-analyzer cargo zstd 0.13.3 stream/read/::{Decoderrust-analyzer cargo zstd 0.13.3 stream/read/Decoder#, Encoderrust-analyzer cargo zstd 0.13.3 stream/read/Encoder#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#; |
| 3 | |
| 4 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 5 | fn test_error_handlingrust-analyzer cargo zstd 0.13.3 stream/read/tests/test_error_handling().() { |
| 6 | let invalid_input = b"Abcdefghabcdefgh"; |
| 7 | |
| 8 | let mut decoder = Decoderrust-analyzer cargo zstd 0.13.3 stream/read/Decoder#::newrust-analyzer cargo zstd 0.13.3 stream/read/impl#[`Decoder<'static, BufReader<R>>`]new().(&invalid_input[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/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 9 | let output = decoder.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 10 | |
| 11 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().(), true); |
| 12 | } |
| 13 | |
| 14 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 15 | fn test_cyclerust-analyzer cargo zstd 0.13.3 stream/read/tests/test_cycle().() { |
| 16 | let input = b"Abcdefghabcdefgh"; |
| 17 | |
| 18 | let mut encoder = Encoderrust-analyzer cargo zstd 0.13.3 stream/read/Encoder#::newrust-analyzer cargo zstd 0.13.3 stream/read/impl#[`Encoder<'static, BufReader<R>>`]new().(&input[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/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 19 | let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 20 | encoder.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 21 | |
| 22 | let mut decoder = Decoderrust-analyzer cargo zstd 0.13.3 stream/read/Decoder#::newrust-analyzer cargo zstd 0.13.3 stream/read/impl#[`Decoder<'static, BufReader<R>>`]new().(&buffer[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().(); |
| 23 | let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 24 | decoder.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 25 | |
| 26 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(input, &buffer[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 27 | } |