From: andy wharmby Date: Mon, 19 Jan 2009 15:54:47 +0000 (+0000) Subject: New strval() tests. Tested on Windows, Linux and Linux 64 bit. X-Git-Tag: php-5.3.0beta1~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a34f4ad2c53fa88f0645ba5722434bd39b4a73d;p=php New strval() tests. Tested on Windows, Linux and Linux 64 bit. --- diff --git a/ext/standard/tests/strings/strval_basic.phpt b/ext/standard/tests/strings/strval_basic.phpt new file mode 100644 index 0000000000..c099058b99 --- /dev/null +++ b/ext/standard/tests/strings/strval_basic.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test strval() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strval() : basic variations *** + +-- Iteration 1 -- +string(11) "Hello World" + +-- Iteration 2 -- +string(11) "Hello World" + +-- Iteration 3 -- +string(32) "String +with +control +characters +" + +-- Iteration 4 -- +string(20) "String with "quotes"" + +-- Iteration 5 -- +string(6) "123456" + +-- Iteration 6 -- +string(5) "0xABC" + +-- Iteration 7 -- +string(21) "Simple HEREDOC string" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strval_error.phpt b/ext/standard/tests/strings/strval_error.phpt new file mode 100644 index 0000000000..c31a2ab35b --- /dev/null +++ b/ext/standard/tests/strings/strval_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test strval() function : usage variations - error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strval() : error conditions *** + +-- Testing strval() function with more than expected no. of arguments -- + +Warning: strval() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +-- Testing strval() function with less than expected no. of arguments -- + +Warning: strval() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing strval() function with object which has not toString() method -- + +Catchable fatal error: Object of class MyClass could not be converted to string in %s on line %d \ No newline at end of file diff --git a/ext/standard/tests/strings/strval_variation1.phpt b/ext/standard/tests/strings/strval_variation1.phpt new file mode 100644 index 0000000000..430a4362bd --- /dev/null +++ b/ext/standard/tests/strings/strval_variation1.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test strval() function : usage variations - Pass different data types as strval +--FILE-- + 'red', 'item' => 'pen'), + + // null data +/*20*/ NULL, + null, + + // boolean data +/*22*/ true, + false, + TRUE, + FALSE, + + // empty data +/*26*/ "", + '', + + // object data +/*28*/ new MyClass(), + + // resource +/*29*/ $file_handle, + + // undefined data +/*30*/ @$undefined_var, + + // unset data +/*31*/ @$unset_var, +); + +// loop through each element of the array for strval +$iterator = 1; +foreach($values as $value) { + echo "\n-- Iteration $iterator --\n"; + var_dump( strval($value) ); + $iterator++; +}; +?> +===DONE=== +--EXPECTF-- +*** Testing strval() : usage variations *** + +-- Iteration 1 -- +string(1) "0" + +-- Iteration 2 -- +string(1) "1" + +-- Iteration 3 -- +string(5) "12345" + +-- Iteration 4 -- +string(6) "-12345" + +-- Iteration 5 -- +string(1) "2" + +-- Iteration 6 -- +string(1) "8" + +-- Iteration 7 -- +string(5) "12345" + +-- Iteration 8 -- +string(6) "-12345" + +-- Iteration 9 -- +string(1) "0" + +-- Iteration 10 -- +string(1) "1" + +-- Iteration 11 -- +string(5) "43981" + +-- Iteration 12 -- +string(6) "-43981" + +-- Iteration 13 -- +string(5) "100.5" + +-- Iteration 14 -- +string(6) "-100.5" + +-- Iteration 15 -- +string(13) "1001234567000" + +-- Iteration 16 -- +string(14) "1.007654321E-8" + +-- Iteration 17 -- +string(3) "0.5" + +-- Iteration 18 -- +string(5) "Array" + +-- Iteration 19 -- +string(5) "Array" + +-- Iteration 20 -- +string(0) "" + +-- Iteration 21 -- +string(0) "" + +-- Iteration 22 -- +string(1) "1" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(1) "1" + +-- Iteration 25 -- +string(0) "" + +-- Iteration 26 -- +string(0) "" + +-- Iteration 27 -- +string(0) "" + +-- Iteration 28 -- +string(7) "MyClass" + +-- Iteration 29 -- +string(%d) "Resource id #%d" + +-- Iteration 30 -- +string(0) "" + +-- Iteration 31 -- +string(0) "" +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/strval_variation2.phpt b/ext/standard/tests/strings/strval_variation2.phpt new file mode 100644 index 0000000000..da74973c5e --- /dev/null +++ b/ext/standard/tests/strings/strval_variation2.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test strval() function : usage variations - Pass all valid char codes +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing strval() : usage variations - Pass all valid char codes *** +000102030405060708090a0b0c0d0e0f +101112131415161718191a1b1c1d1e1f +202122232425262728292a2b2c2d2e2f +303132333435363738393a3b3c3d3e3f +404142434445464748494a4b4c4d4e4f +505152535455565758595a5b5c5d5e5f +606162636465666768696a6b6c6d6e6f +707172737475767778797a7b7c7d7e7f +808182838485868788898a8b8c8d8e8f +909192939495969798999a9b9c9d9e9f +a0a1a2a3a4a5a6a7a8a9aaabacadaeaf +b0b1b2b3b4b5b6b7b8b9babbbcbdbebf +c0c1c2c3c4c5c6c7c8c9cacbcccdcecf +d0d1d2d3d4d5d6d7d8d9dadbdcdddedf +e0e1e2e3e4e5e6e7e8e9eaebecedeeef +f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff +===DONE=== \ No newline at end of file