0
0
mirror of https://github.com/pmmp/ext-encoding.git synced 2025-10-06 03:49:56 +00:00
Files
ext-encoding/tests/fixed-simple/read-update-offset.phpt
Dylan K. Taylor eb9610a102 Split up ByteBuffer into reader & writer parts
closes #13

This prevents accidentally writing when reading is intended, and vice
versa.
It also allows specialising the APIs and constructors.
2025-09-06 17:12:57 +01:00

47 lines
814 B
PHP

--TEST--
(BE|LE)::read*() for fixed-size type must correctly update the reference $offset parameter if given
--EXTENSIONS--
encoding
--FILE--
<?php
use pmmp\encoding\ByteBufferReader;
function test(\Closure $function, int $size) : void{
$originalOffset = $size;
$bytes = str_repeat("\x00", $size * 3);
$buffer = new ByteBufferReader($bytes);
$buffer->setOffset($originalOffset);
$function($buffer);
var_dump($buffer->getOffset() === $originalOffset + $size);
}
$functions = require __DIR__ . '/read-samples.inc';
foreach($functions as [$function, $buf]){
test($function, strlen($buf));
}
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)