Skip to content

Add boundary tests for BinaryCodec.fromAscii partial-bit inputs#425

Merged
garydgregory merged 2 commits intoapache:masterfrom
pdtx:binarycodec-boundary-tests
Feb 27, 2026
Merged

Add boundary tests for BinaryCodec.fromAscii partial-bit inputs#425
garydgregory merged 2 commits intoapache:masterfrom
pdtx:binarycodec-boundary-tests

Conversation

@pdtx
Copy link
Contributor

@pdtx pdtx commented Feb 27, 2026

Summary

  • Add boundary tests for BinaryCodec.fromAscii(byte[]) and BinaryCodec.fromAscii(char[]) when input length is less than 8 bits.
  • Add boundary tests for non-multiple-of-8 input lengths to assert the current decoding behavior where extra leading bits are ignored.
  • Add a direct null-contract test for BinaryCodec.toAsciiString(byte[]).

Why

Current tests cover null/empty and exact 8-bit aligned inputs, but do not explicitly cover short non-empty inputs or partial-bit-length inputs.
These boundary cases are easy to regress (for example, through off-by-one or grouping changes), so explicit tests improve behavioral stability.

Verification

  • Ran mvn -Dtest=BinaryCodecTest test
  • Result: all tests passed

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hello @pdtx

Thank you for your PR.

Update the existing testFromAsciiCharArray(), testFromAsciiByteArray(), and testToAsciiString().

Thank you!


@Test
void testToAsciiStringNullReturnsEmptyString() {
assertEquals("", BinaryCodec.toAsciiString(null));
Copy link
Member

Choose a reason for hiding this comment

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

Make this edge case the first assertion in testToAsciiString().

@pdtx
Copy link
Contributor Author

pdtx commented Feb 27, 2026

Thanks for the review. Updated as requested: I folded the new assertions into the existing testFromAsciiCharArray(), testFromAsciiByteArray(), and testToAsciiString() methods, and removed the standalone test methods.

@pdtx pdtx force-pushed the binarycodec-boundary-tests branch from 70436c2 to 3da6d7a Compare February 27, 2026 14:23
@garydgregory
Copy link
Member

Hello @pdtx

Thank you for the update.

Please rebate on git master.

@pdtx
Copy link
Contributor Author

pdtx commented Feb 27, 2026

Thanks for the note. Rebased on the latest master, resolved conflicts, and force-pushed the branch.

@garydgregory garydgregory merged commit 7789636 into apache:master Feb 27, 2026
9 checks passed
@garydgregory
Copy link
Member

garydgregory commented Feb 27, 2026

@pdtx
Merged, ty! 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants