Browse Source
New string function tests. Tested on Windows, Linux and Linux 64 bit.
experimental/5.3-FPM
New string function tests. Tested on Windows, Linux and Linux 64 bit.
experimental/5.3-FPM
22 changed files with 3374 additions and 50 deletions
-
96ext/standard/tests/strings/addslashes_variation1.phpt
-
50ext/standard/tests/strings/bin2hex_basic.phpt
-
35ext/standard/tests/strings/bin2hex_error.phpt
-
128ext/standard/tests/strings/bin2hex_variation1.phpt
-
4ext/standard/tests/strings/bug37262.phpt
-
10ext/standard/tests/strings/bug45166.phpt
-
23ext/standard/tests/strings/chr_basic.phpt
-
34ext/standard/tests/strings/chr_error.phpt
-
123ext/standard/tests/strings/chr_variation1.phpt
-
165ext/standard/tests/strings/convert_cyr_string_basic.phpt
-
73ext/standard/tests/strings/convert_cyr_string_error.phpt
-
139ext/standard/tests/strings/convert_cyr_string_variation1.phpt
-
54ext/standard/tests/strings/convert_uudecode_basic.phpt
-
35ext/standard/tests/strings/convert_uudecode_error.phpt
-
161ext/standard/tests/strings/convert_uudecode_variation1.phpt
-
88ext/standard/tests/strings/convert_uuencode_basic.phpt
-
35ext/standard/tests/strings/convert_uuencode_error.phpt
-
137ext/standard/tests/strings/convert_uuencode_variation1.phpt
-
1574ext/standard/tests/strings/count_chars_basic.phpt
-
36ext/standard/tests/strings/count_chars_error.phpt
-
262ext/standard/tests/strings/count_chars_variation1.phpt
-
162ext/standard/tests/strings/count_chars_variation2.phpt
@ -0,0 +1,50 @@ |
|||||
|
--TEST-- |
||||
|
Test bin2hex() function : basic functionality |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string bin2hex ( string $str ) |
||||
|
* Description: Convert binary data into hexadecimal representation |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing bin2hex() : basic functionality ***\n"; |
||||
|
|
||||
|
// array with different values for $string |
||||
|
$strings = array ( |
||||
|
|
||||
|
//double quoted strings |
||||
|
/*1*/ "Here is a simple string", |
||||
|
"\t This String contains \t\t some control characters\r\n", |
||||
|
"\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f", |
||||
|
|
||||
|
//single quoted strings |
||||
|
/*4*/ 'Here is a simple string', |
||||
|
'\t This String contains \t\t some control characters\r\n', |
||||
|
'\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f', |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $strings array to test bin2hex() function |
||||
|
$count = 1; |
||||
|
foreach($strings as $string) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump(bin2hex($string)); |
||||
|
$count ++; |
||||
|
} |
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECT-- |
||||
|
*** Testing bin2hex() : basic functionality *** |
||||
|
-- Iteration 1 -- |
||||
|
string(46) "4865726520697320612073696d706c6520737472696e67" |
||||
|
-- Iteration 2 -- |
||||
|
string(102) "09205468697320537472696e6720636f6e7461696e7320090920736f6d6520636f6e74726f6c20636861726163746572730d0a" |
||||
|
-- Iteration 3 -- |
||||
|
string(36) "9091009394909195969798999a9b9c9d9e9f" |
||||
|
-- Iteration 4 -- |
||||
|
string(46) "4865726520697320612073696d706c6520737472696e67" |
||||
|
-- Iteration 5 -- |
||||
|
string(112) "5c74205468697320537472696e6720636f6e7461696e73205c745c7420736f6d6520636f6e74726f6c20636861726163746572735c725c6e" |
||||
|
-- Iteration 6 -- |
||||
|
string(144) "5c7839305c7839315c7830305c7839335c7839345c7839305c7839315c7839355c7839365c7839375c7839385c7839395c7839615c7839625c7839635c7839645c7839655c783966" |
||||
|
===DONE=== |
||||
@ -0,0 +1,35 @@ |
|||||
|
--TEST-- |
||||
|
Test bin2hex() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string bin2hex ( string $str ) |
||||
|
* Description: Convert binary data into hexadecimal representation |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing bin2hex() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing bin2hex() function with no arguments --\n"; |
||||
|
var_dump( bin2hex() ); |
||||
|
|
||||
|
echo "\n-- Testing bin2hex() function with more than expected no. of arguments --\n"; |
||||
|
$extra_arg = 10; |
||||
|
var_dump( bin2hex("Hello World", $extra_arg) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing bin2hex() : error conditions *** |
||||
|
|
||||
|
-- Testing bin2hex() function with no arguments -- |
||||
|
|
||||
|
Warning: bin2hex() expects exactly 1 parameter, 0 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing bin2hex() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: bin2hex() expects exactly 1 parameter, 2 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
===DONE=== |
||||
@ -0,0 +1,128 @@ |
|||||
|
--TEST-- |
||||
|
Test bin2hex() function : usage variations - test values for $str argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string bin2hex ( string $str ) |
||||
|
* Description: Convert binary data into hexadecimal representation |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing bin2hex() function: with unexpected inputs for 'str' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $input |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/*1*/ 0, |
||||
|
1, |
||||
|
123456, |
||||
|
|
||||
|
// float values |
||||
|
/*4*/ 10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/*7*/ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/*10*/true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/*14*/NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/*16*/new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/*17*/$file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/*18*/@$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/*19*/@$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $inputs array to test bin2hex() function |
||||
|
$count = 1; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump(bin2hex($input) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing bin2hex() function: with unexpected inputs for 'str' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
string(2) "30" |
||||
|
-- Iteration 2 -- |
||||
|
string(2) "31" |
||||
|
-- Iteration 3 -- |
||||
|
string(12) "313233343536" |
||||
|
-- Iteration 4 -- |
||||
|
string(8) "31302e35" |
||||
|
-- Iteration 5 -- |
||||
|
string(10) "2d32302e35" |
||||
|
-- Iteration 6 -- |
||||
|
string(24) "313031323334353637303030" |
||||
|
-- Iteration 7 -- |
||||
|
|
||||
|
Warning: bin2hex() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 8 -- |
||||
|
|
||||
|
Warning: bin2hex() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 9 -- |
||||
|
|
||||
|
Warning: bin2hex() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 10 -- |
||||
|
string(2) "31" |
||||
|
-- Iteration 11 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 12 -- |
||||
|
string(2) "31" |
||||
|
-- Iteration 13 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 14 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 15 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 16 -- |
||||
|
string(26) "73616d706c65206f626a656374" |
||||
|
-- Iteration 17 -- |
||||
|
|
||||
|
Warning: bin2hex() expects parameter 1 to be string, resource given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 18 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 19 -- |
||||
|
string(0) "" |
||||
|
===DONE=== |
||||
@ -0,0 +1,10 @@ |
|||||
|
--TEST-- |
||||
|
Bug #45166 (substr() ) |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
echo substr('cd', -3) . "\n"; |
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECT-- |
||||
|
cd |
||||
|
===DONE=== |
||||
@ -0,0 +1,23 @@ |
|||||
|
--TEST-- |
||||
|
Test chr() function : basic functionality |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string chr ( int $ascii ) |
||||
|
* Description: Return a specific character |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing chr() : basic functionality ***\n"; |
||||
|
|
||||
|
echo chr(72). chr(101) . chr(108) . chr(108). chr(111); // Hello |
||||
|
echo chr(10); // "\n" |
||||
|
echo "World"; |
||||
|
echo "\n"; |
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing chr() : basic functionality *** |
||||
|
Hello |
||||
|
World |
||||
|
===DONE=== |
||||
@ -0,0 +1,34 @@ |
|||||
|
--TEST-- |
||||
|
Test chr() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string chr ( int $ascii ) |
||||
|
* Description: Return a specific character |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing chr() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing chr() function with no arguments --\n"; |
||||
|
var_dump( chr() ); |
||||
|
|
||||
|
echo "\n-- Testing chr() function with more than expected no. of arguments --\n"; |
||||
|
$extra_arg = 10; |
||||
|
var_dump( chr(72, $extra_arg) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing chr() : error conditions *** |
||||
|
|
||||
|
-- Testing chr() function with no arguments -- |
||||
|
|
||||
|
Warning: Wrong parameter count for chr() in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing chr() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: Wrong parameter count for chr() in %s on line %d |
||||
|
NULL |
||||
|
===DONE=== |
||||
@ -0,0 +1,123 @@ |
|||||
|
--TEST-- |
||||
|
Test chr() function : usage variations - test values for $ascii argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string chr ( int $ascii ) |
||||
|
* Description: Return a specific character |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing chr() function: with unexpected inputs for 'ascii' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $input |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/*1*/ 0, |
||||
|
1, |
||||
|
255, |
||||
|
256, |
||||
|
|
||||
|
// float values |
||||
|
/*5*/ 10.5, |
||||
|
-20.5, |
||||
|
1.1234e6, |
||||
|
|
||||
|
// array values |
||||
|
/*8*/ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/*11*/ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/*15*/ NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/*17*/ new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/*18*/ $file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/*19*/ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/*20*/ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $inputs array to test chr() function |
||||
|
$count = 1; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump( bin2hex(chr($input)) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing chr() function: with unexpected inputs for 'ascii' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 2 -- |
||||
|
string(2) "01" |
||||
|
-- Iteration 3 -- |
||||
|
string(2) "ff" |
||||
|
-- Iteration 4 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 5 -- |
||||
|
string(2) "0a" |
||||
|
-- Iteration 6 -- |
||||
|
string(2) "ec" |
||||
|
-- Iteration 7 -- |
||||
|
string(2) "48" |
||||
|
-- Iteration 8 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 9 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 10 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 11 -- |
||||
|
string(2) "01" |
||||
|
-- Iteration 12 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 13 -- |
||||
|
string(2) "01" |
||||
|
-- Iteration 14 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 15 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 16 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 17 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 18 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 19 -- |
||||
|
string(2) "00" |
||||
|
-- Iteration 20 -- |
||||
|
string(2) "00" |
||||
|
===DONE=== |
||||
@ -0,0 +1,165 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_cyr_string() function : basic functionality |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_cyr_string ( string $str , string $from , string $to ) |
||||
|
* Description: Convert from one Cyrillic character set to another |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_cyr_string() : basic functionality ***\n"; |
||||
|
|
||||
|
$str = "Convert from one Cyrillic character set to another."; |
||||
|
|
||||
|
echo "\n-- First try some simple English text --\n"; |
||||
|
var_dump(bin2hex(convert_cyr_string($str, 'w', 'k'))); |
||||
|
var_dump(bin2hex(convert_cyr_string($str, 'w', 'i'))); |
||||
|
|
||||
|
|
||||
|
echo "\n-- Now try some of characters in 128-255 range --\n"; |
||||
|
|
||||
|
for ($i = 128; $i < 256; $i++) { |
||||
|
$str = chr($i); |
||||
|
echo "$i: " . bin2hex(convert_cyr_string($str, 'w', 'k')) . "\n"; |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_cyr_string() : basic functionality *** |
||||
|
|
||||
|
-- First try some simple English text -- |
||||
|
string(102) "436f6e766572742066726f6d206f6e6520437972696c6c6963206368617261637465722073657420746f20616e6f746865722e" |
||||
|
string(102) "436f6e766572742066726f6d206f6e6520437972696c6c6963206368617261637465722073657420746f20616e6f746865722e" |
||||
|
|
||||
|
-- Now try some of characters in 128-255 range -- |
||||
|
128: 2e |
||||
|
129: 2e |
||||
|
130: 2e |
||||
|
131: 2e |
||||
|
132: 2e |
||||
|
133: 2e |
||||
|
134: 2e |
||||
|
135: 2e |
||||
|
136: 2e |
||||
|
137: 2e |
||||
|
138: 2e |
||||
|
139: 2e |
||||
|
140: 2e |
||||
|
141: 2e |
||||
|
142: 2e |
||||
|
143: 2e |
||||
|
144: 2e |
||||
|
145: 2e |
||||
|
146: 2e |
||||
|
147: 2e |
||||
|
148: 2e |
||||
|
149: 2e |
||||
|
150: 2e |
||||
|
151: 2e |
||||
|
152: 2e |
||||
|
153: 2e |
||||
|
154: 2e |
||||
|
155: 2e |
||||
|
156: 2e |
||||
|
157: 2e |
||||
|
158: 2e |
||||
|
159: 2e |
||||
|
160: 9a |
||||
|
161: ae |
||||
|
162: be |
||||
|
163: 2e |
||||
|
164: 9f |
||||
|
165: bd |
||||
|
166: 2e |
||||
|
167: 2e |
||||
|
168: b3 |
||||
|
169: bf |
||||
|
170: b4 |
||||
|
171: 9d |
||||
|
172: 2e |
||||
|
173: 2e |
||||
|
174: 9c |
||||
|
175: b7 |
||||
|
176: 2e |
||||
|
177: 2e |
||||
|
178: b6 |
||||
|
179: a6 |
||||
|
180: ad |
||||
|
181: 2e |
||||
|
182: 2e |
||||
|
183: 9e |
||||
|
184: a3 |
||||
|
185: 98 |
||||
|
186: a4 |
||||
|
187: 9b |
||||
|
188: 2e |
||||
|
189: 2e |
||||
|
190: 2e |
||||
|
191: a7 |
||||
|
192: e1 |
||||
|
193: e2 |
||||
|
194: f7 |
||||
|
195: e7 |
||||
|
196: e4 |
||||
|
197: e5 |
||||
|
198: f6 |
||||
|
199: fa |
||||
|
200: e9 |
||||
|
201: ea |
||||
|
202: eb |
||||
|
203: ec |
||||
|
204: ed |
||||
|
205: ee |
||||
|
206: ef |
||||
|
207: f0 |
||||
|
208: f2 |
||||
|
209: f3 |
||||
|
210: f4 |
||||
|
211: f5 |
||||
|
212: e6 |
||||
|
213: e8 |
||||
|
214: e3 |
||||
|
215: fe |
||||
|
216: fb |
||||
|
217: fd |
||||
|
218: ff |
||||
|
219: f9 |
||||
|
220: f8 |
||||
|
221: fc |
||||
|
222: e0 |
||||
|
223: f1 |
||||
|
224: c1 |
||||
|
225: c2 |
||||
|
226: d7 |
||||
|
227: c7 |
||||
|
228: c4 |
||||
|
229: c5 |
||||
|
230: d6 |
||||
|
231: da |
||||
|
232: c9 |
||||
|
233: ca |
||||
|
234: cb |
||||
|
235: cc |
||||
|
236: cd |
||||
|
237: ce |
||||
|
238: cf |
||||
|
239: d0 |
||||
|
240: d2 |
||||
|
241: d3 |
||||
|
242: d4 |
||||
|
243: d5 |
||||
|
244: c6 |
||||
|
245: c8 |
||||
|
246: c3 |
||||
|
247: de |
||||
|
248: db |
||||
|
249: dd |
||||
|
250: df |
||||
|
251: d9 |
||||
|
252: d8 |
||||
|
253: dc |
||||
|
254: c0 |
||||
|
255: d1 |
||||
|
===DONE=== |
||||
@ -0,0 +1,73 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_cyr_string() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_cyr_string ( string $str , string $from , string $to ) |
||||
|
* Description: Convert from one Cyrillic character set to another |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
$str = "hello"; |
||||
|
$from = "k"; |
||||
|
$to = "d"; |
||||
|
$extra_arg = 10; |
||||
|
|
||||
|
echo "*** Testing convert_cyr_string() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with no arguments --\n"; |
||||
|
var_dump( convert_cyr_string() ); |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with no 'to' character set --\n"; |
||||
|
var_dump( convert_cyr_string($str, $from) ); |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with more than expected no. of arguments --\n"; |
||||
|
var_dump( convert_cyr_string($str, $from, $to, $extra_arg) ); |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with invalid 'from' character set --\n"; |
||||
|
var_dump(bin2hex( convert_cyr_string($str, "?", $to) )); |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with invalid 'to' character set --\n"; |
||||
|
var_dump(bin2hex( convert_cyr_string($str, $from, "?")) ); |
||||
|
|
||||
|
echo "\n-- Testing convert_cyr_string() function with invalid 'from' and 'to' character set --\n"; |
||||
|
var_dump(bin2hex( convert_cyr_string($str, ">", "?")) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_cyr_string() : error conditions *** |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with no arguments -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects exactly 3 parameters, 0 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with no 'to' character set -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects exactly 3 parameters, 2 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects exactly 3 parameters, 4 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with invalid 'from' character set -- |
||||
|
|
||||
|
Warning: convert_cyr_string(): Unknown source charset: ? in %s on line %d |
||||
|
string(10) "68656c6c6f" |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with invalid 'to' character set -- |
||||
|
|
||||
|
Warning: convert_cyr_string(): Unknown destination charset: ? in %s on line %d |
||||
|
string(10) "68656c6c6f" |
||||
|
|
||||
|
-- Testing convert_cyr_string() function with invalid 'from' and 'to' character set -- |
||||
|
|
||||
|
Warning: convert_cyr_string(): Unknown source charset: > in %s on line %d |
||||
|
|
||||
|
Warning: convert_cyr_string(): Unknown destination charset: ? in %s on line %d |
||||
|
string(10) "68656c6c6f" |
||||
|
|
||||
|
===DONE=== |
||||
@ -0,0 +1,139 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_cyr_string() function : usage variations - test values for $str argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_cyr_string ( string $str , string $from , string $to ) |
||||
|
* Description: Convert from one Cyrillic character set to another |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_cyr_string() function: with unexpected inputs for 'str' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $str |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/*1*/ 0, |
||||
|
1, |
||||
|
255, |
||||
|
256, |
||||
|
2147483647, |
||||
|
-2147483648, |
||||
|
|
||||
|
// float values |
||||
|
/*7*/ 10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/*10*/ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/*13*/ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/*17*/ NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/*19*/ new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/*20*/ $file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/*21*/ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/*22*/ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $inputs array to test convert_cyr_string() function |
||||
|
$count = 1; |
||||
|
$from = "w"; |
||||
|
$to = "k"; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump( convert_cyr_string($input, $from, $to) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_cyr_string() function: with unexpected inputs for 'str' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
string(1) "0" |
||||
|
-- Iteration 2 -- |
||||
|
string(1) "1" |
||||
|
-- Iteration 3 -- |
||||
|
string(3) "255" |
||||
|
-- Iteration 4 -- |
||||
|
string(3) "256" |
||||
|
-- Iteration 5 -- |
||||
|
string(10) "2147483647" |
||||
|
-- Iteration 6 -- |
||||
|
string(11) "-2147483648" |
||||
|
-- Iteration 7 -- |
||||
|
string(4) "10.5" |
||||
|
-- Iteration 8 -- |
||||
|
string(5) "-20.5" |
||||
|
-- Iteration 9 -- |
||||
|
string(12) "101234567000" |
||||
|
-- Iteration 10 -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 11 -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 12 -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 13 -- |
||||
|
string(1) "1" |
||||
|
-- Iteration 14 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 15 -- |
||||
|
string(1) "1" |
||||
|
-- Iteration 16 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 17 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 18 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 19 -- |
||||
|
string(13) "sample object" |
||||
|
-- Iteration 20 -- |
||||
|
|
||||
|
Warning: convert_cyr_string() expects parameter 1 to be string, resource given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 21 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 22 -- |
||||
|
string(0) "" |
||||
|
===DONE=== |
||||
@ -0,0 +1,54 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uudecode() function : basic functionality |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uudecode ( string $data ) |
||||
|
* Description: Decode a uuencoded string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uudecode() : basic functionality ***\n"; |
||||
|
|
||||
|
// array with different values for $string |
||||
|
$strings = array ( |
||||
|
|
||||
|
//double quoted strings |
||||
|
"123", |
||||
|
"abc", |
||||
|
"1a2b3c", |
||||
|
"Here is a simple string to test convert_uuencode/decode", |
||||
|
"\t This String contains \t\t some control characters\r\n", |
||||
|
"\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f", |
||||
|
|
||||
|
//single quoted strings |
||||
|
'123', |
||||
|
'abc', |
||||
|
'1a2b3c', |
||||
|
'\t This String contains \t\t some control characters\r\n', |
||||
|
|
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $strings array to test convert_uudecode() function |
||||
|
$count = 1; |
||||
|
foreach($strings as $string) { |
||||
|
|
||||
|
$encode = convert_uuencode($string); |
||||
|
$decode = convert_uudecode($encode); |
||||
|
|
||||
|
if ($decode != $string) { |
||||
|
var_dump($encode, $decode, $string); |
||||
|
exit("TEST FAILED on iteration $count\n"); |
||||
|
} |
||||
|
|
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
echo "TEST PASSED\n"; |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uudecode() : basic functionality *** |
||||
|
TEST PASSED |
||||
|
===DONE=== |
||||
@ -0,0 +1,35 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uudecode() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uudecode ( string $data ) |
||||
|
* Description: Decode a uuencoded string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uudecode() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing convert_uudecode() function with no arguments --\n"; |
||||
|
var_dump( convert_uudecode() ); |
||||
|
|
||||
|
echo "\n-- Testing convert_uudecode() function with more than expected no. of arguments --\n"; |
||||
|
$extra_arg = 10; |
||||
|
var_dump( convert_uudecode(72, $extra_arg) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uudecode() : error conditions *** |
||||
|
|
||||
|
-- Testing convert_uudecode() function with no arguments -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects exactly 1 parameter, 0 given in %s on line %d |
||||
|
bool(false) |
||||
|
|
||||
|
-- Testing convert_uudecode() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects exactly 1 parameter, 2 given in %s on line %d |
||||
|
bool(false) |
||||
|
|
||||
|
===DONE=== |
||||
@ -0,0 +1,161 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uudecode() function : usage variations - test values for $data argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uudecode ( string $data ) |
||||
|
* Description: Decode a uuencoded string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uudecode() function: with unexpected inputs for 'data' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $data |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/*1*/ 0, |
||||
|
1, |
||||
|
255, |
||||
|
256, |
||||
|
2147483647, |
||||
|
-2147483648, |
||||
|
|
||||
|
// float values |
||||
|
/*7*/ 10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/*10*/ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/*13*/ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/*17*/ NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/*19*/ new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/*20*/ $file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/*21*/ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/*22*/ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $data array to test convert_uudecode() function |
||||
|
$count = 1; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump( convert_uudecode($input) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uudecode() function: with unexpected inputs for 'data' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 2 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 3 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 4 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 5 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 6 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 7 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 8 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 9 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 10 -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 11 -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 12 -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 13 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 14 -- |
||||
|
bool(false) |
||||
|
-- Iteration 15 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 16 -- |
||||
|
bool(false) |
||||
|
-- Iteration 17 -- |
||||
|
bool(false) |
||||
|
-- Iteration 18 -- |
||||
|
bool(false) |
||||
|
-- Iteration 19 -- |
||||
|
|
||||
|
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 20 -- |
||||
|
|
||||
|
Warning: convert_uudecode() expects parameter 1 to be string, resource given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 21 -- |
||||
|
bool(false) |
||||
|
-- Iteration 22 -- |
||||
|
bool(false) |
||||
|
===DONE=== |
||||
@ -0,0 +1,88 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uuencode() function : basic functionality |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uuencode ( string $data ) |
||||
|
* Description: Uuencode a string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uuencode() : basic functionality ***\n"; |
||||
|
|
||||
|
// array with different values for $string |
||||
|
$strings = array ( |
||||
|
|
||||
|
//double quoted strings |
||||
|
b"123", |
||||
|
b"abc", |
||||
|
b"1a2b3c", |
||||
|
b"Here is a simple string to test convert_uuencode/decode", |
||||
|
b"\t This String contains \t\t some control characters\r\n", |
||||
|
b"\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f", |
||||
|
|
||||
|
//single quoted strings |
||||
|
b'123', |
||||
|
b'abc', |
||||
|
b'1a2b3c', |
||||
|
b'\t This String contains \t\t some control characters\r\n', |
||||
|
|
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $strings array to test convert_uuencode() function |
||||
|
$count = 1; |
||||
|
foreach($strings as $string) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump( convert_uuencode($string) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uuencode() : basic functionality *** |
||||
|
-- Iteration 1 -- |
||||
|
string(8) "#,3(S |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 2 -- |
||||
|
string(8) "#86)C |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 3 -- |
||||
|
string(12) "&,6$R8C-C |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 4 -- |
||||
|
string(82) "M2&5R92!I<R!A('-I;7!L92!S=')I;F<@=&\@=&5S="!C;VYV97)T7W5U96YC |
||||
|
*;V1E+V1E8V]D90`` |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 5 -- |
||||
|
string(74) "M"2!4:&ES(%-T<FEN9R!C;VYT86EN<R`)"2!S;VUE(&-O;G1R;VP@8VAA<F%C |
||||
|
&=&5R<PT* |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 6 -- |
||||
|
string(28) "2D)$`DY20D966EYB9FIN<G9Z? |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 7 -- |
||||
|
string(8) "#,3(S |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 8 -- |
||||
|
string(8) "#86)C |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 9 -- |
||||
|
string(12) "&,6$R8C-C |
||||
|
` |
||||
|
" |
||||
|
-- Iteration 10 -- |
||||
|
string(82) "M7'0@5&AI<R!3=')I;F<@8V]N=&%I;G,@7'1<="!S;VUE(&-O;G1R;VP@8VAA |
||||
|
+<F%C=&5R<UQR7&X` |
||||
|
` |
||||
|
" |
||||
|
===DONE=== |
||||
@ -0,0 +1,35 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uuencode() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uuencode ( string $data ) |
||||
|
* Description: Uuencode a string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uuencode() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing chconvert_uuencoder() function with no arguments --\n"; |
||||
|
var_dump( convert_uuencode() ); |
||||
|
|
||||
|
echo "\n-- Testing convert_uuencode() function with more than expected no. of arguments --\n"; |
||||
|
$extra_arg = 10; |
||||
|
var_dump( convert_uuencode(72, $extra_arg) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uuencode() : error conditions *** |
||||
|
|
||||
|
-- Testing chconvert_uuencoder() function with no arguments -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects exactly 1 parameter, 0 given in %s on line %d |
||||
|
bool(false) |
||||
|
|
||||
|
-- Testing convert_uuencode() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects exactly 1 parameter, 2 given in %s on line %d |
||||
|
bool(false) |
||||
|
|
||||
|
===DONE=== |
||||
@ -0,0 +1,137 @@ |
|||||
|
--TEST-- |
||||
|
Test convert_uuencode() function : usage variations - test values for $data argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : string convert_uuencode ( string $data ) |
||||
|
* Description: Uuencode a string |
||||
|
* Source code: ext/standard/uuencode.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing convert_uuencode() function: with unexpected inputs for 'data' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $data |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/*1*/ 0, |
||||
|
1, |
||||
|
255, |
||||
|
256, |
||||
|
2147483647, |
||||
|
-2147483648, |
||||
|
|
||||
|
// float values |
||||
|
/*7*/ 10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/*10*/ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/*13*/ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/*17*/ NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/*19*/ new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/*20*/ $file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/*21*/ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/*22*/ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $data array to test convert_uuencode() function |
||||
|
$count = 1; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
var_dump( bin2hex(convert_uuencode($input)) ); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing convert_uuencode() function: with unexpected inputs for 'data' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
string(16) "212c6060600a600a" |
||||
|
-- Iteration 2 -- |
||||
|
string(16) "212c3060600a600a" |
||||
|
-- Iteration 3 -- |
||||
|
string(16) "232c4334550a600a" |
||||
|
-- Iteration 4 -- |
||||
|
string(16) "232c4334560a600a" |
||||
|
-- Iteration 5 -- |
||||
|
string(40) "2a2c4324542d5330582c5338542d5060600a600a" |
||||
|
-- Iteration 6 -- |
||||
|
string(40) "2b2b3328512d233c542e232c562d2340600a600a" |
||||
|
-- Iteration 7 -- |
||||
|
string(24) "242c33604e2d3060600a600a" |
||||
|
-- Iteration 8 -- |
||||
|
string(24) "252b3328502b4334600a600a" |
||||
|
-- Iteration 9 -- |
||||
|
string(40) "2c2c3360512c432c542d3338572c2360500a600a" |
||||
|
-- Iteration 10 -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
string(0) "" |
||||
|
-- Iteration 11 -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
string(0) "" |
||||
|
-- Iteration 12 -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects parameter 1 to be string, array given in %s on line %d |
||||
|
string(0) "" |
||||
|
-- Iteration 13 -- |
||||
|
string(16) "212c3060600a600a" |
||||
|
-- Iteration 14 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 15 -- |
||||
|
string(16) "212c3060600a600a" |
||||
|
-- Iteration 16 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 17 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 18 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 19 -- |
||||
|
string(48) "2d3c56254d3c26514528265d423a4635433d6060600a600a" |
||||
|
-- Iteration 20 -- |
||||
|
|
||||
|
Warning: convert_uuencode() expects parameter 1 to be string, resource given in %s on line %d |
||||
|
string(0) "" |
||||
|
-- Iteration 21 -- |
||||
|
string(0) "" |
||||
|
-- Iteration 22 -- |
||||
|
string(0) "" |
||||
|
===DONE=== |
||||
1574
ext/standard/tests/strings/count_chars_basic.phpt
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,36 @@ |
|||||
|
--TEST-- |
||||
|
Test count_chars() function : error conditions |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : mixed count_chars ( string $string [, int $mode ] ) |
||||
|
* Description: Return information about characters used in a string |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing count_chars() : error conditions ***\n"; |
||||
|
|
||||
|
echo "\n-- Testing count_chars() function with no arguments --\n"; |
||||
|
var_dump( count_chars() ); |
||||
|
|
||||
|
echo "\n-- Testing count_chars() function with more than expected no. of arguments --\n"; |
||||
|
$string = "Hello World\n"; |
||||
|
$mode = 1; |
||||
|
$extra_arg = 10; |
||||
|
var_dump( count_chars($string, $mode, $extra_arg) ); |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing count_chars() : error conditions *** |
||||
|
|
||||
|
-- Testing count_chars() function with no arguments -- |
||||
|
|
||||
|
Warning: count_chars() expects at least 1 parameter, 0 given in %s on line %d |
||||
|
NULL |
||||
|
|
||||
|
-- Testing count_chars() function with more than expected no. of arguments -- |
||||
|
|
||||
|
Warning: count_chars() expects at most 2 parameters, 3 given in %s on line %d |
||||
|
NULL |
||||
|
===DONE=== |
||||
@ -0,0 +1,262 @@ |
|||||
|
--TEST-- |
||||
|
Test count_chars() function : usage variations - test values for $string argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : mixed count_chars ( string $string [, int $mode ] ) |
||||
|
* Description: Return information about characters used in a string |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing count_chars() function: with unexpected inputs for 'string' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
public function __toString() { |
||||
|
return "sample object"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//getting the resource |
||||
|
$file_handle = fopen(__FILE__, "r"); |
||||
|
|
||||
|
// array with different values for $input |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/* 1 */ 0, |
||||
|
1, |
||||
|
255, |
||||
|
256, |
||||
|
2147483647, |
||||
|
-2147483648, |
||||
|
|
||||
|
// float values |
||||
|
/* 7 */ 10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/* 10 */ array(), |
||||
|
array(0), |
||||
|
array(1, 2), |
||||
|
|
||||
|
// boolean values |
||||
|
/* 13 */ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/* 17 */ NULL, |
||||
|
null, |
||||
|
|
||||
|
// objects |
||||
|
/* 19 */ new sample(), |
||||
|
|
||||
|
// resource |
||||
|
/* 20 */ $file_handle, |
||||
|
|
||||
|
// undefined variable |
||||
|
/* 21 */ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/* 22 */ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $inputs array to test count_chars() function |
||||
|
$count = 1; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
// only list characters with a frequency > 0 |
||||
|
var_dump(count_chars($input, 1)); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
fclose($file_handle); //closing the file handle |
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing count_chars() function: with unexpected inputs for 'string' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
array(1) { |
||||
|
[48]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 2 -- |
||||
|
array(1) { |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 3 -- |
||||
|
array(2) { |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[53]=> |
||||
|
int(2) |
||||
|
} |
||||
|
-- Iteration 4 -- |
||||
|
array(3) { |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[53]=> |
||||
|
int(1) |
||||
|
[54]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 5 -- |
||||
|
array(7) { |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[51]=> |
||||
|
int(1) |
||||
|
[52]=> |
||||
|
int(3) |
||||
|
[54]=> |
||||
|
int(1) |
||||
|
[55]=> |
||||
|
int(2) |
||||
|
[56]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 6 -- |
||||
|
array(8) { |
||||
|
[45]=> |
||||
|
int(1) |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[51]=> |
||||
|
int(1) |
||||
|
[52]=> |
||||
|
int(3) |
||||
|
[54]=> |
||||
|
int(1) |
||||
|
[55]=> |
||||
|
int(1) |
||||
|
[56]=> |
||||
|
int(2) |
||||
|
} |
||||
|
-- Iteration 7 -- |
||||
|
array(4) { |
||||
|
[46]=> |
||||
|
int(1) |
||||
|
[48]=> |
||||
|
int(1) |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
[53]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 8 -- |
||||
|
array(5) { |
||||
|
[45]=> |
||||
|
int(1) |
||||
|
[46]=> |
||||
|
int(1) |
||||
|
[48]=> |
||||
|
int(1) |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[53]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 9 -- |
||||
|
array(8) { |
||||
|
[48]=> |
||||
|
int(4) |
||||
|
[49]=> |
||||
|
int(2) |
||||
|
[50]=> |
||||
|
int(1) |
||||
|
[51]=> |
||||
|
int(1) |
||||
|
[52]=> |
||||
|
int(1) |
||||
|
[53]=> |
||||
|
int(1) |
||||
|
[54]=> |
||||
|
int(1) |
||||
|
[55]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 10 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 11 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 12 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 1 to be string, array given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 13 -- |
||||
|
array(1) { |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 14 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
-- Iteration 15 -- |
||||
|
array(1) { |
||||
|
[49]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 16 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
-- Iteration 17 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
-- Iteration 18 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
-- Iteration 19 -- |
||||
|
array(12) { |
||||
|
[32]=> |
||||
|
int(1) |
||||
|
[97]=> |
||||
|
int(1) |
||||
|
[98]=> |
||||
|
int(1) |
||||
|
[99]=> |
||||
|
int(1) |
||||
|
[101]=> |
||||
|
int(2) |
||||
|
[106]=> |
||||
|
int(1) |
||||
|
[108]=> |
||||
|
int(1) |
||||
|
[109]=> |
||||
|
int(1) |
||||
|
[111]=> |
||||
|
int(1) |
||||
|
[112]=> |
||||
|
int(1) |
||||
|
[115]=> |
||||
|
int(1) |
||||
|
[116]=> |
||||
|
int(1) |
||||
|
} |
||||
|
-- Iteration 20 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 1 to be string, resource given in %s on line %d |
||||
|
NULL |
||||
|
-- Iteration 21 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
-- Iteration 22 -- |
||||
|
array(0) { |
||||
|
} |
||||
|
===DONE=== |
||||
@ -0,0 +1,162 @@ |
|||||
|
--TEST-- |
||||
|
Test count_chars() function : usage variations - test values for $mode argument |
||||
|
--FILE-- |
||||
|
<?php |
||||
|
|
||||
|
/* Prototype : mixed count_chars ( string $string [, int $mode ] ) |
||||
|
* Description: Return information about characters used in a string |
||||
|
* Source code: ext/standard/string.c |
||||
|
*/ |
||||
|
|
||||
|
echo "*** Testing count_chars() function: with unexpected inputs for 'mode' argument ***\n"; |
||||
|
|
||||
|
//get an unset variable |
||||
|
$unset_var = 'string_val'; |
||||
|
unset($unset_var); |
||||
|
|
||||
|
//defining a class |
||||
|
class sample { |
||||
|
} |
||||
|
|
||||
|
// array with different values for $input |
||||
|
$inputs = array ( |
||||
|
|
||||
|
// integer values |
||||
|
/* 1 */ 0, |
||||
|
1, |
||||
|
255, |
||||
|
2147483647, |
||||
|
-2147483648, |
||||
|
|
||||
|
// float values |
||||
|
/* 6 */ 0.0, |
||||
|
1.3, |
||||
|
10.5, |
||||
|
-20.5, |
||||
|
10.1234567e10, |
||||
|
|
||||
|
// array values |
||||
|
/* 11 */ array(), |
||||
|
array(1, 2, 3, 4, 5, 6, 7, 8, 9), |
||||
|
|
||||
|
// boolean values |
||||
|
/* 14 */ true, |
||||
|
false, |
||||
|
TRUE, |
||||
|
FALSE, |
||||
|
|
||||
|
// null values |
||||
|
/* 18 */ NULL, |
||||
|
null, |
||||
|
|
||||
|
// string values |
||||
|
/* 20 */ "ABCD", |
||||
|
'abcd', |
||||
|
"1ABC", |
||||
|
"5ABC", |
||||
|
|
||||
|
// objects |
||||
|
/* 24 */ new sample(), |
||||
|
|
||||
|
// undefined variable |
||||
|
/* 25 */ @$undefined_var, |
||||
|
|
||||
|
// unset variable |
||||
|
/* 26 */ @$unset_var |
||||
|
); |
||||
|
|
||||
|
// loop through with each element of the $inputs array to test count_chars() function |
||||
|
// with unexepcted values for the 'mode' argument |
||||
|
$count = 1; |
||||
|
$string = "Return information about characters used in a string"; |
||||
|
foreach($inputs as $input) { |
||||
|
echo "-- Iteration $count --\n"; |
||||
|
// only list characters with a frequency > 0 |
||||
|
var_dump(is_array(count_chars($string, $input))); |
||||
|
$count ++; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
?> |
||||
|
===DONE=== |
||||
|
--EXPECTF-- |
||||
|
*** Testing count_chars() function: with unexpected inputs for 'mode' argument *** |
||||
|
-- Iteration 1 -- |
||||
|
bool(true) |
||||
|
-- Iteration 2 -- |
||||
|
bool(true) |
||||
|
-- Iteration 3 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 4 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 5 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 6 -- |
||||
|
bool(true) |
||||
|
-- Iteration 7 -- |
||||
|
bool(true) |
||||
|
-- Iteration 8 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 9 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 10 -- |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 11 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 2 to be long, array given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 12 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 2 to be long, array given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 13 -- |
||||
|
bool(true) |
||||
|
-- Iteration 14 -- |
||||
|
bool(true) |
||||
|
-- Iteration 15 -- |
||||
|
bool(true) |
||||
|
-- Iteration 16 -- |
||||
|
bool(true) |
||||
|
-- Iteration 17 -- |
||||
|
bool(true) |
||||
|
-- Iteration 18 -- |
||||
|
bool(true) |
||||
|
-- Iteration 19 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 2 to be long, string given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 20 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 2 to be long, string given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 21 -- |
||||
|
|
||||
|
Notice: A non well formed numeric value encountered in %s on line %d |
||||
|
bool(true) |
||||
|
-- Iteration 22 -- |
||||
|
|
||||
|
Notice: A non well formed numeric value encountered in %s on line %d |
||||
|
|
||||
|
Warning: count_chars(): Unknown mode in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 23 -- |
||||
|
|
||||
|
Warning: count_chars() expects parameter 2 to be long, object given in %s on line %d |
||||
|
bool(false) |
||||
|
-- Iteration 24 -- |
||||
|
bool(true) |
||||
|
-- Iteration 25 -- |
||||
|
bool(true) |
||||
|
===DONE=== |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue