summaryrefslogtreecommitdiff
path: root/ext/iconv
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2003-12-05 18:35:17 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2003-12-05 18:35:17 +0000
commitfe205854432b8f44c52c6d3e076a1b7c74dfb519 (patch)
tree57271da768dc490f6767d0406c785b36229407f9 /ext/iconv
parentc191a40ba4cbe41350d8a9dc5aa80b1661c7332b (diff)
downloadphp-git-fe205854432b8f44c52c6d3e076a1b7c74dfb519.tar.gz
Add regression test for iconv stream filters
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/tests/iconv_stream_filter.phpt41
-rw-r--r--ext/iconv/tests/iconv_stream_filter.txt1
2 files changed, 42 insertions, 0 deletions
diff --git a/ext/iconv/tests/iconv_stream_filter.phpt b/ext/iconv/tests/iconv_stream_filter.phpt
new file mode 100644
index 0000000000..2d721788cf
--- /dev/null
+++ b/ext/iconv/tests/iconv_stream_filter.phpt
@@ -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) ""
diff --git a/ext/iconv/tests/iconv_stream_filter.txt b/ext/iconv/tests/iconv_stream_filter.txt
new file mode 100644
index 0000000000..1074d2a48b
--- /dev/null
+++ b/ext/iconv/tests/iconv_stream_filter.txt
@@ -0,0 +1 @@
+こんにちはiconv