Add parameterized tests covering all ASCII-optimization exit paths in CBORParser#691
Merged
Merged
Conversation
… CBORParser These test were missing from the original pull request FasterXML#568, and caused that at least three bugs were found that have been already missed. Adding now to ensure that no regressions are introduced. Each test generates a string with a controlled ASCII prefix followed by unicode, encodes it to CBOR, then decodes via both byte[] and throttled InputStream to exercise both _finishShortText and _finishLongTextAscii/_finishChunkedTextAscii paths.
Member
|
Thank you, @sugmanue. Will get this reviewed, merged. |
cowtowncoder
approved these changes
May 12, 2026
Member
cowtowncoder
left a comment
There was a problem hiding this comment.
LGTM (made some minor clean up)
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
These test were missing from the original pull request #568, and caused that at least three bugs were found that have been missed in the original implementation due to the lack of test covering all corner cases (#687, #617, and, #640). Adding now to ensure that no regressions are introduced.
Each test generates a string with a controlled ASCII prefix followed by unicode, encodes it to CBOR, then decodes via both byte[] and throttled InputStream to exercise both _finishShortText and _finishLongTextAscii/_finishChunkedTextAscii paths.
Since the new tests covers all known cases the previously added test
ParseLongAsciiTextTest.javawas removed as it's now redundant alongside with the resources it used.Also two small changes in CBORParser
_loadMoreForChunkIfNeeded()only called when we've actually exhausted the current window_textBuffer, this code path will already throw if we cannot read enough but it's still worth leaving the_textBufferin a correct state.