Conversation
Add 22 new test methods covering happy-path scenarios: - getUint8, getUint64, getInt16, getInt32, getInt64 (with negative and boundary values) - getPosition, getRemainingBytes (position tracking and mid-read scenarios) - peekUint16 (verifies position unchanged after peek) - skip (position advancement) - readBytes (various lengths and position tracking) - getObjectArray (with KeyValue VO, empty and populated arrays) Increases test coverage from 24 to 46 tests (92 assertions).
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.
Closes #187
Problem
`ReadBuffer` (225 lines, 18 public methods) has good underflow error coverage but is missing tests for several read methods:
Expected tests
```php
public function testGetUint8(): void
{
$buf = new ReadBuffer("\xFF");
$this->assertSame(255, $buf->getUint8());
}
public function testGetUint64(): void
{
$buf = new ReadBuffer(pack('J', 12345678901234));
$this->assertSame(12345678901234, $buf->getUint64());
}
public function testGetInt64Negative(): void
{
$buf = new ReadBuffer(pack('q', -1)); // Note: big-endian
$this->assertSame(-1, $buf->getInt64());
}
public function testPeekUint16DoesNotAdvancePosition(): void
{
$buf = new ReadBuffer("\x00\x01\x00\x02");
$peeked = $buf->peekUint16();
$read = $buf->getUint16();
$this->assertSame($peeked, $read); // Same value — position didn't move
}
public function testGetPositionAdvancesCorrectly(): void
{
$buf = new ReadBuffer("\x00\x01\x00\x02\x00\x03");
$this->assertSame(0, $buf->getPosition());
$buf->getUint16();
$this->assertSame(2, $buf->getPosition());
$buf->getUint32();
$this->assertSame(6, $buf->getPosition());
}
public function testGetObjectArray(): void
{
// Build binary for array of KeyValue objects
// Verify correct deserialization
}
```
Acceptance criteria