X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fmessageparser001.phpt;fp=tests%2Fmessageparser001.phpt;h=f4ec2d90967a01e42350817d1a93f8cf776f63ce;hb=dedd682f1f67f8af921c87653c58863f355ead43;hp=0000000000000000000000000000000000000000;hpb=2b065af121eb367bd3fe7e5ad3c673d342438d34;p=m6w6%2Fext-http diff --git a/tests/messageparser001.phpt b/tests/messageparser001.phpt new file mode 100644 index 0000000..f4ec2d9 --- /dev/null +++ b/tests/messageparser001.phpt @@ -0,0 +1,53 @@ +--TEST-- +message parser +--SKIPIF-- + +--FILE-- +parse(fgets($fd), 0, $message)) { + case Parser::STATE_DONE: + $string = (string) $message; + break 2; + case Parser::STATE_FAILURE: + throw new Exception(($e = error_get_last()) ? $e["message"] : "Could not parse $file"); + } + } + + $parser = new Parser; + rewind($fd); + unset($message); + + switch ($parser->stream($fd, 0, $message)) { + case Parser::STATE_DONE: + case Parser::STATE_START: + break; + default: + printf("Expected parser state 0 or 8, got %d", $parser->getState()); + } + if ($string !== (string) $message) { + $a = explode("\n", $string); + $b = explode("\n", (string) $message); + while ((null !== ($aa = array_shift($a))) || (null !== ($bb = array_shift($b)))) { + if ($aa !== $bb) { + isset($aa) and printf("-- %s\n", $aa); + isset($bb) and printf("++ %s\n", $bb); + } + } + } +} +?> +DONE +--EXPECT-- +Test +DONE