Repository navigation
test(cpp): cover the decoder batch and exact-read contracts - #1135
Merged
ColinLeeo merged 1 commit intoNov 20, 2026
Merged
Conversation
Add a fake Decoder that implements only the abstract interface so the base-class helpers can be exercised directly: default read_batch_* and skip_* behaviour (capacity limits, exhaustion, error propagation), read_exact_*/skip_exact_* (exact counts, insufficient data, invalid arguments, corrupt batch counts), the default block hooks, and destroy/owns_resources. decoder.h: 60.9% -> 87.2% line coverage, 30/30 functions.
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
encoding/decoder.his the contract layer every codec derives from, but its base-class helpers had 60.9% line coverage because each concrete decoder overrides most entry points and the defaults are only used by a few codecs.cpp/test/encoding/decoder_contract_test.ccadds a fakeDecoderthat implements only the abstract interface, so the shared helpers run directly:read_batch_int32/int64/float/double: capacity limits, exhaustion, and read-error propagationskip_int32/int64/float/double: clamping at end, zero/absent skips, and error propagationread_exact_*/skip_exact_*: exact counts, the batch-then-single fallback, insufficient data, invalid arguments, and corrupt batch counts (E_TSFILE_CORRUPTED)peek_next_block_range_int64,skip_peeked_block_int64),destroy(),owns_resources()andreset()reuseCoverage of
decoder.h: 60.9% -> 87.2% lines, 30/30 functions. The remaining lines are the float/double exact wrappers and template lines that gcov attributes to the calling translation units.Test plan
./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON(Java, C++, Python; 1866 C++ tests passed)./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON(1867 tests, 0 failed; macOS run used the Xcode 26.6 toolchain withASAN_OPTIONS=detect_container_overflow=0for the uninstrumented ANTLR runtime)./mvnw spotless:check -P with-java,with-python