Skip to content

Add parameterized tests covering all ASCII-optimization exit paths in CBORParser#691

Merged
cowtowncoder merged 3 commits into
FasterXML:2.21from
sugmanue:sugmanue/add-ascii-tests
May 12, 2026
Merged

Add parameterized tests covering all ASCII-optimization exit paths in CBORParser#691
cowtowncoder merged 3 commits into
FasterXML:2.21from
sugmanue:sugmanue/add-ascii-tests

Conversation

@sugmanue
Copy link
Copy Markdown
Contributor

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.java was removed as it's now redundant alongside with the resources it used.

Also two small changes in CBORParser

  • A performance improvement to call _loadMoreForChunkIfNeeded() only called when we've actually exhausted the current window
  • A change to reset _textBuffer, this code path will already throw if we cannot read enough but it's still worth leaving the _textBuffer in a correct state.

… 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.
@cowtowncoder
Copy link
Copy Markdown
Member

Thank you, @sugmanue. Will get this reviewed, merged.

Copy link
Copy Markdown
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (made some minor clean up)

@cowtowncoder cowtowncoder merged commit 3dde898 into FasterXML:2.21 May 12, 2026
3 checks passed
@sugmanue sugmanue deleted the sugmanue/add-ascii-tests branch May 12, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants