test: make MRMesh.ZlibCompressStats engine-agnostic#5978
Merged
Conversation
The test currently compares `stats.compressedSize` and `out.str().size()` against `sizeof( cRawLevel* )` / `sizeof( cWrappedLevel* )`. Those reference blobs were captured from stock zlib, and the exact compressed byte count drifts from one deflate implementation to another (stock zlib vs zlib-ng compat vs zlib-ng native vs libdeflate -- all lossless, but each picks its own block-split / Huffman / match-length heuristics). Once we swap any part of the compress path to a non-zlib engine, this assertion fails for reasons that have nothing to do with correctness. Replace with engine-agnostic assertions: - CRC matches the reference CRC of the input (decoder-defined, engine- independent). - Uncompressed size matches the input size (tautology that still guards against stats wiring regressions). - `stats.compressedSize == out.str().size()` -- API consistency between the stats block and the actual stream, regardless of engine. - `0 < stats.compressedSize < sizeof( cInput )` -- sanity: we produced a non-empty payload smaller than the input. Split out of #5959 so the test relaxation can land independently of the zlib-ng routing. Pure test change -- no source / build / CI impact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Grantim
approved these changes
Apr 24, 2026
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.
Summary
Relax
MRMesh.ZlibCompressStatsso it stops comparingstats.compressedSizeagainst the byte-exact size of thecRawLevel*/cWrappedLevel*reference blobs. Those blobs were captured from stock zlib, and the exact compressed byte count drifts from one deflate implementation to another — stock zlib, zlib-ng (native and compat), libdeflate, etc. all produce different (still-valid-DEFLATE) bytestreams for the same input and level, per RFC 1951's encoder latitude. The moment any part of the compress path is swapped to a non-zlib engine, this assertion fires for reasons that have nothing to do with correctness.What the new assertions actually check
stats.crc32 == expectedCrc— defined by the input, engine-independent.stats.uncompressedSize == sizeof( cInput )— guards stats wiring.stats.compressedSize == out.str().size()— API consistency: the stats block's claim matches the actual stream length, whichever engine produced it.0 < stats.compressedSize < sizeof( cInput )— sanity floor + ceiling: we produced a non-empty payload, and it's strictly smaller than the input.This preserves every property the test was actually trying to verify (CRC correctness, stats plumbing, that compression happened) while dropping the one that pinned correctness to one specific encoder's byte-level output.
Why a standalone PR
Split out of #5959 (route
MRZlibthrough zlib-ng). The zlib-ng PR needs this relaxation to pass, but the relaxation itself is orthogonal — anyone benchmarking libdeflate, zlib-ng-compat, etc. wants the same change. Landing it first keeps #5959 focused on the compressor routing and avoids a test-assertion change bundled into an ABI / CI PR.Scope
One file:
source/MRTest/MRZlibTests.cpp. No source/build/CI changes.🤖 Generated with Claude Code