Debian Codegraph @

tests/decompress_test.rs

raw symbols SCIP
1 // Copyright (c) 2023 Harry [Majored] [[email protected]]
2 // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE)
3
4 use tokiorust-analyzer cargo tokio 1.25.0 crate/::iorust-analyzer cargo tokio 1.25.0 io/::BufReaderrust-analyzer cargo tokio 1.25.0 io/util/buf_reader/BufReader#;
5 use tokio_utilrust-analyzer cargo tokio-util 0.7.4 crate/::compatrust-analyzer cargo tokio-util 0.7.4 compat/::TokioAsyncReadCompatExtrust-analyzer cargo tokio-util 0.7.4 compat/TokioAsyncReadCompatExt#;
6
7 mod commonrust-analyzer cargo async_zip 0.0.18 common/;
8
9 const ZSTD_ZIP_FILErust-analyzer cargo async_zip 0.0.18 ZSTD_ZIP_FILE.: &str = "tests/test_inputs/sample_data.zstd.zip";
10 const DEFLATE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 DEFLATE_ZIP_FILE.: &str = "tests/test_inputs/sample_data.deflate.zip";
11 const STORE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 STORE_ZIP_FILE.: &str = "tests/test_inputs/sample_data.store.zip";
12 const UTF8_EXTRA_ZIP_FILErust-analyzer cargo async_zip 0.0.18 UTF8_EXTRA_ZIP_FILE.: &str = "tests/test_inputs/sample_data_utf8_extra.zip";
13
14 #[cfg(feature = "zstd")]
15 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
16 async fn decompress_zstd_zip_seekrust-analyzer cargo async_zip 0.0.18 decompress_zstd_zip_seek().() {
17 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_seekrust-analyzer cargo async_zip 0.0.18 common/check_decompress_seek().(ZSTD_ZIP_FILErust-analyzer cargo async_zip 0.0.18 ZSTD_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
18 }
19
20 #[cfg(feature = "deflate")]
21 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
22 async fn decompress_deflate_zip_seekrust-analyzer cargo async_zip 0.0.18 decompress_deflate_zip_seek().() {
23 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_seekrust-analyzer cargo async_zip 0.0.18 common/check_decompress_seek().(DEFLATE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 DEFLATE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
24 }
25
26 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
27 async fn check_empty_zip_seekrust-analyzer cargo async_zip 0.0.18 check_empty_zip_seek().() {
28 let mut data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = 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().();
29 async_ziprust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::writerust-analyzer cargo async_zip 0.0.18 base/write/::ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(futuresrust-analyzer cargo futures 0.3.25 crate/::iorust-analyzer cargo futures-util 0.3.25 io/::Cursorrust-analyzer cargo futures-util 0.3.25 io/cursor/Cursor#::newrust-analyzer cargo futures-util 0.3.25 io/cursor/impl#[`Cursor<T>`]new().(&mut data)).closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
30 async_ziprust-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/::seekrust-analyzer cargo async_zip 0.0.18 base/read/seek/::ZipFileReaderrust-analyzer cargo async_zip 0.0.18 base/read/seek/ZipFileReader#::newrust-analyzer cargo async_zip 0.0.18 base/read/seek/impl#[`ZipFileReader<R>`]new().(futuresrust-analyzer cargo futures 0.3.25 crate/::iorust-analyzer cargo futures-util 0.3.25 io/::Cursorrust-analyzer cargo futures-util 0.3.25 io/cursor/Cursor#::newrust-analyzer cargo futures-util 0.3.25 io/cursor/impl#[`Cursor<T>`]new().(&data)).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
31 }
32
33 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
34 async fn decompress_store_zip_seekrust-analyzer cargo async_zip 0.0.18 decompress_store_zip_seek().() {
35 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_seekrust-analyzer cargo async_zip 0.0.18 common/check_decompress_seek().(STORE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 STORE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
36 }
37
38 #[cfg(feature = "zstd")]
39 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
40 async fn decompress_zstd_zip_memrust-analyzer cargo async_zip 0.0.18 decompress_zstd_zip_mem().() {
41 let content = tokiorust-analyzer cargo tokio 1.25.0 crate/::fsrust-analyzer cargo tokio 1.25.0 fs/::readrust-analyzer cargo tokio 1.25.0 fs/read/read().(ZSTD_ZIP_FILErust-analyzer cargo async_zip 0.0.18 ZSTD_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
42 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_memrust-analyzer cargo async_zip 0.0.18 common/check_decompress_mem().(content).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
43 }
44
45 #[cfg(feature = "deflate")]
46 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
47 async fn decompress_deflate_zip_memrust-analyzer cargo async_zip 0.0.18 decompress_deflate_zip_mem().() {
48 let content = tokiorust-analyzer cargo tokio 1.25.0 crate/::fsrust-analyzer cargo tokio 1.25.0 fs/::readrust-analyzer cargo tokio 1.25.0 fs/read/read().(DEFLATE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 DEFLATE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
49 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_memrust-analyzer cargo async_zip 0.0.18 common/check_decompress_mem().(content).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
50 }
51
52 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
53 async fn decompress_store_zip_memrust-analyzer cargo async_zip 0.0.18 decompress_store_zip_mem().() {
54 let content = tokiorust-analyzer cargo tokio 1.25.0 crate/::fsrust-analyzer cargo tokio 1.25.0 fs/::readrust-analyzer cargo tokio 1.25.0 fs/read/read().(STORE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 STORE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
55 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_memrust-analyzer cargo async_zip 0.0.18 common/check_decompress_mem().(content).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
56 }
57
58 #[cfg(feature = "zstd")]
59 #[cfg(feature = "tokio-fs")]
60 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
61 async fn decompress_zstd_zip_fsrust-analyzer cargo async_zip 0.0.18 decompress_zstd_zip_fs().() {
62 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_fsrust-analyzer cargo async_zip 0.0.18 common/check_decompress_fs().(ZSTD_ZIP_FILErust-analyzer cargo async_zip 0.0.18 ZSTD_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
63 }
64
65 #[cfg(feature = "deflate")]
66 #[cfg(feature = "tokio-fs")]
67 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
68 async fn decompress_deflate_zip_fsrust-analyzer cargo async_zip 0.0.18 decompress_deflate_zip_fs().() {
69 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_fsrust-analyzer cargo async_zip 0.0.18 common/check_decompress_fs().(DEFLATE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 DEFLATE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
70 }
71
72 #[cfg(feature = "tokio-fs")]
73 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
74 async fn decompress_store_zip_fsrust-analyzer cargo async_zip 0.0.18 decompress_store_zip_fs().() {
75 commonrust-analyzer cargo async_zip 0.0.18 common/::check_decompress_fsrust-analyzer cargo async_zip 0.0.18 common/check_decompress_fs().(STORE_ZIP_FILErust-analyzer cargo async_zip 0.0.18 STORE_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
76 }
77
78 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
79 async fn decompress_zip_with_utf8_extrarust-analyzer cargo async_zip 0.0.18 decompress_zip_with_utf8_extra().() {
80 let file = BufReaderrust-analyzer cargo tokio 1.25.0 io/util/buf_reader/BufReader#::newrust-analyzer cargo tokio 1.25.0 io/util/buf_reader/impl#[`BufReader<R>`]new().(tokiorust-analyzer cargo tokio 1.25.0 crate/::fsrust-analyzer cargo tokio 1.25.0 fs/::Filerust-analyzer cargo tokio 1.25.0 fs/file/File#::openrust-analyzer cargo tokio 1.25.0 fs/file/impl#[File]open().(UTF8_EXTRA_ZIP_FILErust-analyzer cargo async_zip 0.0.18 UTF8_EXTRA_ZIP_FILE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
81 let mut file_compat = file.compatrust-analyzer cargo tokio-util 0.7.4 compat/TokioAsyncReadCompatExt#compat().();
82 let zip = async_ziprust-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/::seekrust-analyzer cargo async_zip 0.0.18 base/read/seek/::ZipFileReaderrust-analyzer cargo async_zip 0.0.18 base/read/seek/ZipFileReader#::newrust-analyzer cargo async_zip 0.0.18 base/read/seek/impl#[`ZipFileReader<R>`]new().(&mut file_compat).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
83 let zip_entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = zip.filerust-analyzer cargo async_zip 0.0.18 base/read/seek/impl#[`ZipFileReader<R>`]file().().entriesrust-analyzer cargo async_zip 0.0.18 file/impl#[ZipFile]entries().().to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
84 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip_entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
85 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..header_sizerust-analyzer cargo async_zip 0.0.18 entry/impl#[StoredZipEntry]header_size().(), 93);
86 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..filenamerust-analyzer cargo async_zip 0.0.18 entry/impl#[ZipEntry]filename().().as_strrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]as_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "\u{4E2D}\u{6587}.txt");
87 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..filenamerust-analyzer cargo async_zip 0.0.18 entry/impl#[ZipEntry]filename().().alternativerust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]alternative().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b"\xD6\xD0\xCe\xC4.txt".as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()));
88 }