| 1 | // Copyright (c) 2022 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::compressedrust-analyzer cargo async_zip 0.0.18 base/read/io/compressed/::CompressedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/compressed/CompressedReader#; |
| 5 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#; |
| 6 | |
| 7 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(stored_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/stored_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#, "foo bar", "foo bar"); |
| 8 | |
| 9 | #[cfg(feature = "deflate")] |
| 10 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(deflate_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/deflate_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Deflaterust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Deflate#, "foo bar", include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("deflate.data")); |
| 11 | |
| 12 | #[cfg(feature = "bzip2")] |
| 13 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(bz_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/bz_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Bzrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Bz#, "foo bar", include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("bzip2.data")); |
| 14 | |
| 15 | #[cfg(feature = "lzma")] |
| 16 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(lzma_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/lzma_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Lzmarust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Lzma#, "foo bar", include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("lzma.data")); |
| 17 | |
| 18 | #[cfg(feature = "zstd")] |
| 19 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(zstd_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/zstd_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Zstdrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Zstd#, "foo bar", include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("zstd.data")); |
| 20 | |
| 21 | #[cfg(feature = "xz")] |
| 22 | compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!!(xz_testrust-analyzer cargo async_zip 0.0.18 tests/read/compression/xz_test()., Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Xzrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Xz#, "foo bar", include_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_bytes!!("xz.data")); |
| 23 | |
| 24 | /// A helper macro for generating a CompressedReader test using a specific compression method. |
| 25 | macro_rules! compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper! { |
| 26 | ($name:ident, $type:expr, $data_raw:expr, $data:expr) => { |
| 27 | #[cfg(test)] |
| 28 | #[tokio::test] |
| 29 | async fn $name() { |
| 30 | use futures_lite::io::{AsyncReadExt, Cursor}; |
| 31 | |
| 32 | let data = $data; |
| 33 | let data_raw = $data_raw; |
| 34 | |
| 35 | let cursor = Cursor::new(data); |
| 36 | let mut reader = CompressedReader::new(cursor, $type); |
| 37 | |
| 38 | let mut read_data = String::new(); |
| 39 | reader.read_to_string(&mut read_data).await.expect("read into CompressedReader failed"); |
| 40 | |
| 41 | assert_eq!(read_data, data_raw); |
| 42 | } |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | use compressed_test_helperrust-analyzer cargo async_zip 0.0.18 tests/read/compression/compressed_test_helper!; |