Repository navigation
test(cpp): cover the ALP decoder API - #1121
Merged
Merged
Conversation
Exercise AlpDecoderBase directly instead of only the page-level AlpEncodePage/AlpDecodePage path: single-value reads, batch reads with capacity/null/remaining limits, skip clamping, type-mismatch returns for every typed entry point, valid empty pages, malformed pages, reset and decoder reuse, and the wrapped and copied byte-stream paths. alp_decoder.h: 47% -> 97.6% line coverage, all 44 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
The ALP decoder's page-level codec was covered by
alp_codec_test.cc, but theAlpDecoderBaseAPI used by the read path had 47% line coverage and 23 never-executed functions (single-value reads, skip, every type-mismatch return).cpp/test/encoding/alp_decoder_api_test.ccnow covers, forFloatAlpDecoderandDoubleAlpDecoder:read_float/read_doubleand exhaustion withE_NO_MORE_DATAread_batch_*with capacity smaller than, larger than, and equal to the remaining values, pluscapacity <= 0andout == nullptrskip_*clamping: zero/negative counts, partial skips, skipping past the end, and skipping before/after readsread_boolean/int32/int64/float/double/String, batch and skip)value_count == 0), malformed pages (E_DECODE_ERR), and the post-failure statereset()reuse with a different page,destroy(),owns_resources()ByteStreamCoverage of
alp_decoder.h: 47.2% -> 97.6% lines (124/127), 44/44 functions. The three remaining lines are defensive branches that need a >4 GiB stream or a failing stream read, so they are not unit-testable without mocking the allocator.Test plan
./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON(Java, C++, Python; 1663 C++ tests passed)./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON(1664 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