<title>file io: fread correctly working with files > 8KB</title>

<!--
This QA shows bug http://bugs.caucho.com/view.php?id=3894 in action.

-->

<php out='/stdout' unicode.semantics='off' compile='false'>
<?php
$reswrite = fopen("testfile.bin", "w");

for($i = 0; $i < 14083; $i++)
{
        assert(fwrite($reswrite,"a") === 1);
}

assert(fclose($reswrite));

assert(14083 === filesize("testfile.bin"));





$res = fopen("testfile.bin", "r");

assert(14083 === filesize("testfile.bin"));

$result = "";

for($i = 0; $i < 28; $i++)
{
$result .= fread($res, 500);
}
assert(14000 === strlen($result));
echo strlen($result) . "\n";

$result .= fread($res, 8000);

assert(14083 === strlen($result));
echo strlen($result) . "\n";

assert(fclose($res));

?>
</php>

<compare file='/stdout' escape>
14000
14083
</compare>

