mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Add regression test for iconv stream filters
This commit is contained in:
parent
c191a40ba4
commit
fe20585443
2 changed files with 42 additions and 0 deletions
41
ext/iconv/tests/iconv_stream_filter.phpt
Normal file
41
ext/iconv/tests/iconv_stream_filter.phpt
Normal file
|
@ -0,0 +1,41 @@
|
|||
--TEST--
|
||||
iconv stream filter
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
|
||||
--INI--
|
||||
iconv.internal_charset=iso-8859-1
|
||||
--FILE--
|
||||
<?php
|
||||
$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'r');
|
||||
var_dump(bin2hex(fread($fp, 10)));
|
||||
var_dump(bin2hex(fread($fp, 5)));
|
||||
var_dump(bin2hex(fread($fp, 1)));
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'r');
|
||||
stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP');
|
||||
var_dump(bin2hex(fread($fp, 10)));
|
||||
var_dump(bin2hex(fread($fp, 5)));
|
||||
var_dump(bin2hex(fread($fp, 1)));
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'r');
|
||||
stream_filter_append($fp, 'string.rot13'); // this will make conversion fail.
|
||||
stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP');
|
||||
var_dump(bin2hex(fread($fp, 10)));
|
||||
var_dump(bin2hex(fread($fp, 5)));
|
||||
var_dump(bin2hex(fread($fp, 1)));
|
||||
fclose($fp);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(20) "1b244224332473244b24"
|
||||
string(10) "41244f1b28"
|
||||
string(2) "42"
|
||||
string(20) "a4b3a4f3a4cba4c1a4cf"
|
||||
string(10) "69636f6e76"
|
||||
string(2) "0a"
|
||||
|
||||
Warning: fread(): iconv stream filter ("ISO-2022-JP"=>"EUC-JP"): invalid multibyte sequence in %s on line %d
|
||||
string(0) ""
|
||||
string(0) ""
|
||||
string(0) ""
|
1
ext/iconv/tests/iconv_stream_filter.txt
Normal file
1
ext/iconv/tests/iconv_stream_filter.txt
Normal file
|
@ -0,0 +1 @@
|
|||
$B$3$s$K$A$O(Biconv
|
Loading…
Add table
Add a link
Reference in a new issue