Skip to content

API: Add tests for BinaryUtil - #17692

Open
uros-b wants to merge 2 commits into
apache:mainfrom
uros-b:test-add-binaryutil-coverage
Open

API: Add tests for BinaryUtil#17692
uros-b wants to merge 2 commits into
apache:mainfrom
uros-b:test-add-binaryutil-coverage

Conversation

@uros-b

@uros-b uros-b commented Aug 17, 2026

Copy link
Copy Markdown
Member

Adds a unit test class for BinaryUtil, covering its public truncation helpers:

  • truncateBinary - truncation to a shorter length, the fast path that returns the input buffer unchanged when the requested length already covers it, zero-length truncation, and the non-negative-length precondition.
  • truncateBinaryUnsafe - the shared-backing-data view, and that the input buffer's position and limit are left unmodified.
  • truncateBinaryMin - the ByteBuffer overload, and the Literal overload including its distinct branch that returns the input Literal unchanged when the length already covers the value.
  • truncateBinaryMax - the ByteBuffer overload (incrementing the last byte to form the upper bound, and returning null when every byte overflows, all 0xFF), and the Literal overload including its propagation of that null result.

Test-only; no production code changes.

Cover truncateBinary (partial, full, zero-length, and negative-length guard), the previously untested truncateBinaryUnsafe view, and truncateBinaryMax including the all-bytes-overflow case.
@github-actions github-actions Bot added the API label Aug 17, 2026

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added some more tests

@uros-b

uros-b commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@nastra Please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants