1
0
mirror of https://github.com/pmmp/ext-encoding.git synced 2024-11-23 14:46:19 +00:00
ext-encoding/tests/update-offset-fixed-size.phpt
Dylan K. Taylor d0e71a30aa
Pull simple type encoders out into a separate class
this isn't the final form, but these statics already turned out to be
handy for the tests, and they'll probably be good for attributes and
other stuff like it.
2024-04-10 15:07:05 +01:00

47 lines
805 B
PHP

--TEST--
read*() for fixed-size type must correctly update the reference $offset parameter if given
--EXTENSIONS--
encoding
--FILE--
<?php
use pmmp\encoding\ByteBuffer;
function test(\Closure $function, int $size) : void{
$originalOffset = $size;
$bytes = str_repeat("\x00", $size * 3);
$buffer = new ByteBuffer($bytes);
$buffer->setReadOffset($originalOffset);
$function($buffer);
var_dump($buffer->getReadOffset() === $originalOffset + $size);
}
$functions = require __DIR__ . '/fixed-size-types.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)