-
Notifications
You must be signed in to change notification settings - Fork 187
Enable window_bits and gzip functions for zlib-rs backend #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+341
−119
Closed
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
598cf63
Enable window_bits and gzip functions for zlib-rs backend
Copilot b4993c4
refactor
Byron 816bd26
Add integration test for `zlib-rs` specifically to test exposed APIs.
Byron ebf510e
zlib-rs: support `set_dictionary` and `set_level`
folkertdev 92af1df
update zlib-rs to 0.5.4
folkertdev c0f1163
refactor - remove unnecessary newlines
Byron acc6d2c
Merge pull request #522 from folkertdev/zlib-rs-round-2
Byron 1d9e34d
Add "presence" tests for `set_dictionary` and `set_level`.
Byron f5bd992
Make `zlib-rs` specific test general so we validate availability of f…
Byron 924636d
Address Copilot review comments
Byron 2b49642
Bump patch level to prepare for release
Byron 0934d5f
Do not expose functions with `window_bits` in `miniz_oxide`.
Byron a06ead4
Bump `zlib-rs` to v0.5.5 for important bugfix.
Byron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| //! Validate that certain feature-gated functionality is still available. | ||
| use flate2::{Compress, Compression, Decompress, FlushCompress, FlushDecompress}; | ||
|
|
||
| #[test] | ||
| fn test_compress_new_with_window_bits() { | ||
| let string = "hello world".as_bytes(); | ||
|
|
||
| // Test with window_bits = 9 (minimum) | ||
| let mut encoded = Vec::with_capacity(1024); | ||
| let mut encoder = Compress::new_with_window_bits(Compression::default(), true, 9); | ||
| encoder | ||
| .compress_vec(string, &mut encoded, FlushCompress::Finish) | ||
| .unwrap(); | ||
| assert_ne!(encoded.len(), 0); | ||
|
|
||
| let mut decoder = Decompress::new_with_window_bits(true, 9); | ||
| let mut decoded = [0; 1024]; | ||
| decoder | ||
| .decompress(&encoded, &mut decoded, FlushDecompress::Finish) | ||
| .unwrap(); | ||
| assert_eq!(&decoded[..string.len()], string); | ||
|
|
||
| // Test with window_bits = 15 (maximum) | ||
| let mut encoded = Vec::with_capacity(1024); | ||
| let mut encoder = Compress::new_with_window_bits(Compression::default(), false, 15); | ||
| encoder | ||
| .compress_vec(string, &mut encoded, FlushCompress::Finish) | ||
| .unwrap(); | ||
| assert_ne!(encoded.len(), 0); | ||
|
|
||
| let mut decoder = Decompress::new_with_window_bits(false, 15); | ||
| let mut decoded = [0; 1024]; | ||
| decoder | ||
| .decompress(&encoded, &mut decoded, FlushDecompress::Finish) | ||
| .unwrap(); | ||
| assert_eq!(&decoded[..string.len()], string); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_decompress_new_gzip_window_bits() { | ||
| let string = "hello world".as_bytes(); | ||
|
|
||
| // Test with different window_bits values | ||
| for window_bits in [9, 12, 15] { | ||
| let mut encoded = Vec::with_capacity(1024); | ||
| let mut encoder = Compress::new_gzip(Compression::default(), window_bits); | ||
| encoder | ||
| .compress_vec(string, &mut encoded, FlushCompress::Finish) | ||
| .unwrap(); | ||
|
|
||
| let mut decoder = Decompress::new_gzip(window_bits); | ||
| let mut decoded = [0; 1024]; | ||
| decoder | ||
| .decompress(&encoded, &mut decoded, FlushDecompress::Finish) | ||
| .unwrap(); | ||
| assert_eq!( | ||
| &decoded[..string.len()], | ||
| string, | ||
| "Failed with window_bits={}", | ||
| window_bits | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "window_bits must be within 9 ..= 15")] | ||
| fn test_compress_new_with_window_bits_invalid_low() { | ||
| let _ = Compress::new_with_window_bits(Compression::default(), true, 8); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "window_bits must be within 9 ..= 15")] | ||
| fn test_compress_new_with_window_bits_invalid_high() { | ||
| let _ = Compress::new_with_window_bits(Compression::default(), true, 16); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "window_bits must be within 9 ..= 15")] | ||
| fn test_compress_new_gzip_invalid_low() { | ||
| let _ = Compress::new_gzip(Compression::default(), 8); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "window_bits must be within 9 ..= 15")] | ||
| fn test_compress_new_gzip_invalid_high() { | ||
| let _ = Compress::new_gzip(Compression::default(), 16); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.