cvs: php-src /ext/iconv/tests iconv_basic.phpt iconv_encoding_basic.phpt iconv_get_encoding_error.phpt iconv_mime_decode_headers_variation1.phpt
iconv_mime_decode_headers_variation2.phpt iconv_mime_decode_headers_variation3.phpt iconv_mime_decode_variation1.phpt
iconv_mime_decode_variation2.phpt iconv_mime_decode_variation3.phpt iconv_set_encoding_error.phpt iconv_set_encoding_variation.phpt
iconv_strpos_basic.phpt iconv_strpos_error1.phpt iconv_strpos_variation1.phpt iconv_strpos_variation2.phpt iconv_strpos_variation3.phpt
iconv_strpos_variation3_64bit.phpt iconv_strpos_variation4.phpt iconv_strpos_variation5.phpt iconv_strrpos_basic.phpt iconv_strrpos_error1.phpt
iconv_strrpos_error2.phpt iconv_strrpos_variation1.phpt iconv_strrpos_variation2.phpt iconv_strrpos_variation3.phpt

From: Date: Fri, 12 Jun 2009 17:16:06 +0000
Subject: cvs: php-src /ext/iconv/tests iconv_basic.phpt iconv_encoding_basic.phpt iconv_get_encoding_error.phpt iconv_mime_decode_headers_variation1.phpt
iconv_mime_decode_headers_variation2.phpt iconv_mime_decode_headers_variation3.phpt iconv_mime_decode_variation1.phpt
iconv_mime_decode_variation2.phpt iconv_mime_decode_variation3.phpt iconv_set_encoding_error.phpt iconv_set_encoding_variation.phpt
iconv_strpos_basic.phpt iconv_strpos_error1.phpt iconv_strpos_variation1.phpt iconv_strpos_variation2.phpt iconv_strpos_variation3.phpt
iconv_strpos_variation3_64bit.phpt iconv_strpos_variation4.phpt iconv_strpos_variation5.phpt iconv_strrpos_basic.phpt iconv_strrpos_error1.phpt
iconv_strrpos_error2.phpt iconv_strrpos_variation1.phpt iconv_strrpos_variation2.phpt iconv_strrpos_variation3.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-58680@lists.php.net to get a copy of this message
wharmby Fri Jun 12 17:16:06 2009 UTC Modified files: /php-src/ext/iconv/tests iconv_strpos_basic.phpt iconv_strpos_variation2.phpt iconv_mime_decode_variation3.phpt iconv_mime_decode_variation1.phpt iconv_strrpos_basic.phpt iconv_encoding_basic.phpt iconv_strpos_variation1.phpt iconv_strpos_error1.phpt iconv_mime_decode_variation2.phpt iconv_set_encoding_variation.phpt iconv_strrpos_variation3.phpt iconv_strpos_variation3.phpt iconv_mime_decode_headers_variation3.phpt iconv_mime_decode_headers_variation2.phpt iconv_strpos_variation4.phpt iconv_set_encoding_error.phpt iconv_strrpos_error1.phpt iconv_strpos_variation3_64bit.phpt iconv_mime_decode_headers_variation1.phpt iconv_get_encoding_error.phpt iconv_strrpos_variation2.phpt iconv_strpos_variation5.phpt iconv_strrpos_variation1.phpt iconv_basic.phpt iconv_strrpos_error2.phpt Log: New iconv extension tests. Tested on Windows, Linux and Linux 64 bit

http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_basic.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_basic.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_basic.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,57 @@ +--TEST-- +Test iconv_strpos() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Test basic functionality of iconv_strpos with ASCII and multibyte characters + */ + +echo "*** Testing iconv_strpos() : basic functionality***\n"; + +iconv_set_encoding("internal_encoding", "UTF-8"); + +$string_ascii = b'abc def'; +//Japanese string in UTF-8 +$string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); + +echo "\n-- ASCII string 1 --\n"; +var_dump(iconv_strpos($string_ascii, b'd', 2, 'ISO-8859-1')); + +echo "\n-- ASCII string 2 --\n"; +var_dump(iconv_strpos($string_ascii, b'123')); + +echo "\n-- Multibyte string 1 --\n"; +$needle1 = base64_decode('5pel5pys6Kqe'); +var_dump(iconv_strpos($string_mb, $needle1)); + +echo "\n-- Multibyte string 2 --\n"; +$needle2 = base64_decode(b"44GT44KT44Gr44Gh44Gv44CB5LiW55WM"); +var_dump(iconv_strpos($string_mb, $needle2)); + +echo "Done"; +?> +--EXPECTF-- +*** Testing iconv_strpos() : basic functionality*** + +-- ASCII string 1 -- +int(4) + +-- ASCII string 2 -- +bool(false) + +-- Multibyte string 1 -- +int(0) + +-- Multibyte string 2 -- +bool(false) +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation2.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation2.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation2.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,182 @@ +--TEST-- +Test iconv_strpos() function : usage variations - pass different data types as $needle arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strpos different data types as $needle arg to test behaviour + */ + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$haystack = 'string_val'; +$offset = 0; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $needle argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strpos($haystack, $input, $offset, $encoding)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +int(0) + +-- Iteration 19 -- +int(0) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_strpos() expects parameter 2 to be string (Unicode or binary), resource given in %s line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_variation3.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_variation3.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_variation3.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,222 @@ +--TEST-- +Test iconv_mime_decode() function : usage variations - Pass different data types to charset arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode') or die("skip iconv_mime_decode() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : string iconv_mime_decode(string encoded_string [, int mode, string charset]) + * Description: Decodes a mime header field + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode() behaves + */ + +echo "*** Testing iconv_mime_decode() : usage variations ***\n"; + +// Initialise function arguments not being substituted +// Some of the parameters actually passed to charset will request to use +// a default charset determined by the platform. In order for this test to +// run on both linux and windows, the subject will have to be ascii only. +$header = b'Subject: =?UTF-8?B?QSBTYW1wbGUgVGVzdA==?='; +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'UTF-8'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $res = iconv_mime_decode($header, $mode, $input); + if ($res !== false) { + var_dump(bin2hex($res)); + } + else { + var_dump($res); + } + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode() : usage variations *** + +-- Iteration 1 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `0' is not allowed in %s on line %d +bool(false) + +-- Iteration 2 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `1' is not allowed in %s on line %d +bool(false) + +-- Iteration 3 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `12345' is not allowed in %s on line %d +bool(false) + +-- Iteration 4 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `-2345' is not allowed in %s on line %d +bool(false) + +-- Iteration 5 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `10.5' is not allowed in %s on line %d +bool(false) + +-- Iteration 6 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `-10.5' is not allowed in %s on line %d +bool(false) + +-- Iteration 7 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `123456789000' is not allowed in %s on line %d +bool(false) + +-- Iteration 8 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `1.23456789E-9' is not allowed in %s on line %d +bool(false) + +-- Iteration 9 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `0.5' is not allowed in %s on line %d +bool(false) + +-- Iteration 10 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 11 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 12 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `1' is not allowed in %s on line %d +bool(false) + +-- Iteration 13 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 14 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `1' is not allowed in %s on line %d +bool(false) + +-- Iteration 15 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 16 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 17 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 18 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `string' is not allowed in %s on line %d +bool(false) + +-- Iteration 19 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `string' is not allowed in %s on line %d +bool(false) + +-- Iteration 20 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `hello world' is not allowed in %s on line %d +bool(false) + +-- Iteration 21 -- + +Notice: iconv_mime_decode(): Wrong charset, conversion from `???' to `Class A object' is not allowed in %s on line %d +bool(false) + +-- Iteration 22 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 23 -- +unicode(44) "5375626a6563743a20412053616d706c652054657374" + +-- Iteration 24 -- + +Warning: iconv_mime_decode() expects parameter 3 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_variation1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_variation1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_variation1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,183 @@ +--TEST-- +Test iconv_mime_decode() function : usage variations - Pass different data types to header arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode') or die("skip iconv_mime_decode() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : string iconv_mime_decode(string encoded_string [, int mode, string charset]) + * Description: Decodes a mime header field + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode() behaves + */ + +echo "*** Testing iconv_mime_decode() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$header = b'Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?='; +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'ISO-8859-1'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_mime_decode($input, $mode, $charset)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode() : usage variations *** + +-- Iteration 1 -- +string(1) "0" + +-- Iteration 2 -- +string(1) "1" + +-- Iteration 3 -- +string(5) "12345" + +-- Iteration 4 -- +string(5) "-2345" + +-- Iteration 5 -- +string(4) "10.5" + +-- Iteration 6 -- +string(5) "-10.5" + +-- Iteration 7 -- +string(12) "123456789000" + +-- Iteration 8 -- +string(13) "1.23456789E-9" + +-- Iteration 9 -- +string(3) "0.5" + +-- Iteration 10 -- +string(0) "" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(1) "1" + +-- Iteration 13 -- +string(0) "" + +-- Iteration 14 -- +string(1) "1" + +-- Iteration 15 -- +string(0) "" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(6) "string" + +-- Iteration 19 -- +string(6) "string" + +-- Iteration 20 -- +string(11) "hello world" + +-- Iteration 21 -- +string(14) "Class A object" + +-- Iteration 22 -- +string(0) "" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- + +Warning: iconv_mime_decode() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_basic.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_basic.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_basic.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,58 @@ +--TEST-- +Test iconv_strrpos() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Test basic functionality of iconv_strrpos() + */ + +echo "*** Testing iconv_strrpos() : basic ***\n"; + +iconv_set_encoding("internal_encoding", "UTF-8"); + +$string_ascii = b'This is an English string. 0123456789.'; +//Japanese string in UTF-8 +$string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); + +echo "\n-- ASCII string 1 --\n"; +var_dump(iconv_strrpos($string_ascii, b'is', 'ISO-8859-1')); + +echo "\n-- ASCII string 2 --\n"; +var_dump(iconv_strrpos($string_ascii, b'hello, world')); + +echo "\n-- Multibyte string 1 --\n"; +$needle1 = base64_decode(b'44CC'); +var_dump(iconv_strrpos($string_mb, $needle1)); + +echo "\n-- Multibyte string 2 --\n"; +$needle2 = base64_decode(b'44GT44KT44Gr44Gh44Gv44CB5LiW55WM'); +var_dump(iconv_strrpos($string_mb, $needle2)); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : basic *** + +-- ASCII string 1 -- +int(15) + +-- ASCII string 2 -- +bool(false) + +-- Multibyte string 1 -- +int(20) + +-- Multibyte string 2 -- +bool(false) +===DONE=== + http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_encoding_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_encoding_basic.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_encoding_basic.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_encoding_basic.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,94 @@ +--TEST-- +Test iconv_get_encoding()/iconv_set_encoding() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : mixed iconv_get_encoding([string type]) + * Description: Get internal encoding and output encoding for ob_iconv_handler() + * Prototype : bool iconv_set_encoding(string type, string charset) + * Description: Sets internal encoding and output encoding for ob_iconv_handler() + * Source code: ext/iconv/iconv.c + */ + +/* + * Test Basic functionality of iconv_get_encoding/iconv_set_encoding + */ + +echo "*** Testing iconv_get_encoding()/iconv_set_encoding() : basic functionality ***\n"; + +echo "--- Default get_encoding ---\n"; +var_dump(iconv_get_encoding()); +var_dump(iconv_get_encoding("input_encoding")); +var_dump(iconv_get_encoding("output_encoding")); +var_dump(iconv_get_encoding("internal_encoding")); +var_dump(iconv_get_encoding("all")); + +echo "\n--- Altering encodings ---\n"; +var_dump(iconv_set_encoding("input_encoding", "UTF-8")); +var_dump(iconv_set_encoding("output_encoding", "UTF-8")); +var_dump(iconv_set_encoding("internal_encoding", "UTF-8")); + + +echo "\n--- results of alterations ---\n"; +var_dump(iconv_get_encoding()); +var_dump(iconv_get_encoding("input_encoding")); +var_dump(iconv_get_encoding("output_encoding")); +var_dump(iconv_get_encoding("internal_encoding")); +var_dump(iconv_get_encoding("all")); + + +echo "Done"; +?> +--EXPECTF-- +*** Testing iconv_get_encoding()/iconv_set_encoding() : basic functionality *** +--- Default get_encoding --- +array(3) { + ["input_encoding"]=> + string(10) "ISO-8859-1" + ["output_encoding"]=> + string(10) "ISO-8859-1" + ["internal_encoding"]=> + string(10) "ISO-8859-1" +} +string(10) "ISO-8859-1" +string(10) "ISO-8859-1" +string(10) "ISO-8859-1" +array(3) { + ["input_encoding"]=> + string(10) "ISO-8859-1" + ["output_encoding"]=> + string(10) "ISO-8859-1" + ["internal_encoding"]=> + string(10) "ISO-8859-1" +} + +--- Altering encodings --- +bool(true) +bool(true) +bool(true) + +--- results of alterations --- +array(3) { + ["input_encoding"]=> + string(5) "UTF-8" + ["output_encoding"]=> + string(5) "UTF-8" + ["internal_encoding"]=> + string(5) "UTF-8" +} +string(5) "UTF-8" +string(5) "UTF-8" +string(5) "UTF-8" +array(3) { + ["input_encoding"]=> + string(5) "UTF-8" + ["output_encoding"]=> + string(5) "UTF-8" + ["internal_encoding"]=> + string(5) "UTF-8" +} +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,182 @@ +--TEST-- +Test iconv_strpos() function : usage variations - pass different data types to $haystack arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strpos different data types as $haystack arg to test behaviour + */ + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$needle = 'string_val'; +$offset = 0; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $haystack argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strpos($input, $needle, $offset, $encoding)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_strpos() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_error1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_error1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_error1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_error1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,50 @@ +--TEST-- +Test iconv_strpos() function : error conditions - Pass incorrect number of args +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Test how iconv_strpos behaves when passed an incorrect number of arguments + */ + +echo "*** Testing iconv_strpos() : error conditions ***\n"; + + +//Test iconv_strpos with one more than the expected number of arguments +echo "\n-- Testing iconv_strpos() function with more than expected no. of arguments --\n"; +$haystack = 'string_val'; +$needle = 'string_val'; +$offset = 10; +$encoding = 'string_val'; +$extra_arg = 10; +var_dump( iconv_strpos($haystack, $needle, $offset, $encoding, $extra_arg) ); + +// Testing iconv_strpos with one less than the expected number of arguments +echo "\n-- Testing iconv_strpos() function with less than expected no. of arguments --\n"; +$haystack = 'string_val'; +var_dump( iconv_strpos($haystack) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing iconv_strpos() : error conditions *** + +-- Testing iconv_strpos() function with more than expected no. of arguments -- + +Warning: iconv_strpos() expects at most 4 parameters, 5 given in %s on line %d +bool(false) + +-- Testing iconv_strpos() function with less than expected no. of arguments -- + +Warning: iconv_strpos() expects at least 2 parameters, 1 given in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_variation2.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_variation2.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_variation2.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,195 @@ +--TEST-- +Test iconv_mime_decode() function : usage variations - Pass different data types to mode arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode') or die("skip iconv_mime_decode() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : string iconv_mime_decode(string encoded_string [, int mode, string charset]) + * Description: Decodes a mime header field + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode() behaves + */ + +echo "*** Testing iconv_mime_decode() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$header = b'Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?='; +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'UTF-8'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( bin2hex(iconv_mime_decode($header, $input, $charset))); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode() : usage variations *** + +-- Iteration 1 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 2 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 3 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 4 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 5 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 6 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 7 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 8 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 9 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 10 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 11 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 12 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 13 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 14 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 15 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 16 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(0) "" + +-- Iteration 17 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(0) "" + +-- Iteration 18 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(0) "" + +-- Iteration 19 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(0) "" + +-- Iteration 20 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, Unicode string given in %s on line %d +unicode(0) "" + +-- Iteration 21 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, object given in %s on line %d +unicode(0) "" + +-- Iteration 22 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 23 -- +unicode(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67" + +-- Iteration 24 -- + +Warning: iconv_mime_decode() expects parameter 2 to be long, resource given in %s on line %d +unicode(0) "" +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_set_encoding_variation.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_set_encoding_variation.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_set_encoding_variation.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_set_encoding_variation.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,307 @@ +--TEST-- +Test iconv_set_encoding() function : error functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_set_encoding') or die("skip iconv_set_encoding() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : bool iconv_set_encoding(string type, string charset) + * Description: Sets internal encoding and output encoding for ob_iconv_handler() + * Source code: ext/iconv/iconv.c + */ + +/* + * Test Error functionality of iconv_get_encoding + */ + +echo "*** Testing iconv_set_encoding() : error functionality ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "UTF-8"; + } +} + +// heredoc string +$heredoc = <<<EOT +Nothing +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $encoding argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of mb_regex_encoding() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_set_encoding("internal_encoding", $input) ); + var_dump( iconv_set_encoding("input_encoding", $input) ); + var_dump( iconv_set_encoding("output_encoding", $input) ); + var_dump( iconv_get_encoding("internal_encoding") ); + var_dump( iconv_get_encoding("input_encoding") ); + var_dump( iconv_get_encoding("output_encoding") ); + + $iterator++; +}; + +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing iconv_set_encoding() : error functionality *** + +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +string(1) "0" +string(1) "0" +string(1) "0" + +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +string(1) "1" +string(1) "1" +string(1) "1" + +-- Iteration 3 -- +bool(true) +bool(true) +bool(true) +string(5) "12345" +string(5) "12345" +string(5) "12345" + +-- Iteration 4 -- +bool(true) +bool(true) +bool(true) +string(5) "-2345" +string(5) "-2345" +string(5) "-2345" + +-- Iteration 5 -- +bool(true) +bool(true) +bool(true) +string(4) "10.5" +string(4) "10.5" +string(4) "10.5" + +-- Iteration 6 -- +bool(true) +bool(true) +bool(true) +string(5) "-10.5" +string(5) "-10.5" +string(5) "-10.5" + +-- Iteration 7 -- +bool(true) +bool(true) +bool(true) +string(12) "123456789000" +string(12) "123456789000" +string(12) "123456789000" + +-- Iteration 8 -- +bool(true) +bool(true) +bool(true) +string(13) "1.23456789E-9" +string(13) "1.23456789E-9" +string(13) "1.23456789E-9" + +-- Iteration 9 -- +bool(true) +bool(true) +bool(true) +string(3) "0.5" +string(3) "0.5" +string(3) "0.5" + +-- Iteration 10 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 11 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 12 -- +bool(true) +bool(true) +bool(true) +string(1) "1" +string(1) "1" +string(1) "1" + +-- Iteration 13 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 14 -- +bool(true) +bool(true) +bool(true) +string(1) "1" +string(1) "1" +string(1) "1" + +-- Iteration 15 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 16 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 17 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 18 -- +bool(true) +bool(true) +bool(true) +string(7) "Nothing" +string(7) "Nothing" +string(7) "Nothing" + +-- Iteration 19 -- +bool(true) +bool(true) +bool(true) +string(7) "Nothing" +string(7) "Nothing" +string(7) "Nothing" + +-- Iteration 20 -- +bool(true) +bool(true) +bool(true) +string(7) "Nothing" +string(7) "Nothing" +string(7) "Nothing" + +-- Iteration 21 -- +bool(true) +bool(true) +bool(true) +string(5) "UTF-8" +string(5) "UTF-8" +string(5) "UTF-8" + +-- Iteration 22 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 23 -- +bool(true) +bool(true) +bool(true) +string(0) "" +string(0) "" +string(0) "" + +-- Iteration 24 -- + +Warning: iconv_set_encoding() expects parameter 2 to be binary string, resource given in %s on line %d +NULL + +Warning: iconv_set_encoding() expects parameter 2 to be binary string, resource given in %s on line %d +NULL + +Warning: iconv_set_encoding() expects parameter 2 to be binary string, resource given in %s on line %d +NULL +string(0) "" +string(0) "" +string(0) "" +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_variation3.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_variation3.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_variation3.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,204 @@ +--TEST-- +Test iconv_strrpos() function : usage variations - pass different data types as $encoding arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strrpos() different data types as $encoding argument to test behaviour + * Where possible 'UTF-8' has been entered as a string value + */ + +echo "*** Testing iconv_strrpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$haystack = b'hello, world'; +$needle = b'world'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "UTF-8"; + } +} + +// heredoc string +$heredoc = <<<EOT +UTF-8 +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $encoding argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "UTF-8", + 'UTF-8', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strrpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strrpos($haystack, $needle, $input)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : usage variations *** + +-- Iteration 1 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `0' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 2 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 3 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `12345' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 4 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `-2345' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 5 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `10.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 6 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `-10.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 7 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `123456789000' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 8 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `1.23456789E-9' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 9 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `0.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 10 -- +int(7) + +-- Iteration 11 -- +int(7) + +-- Iteration 12 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 13 -- +int(7) + +-- Iteration 14 -- + +Notice: iconv_strrpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 15 -- +int(7) + +-- Iteration 16 -- +int(7) + +-- Iteration 17 -- +int(7) + +-- Iteration 18 -- +int(7) + +-- Iteration 19 -- +int(7) + +-- Iteration 20 -- +int(7) + +-- Iteration 21 -- +int(7) + +-- Iteration 22 -- +int(7) + +-- Iteration 23 -- +int(7) + +-- Iteration 24 -- + +Warning: iconv_strrpos() expects parameter 3 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation3.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation3.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation3.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,201 @@ +--TEST-- +Test iconv_strpos() function : usage variations - pass different data types as $offset arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strpos different data types as $offset arg to test behaviour + */ + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$needle = b'a'; +$haystack = b'string_val'; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $offest argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strpos($haystack, $needle, $input, $encoding)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +-- Iteration 1 -- +int(8) + +-- Iteration 2 -- +int(8) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +-- Iteration 8 -- +int(8) + +-- Iteration 9 -- +int(8) + +-- Iteration 10 -- +int(8) + +-- Iteration 11 -- +int(8) + +-- Iteration 12 -- +int(8) + +-- Iteration 13 -- +int(8) + +-- Iteration 14 -- +int(8) + +-- Iteration 15 -- +int(8) + +-- Iteration 16 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: iconv_strpos() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- Iteration 22 -- +int(8) + +-- Iteration 23 -- +int(8) + +-- Iteration 24 -- + +Warning: iconv_strpos() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_headers_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_headers_variation3.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_headers_variation3.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_headers_variation3.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,482 @@ +--TEST-- +Test iconv_mime_encode() function : usage variations - Pass different data types to charset arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode_headers') or die("skip iconv_mime_decode_headers() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : array iconv_mime_decode_headers(string headers [, int mode, string charset]) + * Description: Decodes multiple mime header fields + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode_headers() behaves + */ + +echo "*** Testing iconv_mime_decode_headers() : usage variations ***\n"; + +// Some of the parameters actually passed to charset will request to use +// a default charset determined by the platform. In order for this test to +// run on both linux and windows, the subject will have to be ascii only. +// Initialise function arguments not being substituted +$headers = <<<EOF +Subject: =?UTF-8?B?QSBTYW1wbGUgVGVzdA==?= +To: example@example.com +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Message-Id: <example@example.com> +Received: from localhost (localhost [127.0.0.1]) by localhost + with SMTP id example for <example@example.com>; + Thu, 1 Jan 1970 00:00:00 +0000 (UTC) + (envelope-from example-return-0000-example=example.com@example.com) +Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000 + +EOF; + +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'UTF-8'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode_headers() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_mime_decode_headers($headers, $input, $charset)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode_headers() : usage variations *** + +-- Iteration 1 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 2 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 3 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 4 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 5 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 6 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 7 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 8 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 9 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 10 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 11 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 12 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 13 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 14 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 15 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 16 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- Iteration 22 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 23 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 24 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_headers_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_headers_variation2.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_headers_variation2.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_headers_variation2.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,479 @@ +--TEST-- +Test iconv_mime_encode() function : usage variations - Pass different data types to mode arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode_headers') or die("skip iconv_mime_decode_headers() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : array iconv_mime_decode_headers(string headers [, int mode, string charset]) + * Description: Decodes multiple mime header fields + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode_headers() behaves + */ + +echo "*** Testing iconv_mime_decode_headers() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$headers = <<<EOF +Subject: =?UTF-8?B?QSBTYW1wbGUgVGVzdA==?= +To: example@example.com +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Message-Id: <example@example.com> +Received: from localhost (localhost [127.0.0.1]) by localhost + with SMTP id example for <example@example.com>; + Thu, 1 Jan 1970 00:00:00 +0000 (UTC) + (envelope-from example-return-0000-example=example.com@example.com) +Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000 + +EOF; + +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'UTF-8'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode_headers() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_mime_decode_headers($headers, $input, $charset)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode_headers() : usage variations *** + +-- Iteration 1 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 2 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 3 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 4 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 5 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 6 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 7 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 8 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 9 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 10 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 11 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 12 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 13 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 14 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 15 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 16 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, object given in %s on line %d +bool(false) + +-- Iteration 22 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 23 -- +array(5) { + ["Subject"]=> + string(13) "A Sample Test" + ["To"]=> + string(19) "example@example.com" + ["Date"]=> + string(30) "Thu, 1 Jan 1970 00:00:00 +0000" + ["Message-Id"]=> + string(21) "<example@example.com>" + ["Received"]=> + array(2) { + [0]=> + string(204) "from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)" + [1]=> + string(57) "(qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000" + } +} + +-- Iteration 24 -- + +Warning: iconv_mime_decode_headers() expects parameter 2 to be long, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation4.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation4.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation4.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,206 @@ +--TEST-- +Test iconv_strpos() function : usage variations - pass different data types as $charset arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + + +/* + * Pass iconv_strpos different data types as $encoding arg to test behaviour + * Where possible 'UTF-8' has been entered as a string value + */ + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$haystack = b'string_val'; +$needle = b'val'; +$offset = 0; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "UTF-8"; + } +} + +// heredoc string +$heredoc = <<<EOT +UTF-8 +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $input argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "UTF-8", + 'UTF-8', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strpos($haystack, $needle, $offset, $input)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +-- Iteration 1 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `0' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 2 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 3 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `12345' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 4 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `-2345' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 5 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `10.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 6 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `-10.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 7 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `123456789000' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 8 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `1.23456789E-9' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 9 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `0.5' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 10 -- +int(7) + +-- Iteration 11 -- +int(7) + +-- Iteration 12 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 13 -- +int(7) + +-- Iteration 14 -- + +Notice: iconv_strpos(): Wrong charset, conversion from `1' to `UCS-4LE' is not allowed in %s on line %d +bool(false) + +-- Iteration 15 -- +int(7) + +-- Iteration 16 -- +int(7) + +-- Iteration 17 -- +int(7) + +-- Iteration 18 -- +int(7) + +-- Iteration 19 -- +int(7) + +-- Iteration 20 -- +int(7) + +-- Iteration 21 -- +int(7) + +-- Iteration 22 -- +int(7) + +-- Iteration 23 -- +int(7) + +-- Iteration 24 -- + +Warning: iconv_strpos() expects parameter 4 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_set_encoding_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_set_encoding_error.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_set_encoding_error.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_set_encoding_error.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,177 @@ +--TEST-- +Test iconv_set_encoding() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_set_encoding') or die("skip iconv_set_encoding() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : bool iconv_set_encoding(string type, string charset) + * Description: Sets internal encoding and output encoding for ob_iconv_handler() + * Source code: ext/iconv/iconv.c + */ + +/* + * Test Error functionality of iconv_get_encoding + */ + +echo "*** Testing iconv_set_encoding() : error functionality ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "UTF-8"; + } +} + +// heredoc string +$heredoc = <<<EOT +Nothing +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $encoding argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of mb_regex_encoding() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_set_encoding($input, "UTF-8") ); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_set_encoding() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_set_encoding() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_error1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_error1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_error1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_error1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,49 @@ +--TEST-- +Test iconv_strrpos() function : error conditions - pass incorrect number of args +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strrpos() an incorrect number of arguments + */ + +echo "*** Testing iconv_strrpos() : error conditions ***\n"; + + +//Test iconv_strrpos with one more than the expected number of arguments +echo "\n-- Testing iconv_strrpos() function with more than expected no. of arguments --\n"; +$haystack = 'string_val'; +$needle = 'string_val'; +$encoding = 'string_val'; +$extra_arg = 10; +var_dump( iconv_strrpos($haystack, $needle, $encoding, $extra_arg) ); + +// Testing iconv_strrpos with one less than the expected number of arguments +echo "\n-- Testing iconv_strrpos() function with less than expected no. of arguments --\n"; +$haystack = 'string_val'; +var_dump( iconv_strrpos($haystack) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : error conditions *** + +-- Testing iconv_strrpos() function with more than expected no. of arguments -- + +Warning: iconv_strrpos() expects at most 3 parameters, 4 given in %s on line %d +bool(false) + +-- Testing iconv_strrpos() function with less than expected no. of arguments -- + +Warning: iconv_strrpos() expects at least 2 parameters, 1 given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,199 @@ +--TEST-- +Test iconv_strpos() function : usage variations - pass different data types as $offset arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strpos different data types as $offset arg to test behaviour + */ + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$needle = b'a'; +$haystack = b'string_val'; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $offest argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strpos($haystack, $needle, $input, $encoding)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +-- Iteration 1 -- +int(8) + +-- Iteration 2 -- +int(8) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +-- Iteration 7 -- +int(8) + +-- Iteration 8 -- +int(8) + +-- Iteration 9 -- +int(8) + +-- Iteration 10 -- +int(8) + +-- Iteration 11 -- +int(8) + +-- Iteration 12 -- +int(8) + +-- Iteration 13 -- +int(8) + +-- Iteration 14 -- +int(8) + +-- Iteration 15 -- +int(8) + +-- Iteration 16 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: iconv_strpos() expects parameter 3 to be long, Unicode string given in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: iconv_strpos() expects parameter 3 to be long, object given in %s on line %d +bool(false) + +-- Iteration 22 -- +int(8) + +-- Iteration 23 -- +int(8) + +-- Iteration 24 -- + +Warning: iconv_strpos() expects parameter 3 to be long, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_mime_decode_headers_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_mime_decode_headers_variation1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_mime_decode_headers_variation1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_mime_decode_headers_variation1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,218 @@ +--TEST-- +Test iconv_mime_encode() function : usage variations - Pass different data types to headers arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_mime_decode_headers') or die("skip iconv_mime_decode_headers() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : array iconv_mime_decode_headers(string headers [, int mode, string charset]) + * Description: Decodes multiple mime header fields + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass different data types to $str argument to see how iconv_mime_decode_headers() behaves + */ + +echo "*** Testing iconv_mime_decode_headers() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$headers = <<<EOF +Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?= +To: example@example.com +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Message-Id: <example@example.com> +Received: from localhost (localhost [127.0.0.1]) by localhost + with SMTP id example for <example@example.com>; + Thu, 1 Jan 1970 00:00:00 +0000 (UTC) + (envelope-from example-return-0000-example=example.com@example.com) +Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000 + +EOF; + +$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; +$charset = 'ISO-8859-1'; + + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $str argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "string", + 'string', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_mime_decode_headers() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_mime_decode_headers($input, $mode, $charset)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_mime_decode_headers() : usage variations *** + +-- Iteration 1 -- +array(0) { +} + +-- Iteration 2 -- +array(0) { +} + +-- Iteration 3 -- +array(0) { +} + +-- Iteration 4 -- +array(0) { +} + +-- Iteration 5 -- +array(0) { +} + +-- Iteration 6 -- +array(0) { +} + +-- Iteration 7 -- +array(0) { +} + +-- Iteration 8 -- +array(0) { +} + +-- Iteration 9 -- +array(0) { +} + +-- Iteration 10 -- +array(0) { +} + +-- Iteration 11 -- +array(0) { +} + +-- Iteration 12 -- +array(0) { +} + +-- Iteration 13 -- +array(0) { +} + +-- Iteration 14 -- +array(0) { +} + +-- Iteration 15 -- +array(0) { +} + +-- Iteration 16 -- +array(0) { +} + +-- Iteration 17 -- +array(0) { +} + +-- Iteration 18 -- +array(0) { +} + +-- Iteration 19 -- +array(0) { +} + +-- Iteration 20 -- +array(0) { +} + +-- Iteration 21 -- +array(0) { +} + +-- Iteration 22 -- +array(0) { +} + +-- Iteration 23 -- +array(0) { +} + +-- Iteration 24 -- + +Warning: iconv_mime_decode_headers() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_get_encoding_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_get_encoding_error.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_get_encoding_error.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_get_encoding_error.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,177 @@ +--TEST-- +Test iconv_get_encoding() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : mixed iconv_get_encoding([string type]) + * Description: Get internal encoding and output encoding for ob_iconv_handler() + * Source code: ext/iconv/iconv.c + */ + +/* + * Test Error functionality of iconv_get_encoding + */ + +echo "*** Testing iconv_get_encoding() : error functionality ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "UTF-8"; + } +} + +// heredoc string +$heredoc = <<<EOT +Nothing +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $encoding argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of mb_regex_encoding() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_get_encoding($input) ); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_get_encoding() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +bool(false) + +-- Iteration 19 -- +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_get_encoding() expects parameter 1 to be binary string, resource given %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_variation2.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_variation2.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_variation2.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,181 @@ +--TEST-- +Test iconv_strrpos() function : usage variations - Pass different data types to $needle arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strrpos() different data types as $needle argument to test behaviour + */ + +echo "*** Testing iconv_strrpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$haystack = 'hello, world'; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "world"; + } +} + +// heredoc string +$heredoc = <<<EOT +world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $needle argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "world", + 'world', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strrpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strrpos($haystack, $input, $encoding)); + $iterator++; +}; + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +int(7) + +-- Iteration 19 -- +int(7) + +-- Iteration 20 -- +int(7) + +-- Iteration 21 -- +int(7) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_strrpos() expects parameter 2 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos_variation5.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strpos_variation5.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strpos_variation5.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,100 @@ +--TEST-- +Test iconv_strpos() function : usage variations - Pass different integers as $offset argument +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Test how iconv_strpos() behaves when passed different integers as $offset argument + * The character length of $string_ascii and $string_mb is the same, + * and the needle appears at the same positions in both strings + */ + +iconv_set_encoding("internal_encoding", "UTF-8"); + +echo "*** Testing iconv_strpos() : usage variations ***\n"; + +$string_ascii = b'+Is an English string'; //21 chars +$needle_ascii = b'g'; + +$string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); //21 chars +$needle_mb = base64_decode(b'44CC'); + +/* + * Loop through integers as multiples of ten for $offset argument + * iconv_strpos should not be able to accept negative values as $offset. + * 60 is larger than *BYTE* count for $string_mb + */ +for ($i = -10; $i <= 60; $i += 10) { + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + var_dump(iconv_strpos($string_ascii, $needle_ascii, $i)); + echo "--Multibyte String --\n"; + var_dump(iconv_strpos($string_mb, $needle_mb, $i, 'UTF-8')); +} + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strpos() : usage variations *** + +**-- Offset is: -10 --** +-- ASCII String -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) +--Multibyte String -- + +Warning: iconv_strpos(): Offset not contained in string in %s on line %d +bool(false) + +**-- Offset is: 0 --** +-- ASCII String -- +int(9) +--Multibyte String -- +int(9) + +**-- Offset is: 10 --** +-- ASCII String -- +int(20) +--Multibyte String -- +int(20) + +**-- Offset is: 20 --** +-- ASCII String -- +int(20) +--Multibyte String -- +int(20) + +**-- Offset is: 30 --** +-- ASCII String -- +bool(false) +--Multibyte String -- +bool(false) + +**-- Offset is: 40 --** +-- ASCII String -- +bool(false) +--Multibyte String -- +bool(false) + +**-- Offset is: 50 --** +-- ASCII String -- +bool(false) +--Multibyte String -- +bool(false) + +**-- Offset is: 60 --** +-- ASCII String -- +bool(false) +--Multibyte String -- +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_variation1.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_variation1.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_variation1.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,179 @@ +--TEST-- +Test iconv_strrpos() function : usage variations - pass different data types to $haystack arg +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strrpos() different data types as $haystack argument to test behaviour + */ + +echo "*** Testing iconv_strrpos() : usage variations ***\n"; + +// Initialise function arguments not being substituted +$needle = 'world'; +$encoding = 'utf-8'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "hello, world"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello, world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $haystack argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + + // string data +/*18*/ "hello, world", + 'hello, world', + $heredoc, + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, + + // resource variable +/*24*/ $fp +); + +// loop through each element of $inputs to check the behavior of iconv_strrpos() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( iconv_strrpos($input, $needle, $encoding)); + $iterator++; +}; + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : usage variations *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- +int(7) + +-- Iteration 19 -- +int(7) + +-- Iteration 20 -- +int(7) + +-- Iteration 21 -- +int(7) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: iconv_strrpos() expects parameter 1 to be binary string, resource given in %s on line %d +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_basic.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_basic.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_basic.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,72 @@ +--TEST-- +Test iconv() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv') or die("skip iconv() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : string iconv(string in_charset, string out_charset, string str) + * Description: Returns converted string in desired encoding + * Source code: ext/iconv/iconv.c + */ + +/* + * Test basic functionality of iconv() + */ + +echo "*** Testing iconv() : basic functionality ***\n"; + +//All strings are the same when displayed in their respective encodings +$sjis_string = base64_decode(b'k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg=='); +$euc_jp_string = base64_decode(b'xvzL3LjspcalraW5pcikx6S5oaMwMTIzNKO1o7ajt6O4o7mhow=='); +$utf8_string = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); + +echo "\n-- Convert to EUC-JP --\n"; +echo "Expected EUC-JP encoded string in base64:\n"; +var_dump(bin2hex($euc_jp_string)); +echo "Converted Strings:\n"; +var_dump(bin2hex(iconv('SJIS', 'EUC-JP', $sjis_string ))); +var_dump(bin2hex(iconv('UTF-8', 'EUC-JP', $utf8_string))); + +echo "\n-- Convert to SJIS --\n"; +echo "Expected SJIS encoded string in base64:\n"; +var_dump(bin2hex($sjis_string)); +echo "Converted Strings:\n"; +var_dump(bin2hex(iconv('EUC-JP', 'SJIS', $euc_jp_string))); +var_dump(bin2hex(iconv('UTF-8', 'SJIS', $utf8_string))); + +echo "\n-- Convert to UTF-8 --\n"; +echo "Expected UTF-8 encoded string in base64:\n"; +var_dump(bin2hex($utf8_string)); +echo "Converted Strings:\n"; +var_dump(bin2hex(iconv('SJIS', 'UTF-8', $sjis_string))); +var_dump(bin2hex(iconv('EUC-JP', 'UTF-8', $euc_jp_string))); + +?> +===DONE=== +--EXPECT-- +*** Testing iconv() : basic functionality *** + +-- Convert to EUC-JP -- +Expected EUC-JP encoded string in base64: +unicode(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3" +Converted Strings: +unicode(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3" +unicode(74) "c6fccbdcb8eca5c6a5ada5b9a5c8a4c7a4b9a1a33031323334a3b5a3b6a3b7a3b8a3b9a1a3" + +-- Convert to SJIS -- +Expected SJIS encoded string in base64: +unicode(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142" +Converted Strings: +unicode(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142" +unicode(74) "93fa967b8cea8365834c8358836782c582b781423031323334825482558256825782588142" + +-- Convert to UTF-8 -- +Expected UTF-8 encoded string in base64: +unicode(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" +Converted Strings: +unicode(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" +unicode(106) "e697a5e69cace8aa9ee38386e382ade382b9e38388e381a7e38199e380823031323334efbc95efbc96efbc97efbc98efbc99e38082" +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos_error2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos_error2.phpt diff -u /dev/null php-src/ext/iconv/tests/iconv_strrpos_error2.phpt:1.2 --- /dev/null Fri Jun 12 17:16:06 2009 +++ php-src/ext/iconv/tests/iconv_strrpos_error2.phpt Fri Jun 12 17:16:06 2009 @@ -0,0 +1,35 @@ +--TEST-- +Test iconv_strrpos() function : error conditions - pass an unknown encoding +--SKIPIF-- +<?php +extension_loaded('iconv') or die('skip'); +function_exists('iconv_strrpos') or die("skip iconv_strrpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : proto int iconv_strrpos(string haystack, string needle [, string charset]) + * Description: Find position of last occurrence of a string within another + * Source code: ext/iconv/iconv.c + */ + +/* + * Pass iconv_strrpos() an encoding that doesn't exist + */ + +echo "*** Testing iconv_strrpos() : error conditions ***\n"; + +$haystack = 'This is an English string. 0123456789.'; +$needle = '123'; +$offset = 5; +$encoding = 'unknown-encoding'; + +var_dump(iconv_strrpos($haystack, $needle , $encoding)); + +?> +===DONE=== +--EXPECTF-- +*** Testing iconv_strrpos() : error conditions *** + +Notice: iconv_strrpos(): Wrong charset, conversion from `unknown-encoding' to `UCS-4LE' is not allowed in %s on line %d +bool(false) +===DONE=== \ No newline at end of file
« previous php.cvs (#58680) next »