Repository navigation
Rust library test coverage - #32
Merged
Merged
Conversation
This commit adds comprehensive unit tests across all major modules: JPEG encoding tests: - Huffman coding: build_code_lengths, build_bits_vals, build_code_table, optimized_from_counts, category, encode_value, encode_block - Progressive encoding: encode_dc_first/refine, encode_ac_first/refine, flush_eob_run, ScanSpec, progressive scripts - Trellis quantization: generate_candidates, rate estimation functions, adaptive quality boundaries, custom lambda values - Quantization tables: quality levels, table formats, zigzag reordering PNG encoding tests: - Filter module: all filter types, adaptive strategies, paeth predictor, wrapping arithmetic, high entropy detection, AdaptiveScratch - Palette functions: ColorBox operations, median_cut_palette, PaletteLut lookup, analyze_rgba, all_gray_rgb - Bit depth reduction (existing tests remain) Compression tests: - LZ77: CostModel variations, boundary conditions, determinism, optimal vs greedy parsing, hash collisions - DEFLATE: rle_code_lengths, reverse_bits, length/distance codes, all compression levels, Deflater reuse, symbol counting - Huffman: canonical code generation, Kraft inequality verification, unique code verification, fixed code caching Bug fixes discovered through testing: - Fix apply_filters to use modified strategy variable instead of original options.filter_strategy (fixes small image Sub optimization) - Remove overly aggressive high-entropy detection that was causing compression regressions (detection based only on first row was insufficient for determining optimal strategy for entire image) Test count increased from ~300 to 386 unit tests, all passing.
|
Cursor Agent can help with this pull request. Just |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…report - Removed unnecessary "Additional coverage tests" section comments from compress/deflate.rs, compress/huffman.rs, and compress/lz77.rs - Updated docs/codebase-size-comparison.md with new statistics: - Total Rust LOC: 16,340 → 18,788 - Core Code: 8,674 → 7,893 LOC - Test Code: 5,766 → 8,967 LOC (35.3% → 47.7%) - Test functions: 335 → 507 - LOC per test: 46 → 37 - Files with colocated tests: 18 → 21 - SIMD LOC: 1,319 → 1,594 - comprs now has the highest test ratio (47.7%) among all compared libraries
leerob
marked this pull request as ready for review
December 25, 2025 22:55
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add ~86 new unit tests across JPEG, PNG, and compression modules, fixing two bugs, to significantly improve Rust library test coverage and reliability.
This PR addresses the task of significantly improving test coverage. During this process, two bugs were identified and fixed:
png/filter.rs,apply_filtersincorrectly usedoptions.filter_strategyinstead of the locally modifiedstrategyvariable, breaking a small image optimization.png/filter.rswas removed as it was insufficient and caused compression regressions.These fixes, alongside the new tests, enhance the library's robustness.
Note
Significantly increases test coverage and fixes a PNG filtering bug, with documentation updated to reflect new LOC and coverage numbers.
src/compress/{deflate,lz77,huffman}.rs,src/jpeg/{huffman,progressive,quantize,trellis}.rs, andsrc/png/{filter,mod}.rs(edge cases, determinism, code-length RLE, canonical codes, AC/DC progressive scans, quantization tables, trellis behavior, palette/median-cut utilities)png/filter.rsapply_filtersto use localstrategy(restores small-image optimization) and remove first-row high-entropy shortcut;is_high_entropy_rowretained but unuseddocs/codebase-size-comparison.mdwith new totals (core LOC 7,893; tests 8,967; 47.7% test ratio; 79.2% coverage), SIMD LOC, rankings, and breakdownsWritten by Cursor Bugbot for commit 2fb3e1c. This will update automatically on new commits. Configure here.