From 32b293cd9cfd411216ffbafd9bbe3be1cd69e0b8 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Fri, 16 Jan 2009 12:53:07 +0000 Subject: [PATCH] New string function tests. Tested on Windows, Linux and Linux 64 bit. --- .../tests/strings/addslashes_variation1.phpt | 12 +- ext/standard/tests/strings/bin2hex_basic.phpt | 50 ++++ ext/standard/tests/strings/bin2hex_error.phpt | 43 +++ .../tests/strings/bin2hex_variation1.phpt | 128 +++++++++ ext/standard/tests/strings/bug37262.phpt | 4 +- ext/standard/tests/strings/bug45166.phpt | 10 + ext/standard/tests/strings/chr_basic.phpt | 27 ++ ext/standard/tests/strings/chr_error.phpt | 34 +++ .../tests/strings/chr_variation1.phpt | 135 +++++++++ .../strings/convert_cyr_string_basic.phpt | 54 ++++ .../strings/convert_cyr_string_error.phpt | 73 +++++ .../convert_cyr_string_variation1.phpt | 139 ++++++++++ .../tests/strings/convert_uudecode_basic.phpt | 54 ++++ .../tests/strings/convert_uudecode_error.phpt | 35 +++ .../strings/convert_uudecode_variation1.phpt | 161 +++++++++++ .../tests/strings/convert_uuencode_basic.phpt | 88 ++++++ .../tests/strings/convert_uuencode_error.phpt | 35 +++ .../strings/convert_uuencode_variation1.phpt | 161 +++++++++++ .../tests/strings/count_chars_basic.phpt | 116 ++++++++ .../tests/strings/count_chars_error.phpt | 36 +++ .../tests/strings/count_chars_variation1.phpt | 262 ++++++++++++++++++ .../tests/strings/count_chars_variation2.phpt | 178 ++++++++++++ 22 files changed, 1827 insertions(+), 8 deletions(-) create mode 100644 ext/standard/tests/strings/bin2hex_basic.phpt create mode 100644 ext/standard/tests/strings/bin2hex_error.phpt create mode 100644 ext/standard/tests/strings/bin2hex_variation1.phpt create mode 100644 ext/standard/tests/strings/bug45166.phpt create mode 100644 ext/standard/tests/strings/chr_basic.phpt create mode 100644 ext/standard/tests/strings/chr_error.phpt create mode 100644 ext/standard/tests/strings/chr_variation1.phpt create mode 100644 ext/standard/tests/strings/convert_cyr_string_basic.phpt create mode 100644 ext/standard/tests/strings/convert_cyr_string_error.phpt create mode 100644 ext/standard/tests/strings/convert_cyr_string_variation1.phpt create mode 100644 ext/standard/tests/strings/convert_uudecode_basic.phpt create mode 100644 ext/standard/tests/strings/convert_uudecode_error.phpt create mode 100644 ext/standard/tests/strings/convert_uudecode_variation1.phpt create mode 100644 ext/standard/tests/strings/convert_uuencode_basic.phpt create mode 100644 ext/standard/tests/strings/convert_uuencode_error.phpt create mode 100644 ext/standard/tests/strings/convert_uuencode_variation1.phpt create mode 100644 ext/standard/tests/strings/count_chars_basic.phpt create mode 100644 ext/standard/tests/strings/count_chars_error.phpt create mode 100644 ext/standard/tests/strings/count_chars_variation1.phpt create mode 100644 ext/standard/tests/strings/count_chars_variation2.phpt diff --git a/ext/standard/tests/strings/addslashes_variation1.phpt b/ext/standard/tests/strings/addslashes_variation1.phpt index 1cef57a3c5..9a35732fe3 100644 --- a/ext/standard/tests/strings/addslashes_variation1.phpt +++ b/ext/standard/tests/strings/addslashes_variation1.phpt @@ -41,8 +41,8 @@ $values = array ( // float values 10.5, -10.5, - 10.5e10, - 10.6E-10, + 10.1234567e10, + 10.7654321E-10, .5, // array values @@ -95,8 +95,8 @@ for($index = 0; $index < count($values); $index ++) { // closing the file fclose($file_handle); -echo "Done\n"; ?> +===DONE=== --EXPECTF-- *** Testing addslashes() : with non-string type argument *** @@ -118,9 +118,9 @@ unicode(4) "10.5" -- Iteration 6 -- unicode(5) "-10.5" -- Iteration 7 -- -unicode(12) "105000000000" +unicode(12) "101234567000" -- Iteration 8 -- -unicode(7) "1.06E-9" +unicode(13) "1.07654321E-9" -- Iteration 9 -- unicode(3) "0.5" -- Iteration 10 -- @@ -169,4 +169,4 @@ NULL unicode(0) "" -- Iteration 26 -- unicode(0) "" -Done +===DONE=== diff --git a/ext/standard/tests/strings/bin2hex_basic.phpt b/ext/standard/tests/strings/bin2hex_basic.phpt new file mode 100644 index 0000000000..e150bfdada --- /dev/null +++ b/ext/standard/tests/strings/bin2hex_basic.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test bin2hex() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing bin2hex() : basic functionality *** +-- Iteration 1 -- +unicode(46) "4865726520697320612073696d706c6520737472696e67" +-- Iteration 2 -- +unicode(102) "09205468697320537472696e6720636f6e7461696e7320090920736f6d6520636f6e74726f6c20636861726163746572730d0a" +-- Iteration 3 -- +unicode(36) "9091009394909195969798999a9b9c9d9e9f" +-- Iteration 4 -- +unicode(46) "4865726520697320612073696d706c6520737472696e67" +-- Iteration 5 -- +unicode(112) "5c74205468697320537472696e6720636f6e7461696e73205c745c7420736f6d6520636f6e74726f6c20636861726163746572735c725c6e" +-- Iteration 6 -- +unicode(144) "5c7839305c7839315c7830305c7839335c7839345c7839305c7839315c7839355c7839365c7839375c7839385c7839395c7839615c7839625c7839635c7839645c7839655c783966" +===DONE=== diff --git a/ext/standard/tests/strings/bin2hex_error.phpt b/ext/standard/tests/strings/bin2hex_error.phpt new file mode 100644 index 0000000000..1db1b48526 --- /dev/null +++ b/ext/standard/tests/strings/bin2hex_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test bin2hex() function : error conditions +--FILE-- + +===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 + +-- Testing bin2hex() function with Unicode string -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL + +===DONE=== diff --git a/ext/standard/tests/strings/bin2hex_variation1.phpt b/ext/standard/tests/strings/bin2hex_variation1.phpt new file mode 100644 index 0000000000..970eff1e22 --- /dev/null +++ b/ext/standard/tests/strings/bin2hex_variation1.phpt @@ -0,0 +1,128 @@ +--TEST-- +Test bin2hex() function : usage variations - test values for $str argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing bin2hex() function: with unexpected inputs for 'str' argument *** +-- Iteration 1 -- +unicode(2) "30" +-- Iteration 2 -- +unicode(2) "31" +-- Iteration 3 -- +unicode(12) "313233343536" +-- Iteration 4 -- +unicode(8) "31302e35" +-- Iteration 5 -- +unicode(10) "2d32302e35" +-- Iteration 6 -- +unicode(24) "313031323334353637303030" +-- Iteration 7 -- + +Warning: bin2hex() expects parameter 1 to be binary string, array given in %s on line %d +NULL +-- Iteration 8 -- + +Warning: bin2hex() expects parameter 1 to be binary string, array given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: bin2hex() expects parameter 1 to be binary string, array given in %s on line %d +NULL +-- Iteration 10 -- +unicode(2) "31" +-- Iteration 11 -- +unicode(0) "" +-- Iteration 12 -- +unicode(2) "31" +-- Iteration 13 -- +unicode(0) "" +-- Iteration 14 -- +unicode(0) "" +-- Iteration 15 -- +unicode(0) "" +-- Iteration 16 -- +unicode(26) "73616d706c65206f626a656374" +-- Iteration 17 -- + +Warning: bin2hex() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(0) "" +===DONE=== diff --git a/ext/standard/tests/strings/bug37262.phpt b/ext/standard/tests/strings/bug37262.phpt index c231587cd8..5a9f7f724d 100644 --- a/ext/standard/tests/strings/bug37262.phpt +++ b/ext/standard/tests/strings/bug37262.phpt @@ -5,5 +5,5 @@ Bug #37262 (var_export() does not escape \0 character) $func = create_function('$a', 'return $a;'); var_export($func); ?> ---EXPECT-- -'' . "\0" . 'lambda_1' +--EXPECTF-- +'' . "\0" . 'lambda_%d' diff --git a/ext/standard/tests/strings/bug45166.phpt b/ext/standard/tests/strings/bug45166.phpt new file mode 100644 index 0000000000..223cc0b4dc --- /dev/null +++ b/ext/standard/tests/strings/bug45166.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #45166 (substr() ) +--FILE-- + +===DONE=== +--EXPECT-- +cd +===DONE=== diff --git a/ext/standard/tests/strings/chr_basic.phpt b/ext/standard/tests/strings/chr_basic.phpt new file mode 100644 index 0000000000..600d18b516 --- /dev/null +++ b/ext/standard/tests/strings/chr_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test chr() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing chr() : basic functionality *** +Hello +World +===DONE=== diff --git a/ext/standard/tests/strings/chr_error.phpt b/ext/standard/tests/strings/chr_error.phpt new file mode 100644 index 0000000000..c0dcae7c4c --- /dev/null +++ b/ext/standard/tests/strings/chr_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test chr() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing chr() : error conditions *** + +-- Testing chr() function with no arguments -- + +Warning: chr() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing chr() function with more than expected no. of arguments -- + +Warning: chr() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/strings/chr_variation1.phpt b/ext/standard/tests/strings/chr_variation1.phpt new file mode 100644 index 0000000000..cb090b5b2d --- /dev/null +++ b/ext/standard/tests/strings/chr_variation1.phpt @@ -0,0 +1,135 @@ +--TEST-- +Test chr() function : usage variations - test values for $ascii argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing chr() function: with unexpected inputs for 'ascii' argument *** +-- Iteration 1 -- +unicode(2) "00" +-- Iteration 2 -- +unicode(2) "01" +-- Iteration 3 -- +unicode(2) "ff" +-- Iteration 4 -- +unicode(2) "3f" +-- Iteration 5 -- +unicode(2) "0a" +-- Iteration 6 -- +unicode(4) "3f3f" +-- Iteration 7 -- + +Warning: Codepoint value cannot be greater than 10FFFF in %s on line %d +unicode(0) "" +-- Iteration 8 -- + +Warning: chr() expects parameter 1 to be long, array given in %s on line %d +unicode(0) "" +-- Iteration 9 -- + +Warning: chr() expects parameter 1 to be long, array given in %s on line %d +unicode(0) "" +-- Iteration 10 -- + +Warning: chr() expects parameter 1 to be long, array given in %s on line %d +unicode(0) "" +-- Iteration 11 -- +unicode(2) "01" +-- Iteration 12 -- +unicode(2) "00" +-- Iteration 13 -- +unicode(2) "01" +-- Iteration 14 -- +unicode(2) "00" +-- Iteration 15 -- +unicode(2) "00" +-- Iteration 16 -- +unicode(2) "00" +-- Iteration 17 -- + +Warning: chr() expects parameter 1 to be long, object given in %s on line %d +unicode(0) "" +-- Iteration 18 -- + +Warning: chr() expects parameter 1 to be long, resource given in %s on line %d +unicode(0) "" +-- Iteration 19 -- +unicode(2) "00" +-- Iteration 20 -- +unicode(2) "00" +===DONE=== diff --git a/ext/standard/tests/strings/convert_cyr_string_basic.phpt b/ext/standard/tests/strings/convert_cyr_string_basic.phpt new file mode 100644 index 0000000000..139361d33f --- /dev/null +++ b/ext/standard/tests/strings/convert_cyr_string_basic.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test convert_cyr_string() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing convert_cyr_string() : basic functionality *** + +-- First try some simple English text -- +unicode(102) "436f6e766572742066726f6d206f6e6520437972696c6c6963206368617261637465722073657420746f20616e6f746865722e" +unicode(102) "436f6e766572742066726f6d206f6e6520437972696c6c6963206368617261637465722073657420746f20616e6f746865722e" + +-- Now try some of characters in 128-255 range -- +128: + +Warning: convert_cyr_string() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d + +200: + +Warning: convert_cyr_string() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d + +255: + +Warning: convert_cyr_string() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d + +===DONE=== diff --git a/ext/standard/tests/strings/convert_cyr_string_error.phpt b/ext/standard/tests/strings/convert_cyr_string_error.phpt new file mode 100644 index 0000000000..23e59d8121 --- /dev/null +++ b/ext/standard/tests/strings/convert_cyr_string_error.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test convert_cyr_string() function : error conditions +--FILE-- +", "?")) ); + +?> +===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 +unicode(10) "68656c6c6f" + +-- Testing convert_cyr_string() function with invalid 'to' character set -- + +Warning: convert_cyr_string(): Unknown destination charset: ? in %s on line %d +unicode(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 +unicode(10) "68656c6c6f" + +===DONE=== diff --git a/ext/standard/tests/strings/convert_cyr_string_variation1.phpt b/ext/standard/tests/strings/convert_cyr_string_variation1.phpt new file mode 100644 index 0000000000..471acb2ac6 --- /dev/null +++ b/ext/standard/tests/strings/convert_cyr_string_variation1.phpt @@ -0,0 +1,139 @@ +--TEST-- +Test convert_cyr_string() function : usage variations - test values for $str argument +--FILE-- + +===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 binary string, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: convert_cyr_string() expects parameter 1 to be binary string, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: convert_cyr_string() expects parameter 1 to be binary 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 binary string, resource given in %s on line %d +NULL +-- Iteration 21 -- +string(0) "" +-- Iteration 22 -- +string(0) "" +===DONE=== diff --git a/ext/standard/tests/strings/convert_uudecode_basic.phpt b/ext/standard/tests/strings/convert_uudecode_basic.phpt new file mode 100644 index 0000000000..8f8afb6e10 --- /dev/null +++ b/ext/standard/tests/strings/convert_uudecode_basic.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test convert_uudecode() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing convert_uudecode() : basic functionality *** +TEST PASSED +===DONE=== diff --git a/ext/standard/tests/strings/convert_uudecode_error.phpt b/ext/standard/tests/strings/convert_uudecode_error.phpt new file mode 100644 index 0000000000..77d3a88833 --- /dev/null +++ b/ext/standard/tests/strings/convert_uudecode_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test convert_uudecode() function : error conditions +--FILE-- + +===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=== diff --git a/ext/standard/tests/strings/convert_uudecode_variation1.phpt b/ext/standard/tests/strings/convert_uudecode_variation1.phpt new file mode 100644 index 0000000000..ed9cafacea --- /dev/null +++ b/ext/standard/tests/strings/convert_uudecode_variation1.phpt @@ -0,0 +1,161 @@ +--TEST-- +Test convert_uudecode() function : usage variations - test values for $data argument +--FILE-- + +===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 +bool(false) +-- Iteration 9 -- + +Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s +bool(false) +-- Iteration 10 -- + +Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), array given in %s +bool(false) +-- Iteration 11 -- + +Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), array given in %s +bool(false) +-- Iteration 12 -- + +Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), array given in %s +bool(false) +-- Iteration 13 -- + +Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- + +Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s +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 +bool(false) +-- Iteration 20 -- + +Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), resource given in %s +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/strings/convert_uuencode_basic.phpt b/ext/standard/tests/strings/convert_uuencode_basic.phpt new file mode 100644 index 0000000000..fd17f18013 --- /dev/null +++ b/ext/standard/tests/strings/convert_uuencode_basic.phpt @@ -0,0 +1,88 @@ +--TEST-- +Test convert_uuencode() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing convert_uuencode() : basic functionality *** +-- Iteration 1 -- +unicode(8) "#,3(S +` +" +-- Iteration 2 -- +unicode(8) "#86)C +` +" +-- Iteration 3 -- +unicode(12) "&,6$R8C-C +` +" +-- Iteration 4 -- +unicode(82) "M2&5R92!I +===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=== diff --git a/ext/standard/tests/strings/convert_uuencode_variation1.phpt b/ext/standard/tests/strings/convert_uuencode_variation1.phpt new file mode 100644 index 0000000000..4b90fd5eda --- /dev/null +++ b/ext/standard/tests/strings/convert_uuencode_variation1.phpt @@ -0,0 +1,161 @@ +--TEST-- +Test convert_uuencode() function : usage variations - test values for $data argument +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing convert_uuencode() function: with unexpected inputs for 'data' argument *** +-- Iteration 1 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 2 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 3 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 4 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 5 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 6 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 7 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 8 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +unicode(0) "" +-- Iteration 11 -- + +Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +unicode(0) "" +-- Iteration 12 -- + +Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +unicode(0) "" +-- Iteration 13 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 14 -- +unicode(0) "" +-- Iteration 15 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(0) "" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- + +Warning: bin2hex() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL +-- Iteration 20 -- + +Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +===DONE=== diff --git a/ext/standard/tests/strings/count_chars_basic.phpt b/ext/standard/tests/strings/count_chars_basic.phpt new file mode 100644 index 0000000000..1f9fa39301 --- /dev/null +++ b/ext/standard/tests/strings/count_chars_basic.phpt @@ -0,0 +1,116 @@ +--TEST-- +Test count_chars() function : basic functionality +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing count_chars() : basic functionality *** +array(18) { + [u"R"]=> + int(1) + [u"e"]=> + int(3) + [u"t"]=> + int(5) + [u"u"]=> + int(3) + [u"r"]=> + int(5) + [u"n"]=> + int(5) + [u" "]=> + int(7) + [u"i"]=> + int(4) + [u"f"]=> + int(1) + [u"o"]=> + int(3) + [u"m"]=> + int(1) + [u"a"]=> + int(5) + [u"b"]=> + int(1) + [u"c"]=> + int(2) + [u"h"]=> + int(1) + [u"s"]=> + int(3) + [u"d"]=> + int(1) + [u"g"]=> + int(1) +} + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +array(18) { + [u"R"]=> + int(1) + [u"e"]=> + int(3) + [u"t"]=> + int(5) + [u"u"]=> + int(3) + [u"r"]=> + int(5) + [u"n"]=> + int(5) + [u" "]=> + int(7) + [u"i"]=> + int(4) + [u"f"]=> + int(1) + [u"o"]=> + int(3) + [u"m"]=> + int(1) + [u"a"]=> + int(5) + [u"b"]=> + int(1) + [u"c"]=> + int(2) + [u"h"]=> + int(1) + [u"s"]=> + int(3) + [u"d"]=> + int(1) + [u"g"]=> + int(1) +} + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +unicode(0) "" +===DONE=== diff --git a/ext/standard/tests/strings/count_chars_error.phpt b/ext/standard/tests/strings/count_chars_error.phpt new file mode 100644 index 0000000000..45c1163398 --- /dev/null +++ b/ext/standard/tests/strings/count_chars_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test count_chars() function : error conditions +--FILE-- + +===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=== diff --git a/ext/standard/tests/strings/count_chars_variation1.phpt b/ext/standard/tests/strings/count_chars_variation1.phpt new file mode 100644 index 0000000000..e24fc570df --- /dev/null +++ b/ext/standard/tests/strings/count_chars_variation1.phpt @@ -0,0 +1,262 @@ +--TEST-- +Test count_chars() function : usage variations - test values for $string argument +--FILE-- + 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) { + [0]=> + int(1) +} +-- Iteration 2 -- +array(1) { + [1]=> + int(1) +} +-- Iteration 3 -- +array(2) { + [2]=> + int(1) + [5]=> + int(2) +} +-- Iteration 4 -- +array(3) { + [2]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) +} +-- Iteration 5 -- +array(7) { + [2]=> + int(1) + [1]=> + int(1) + [4]=> + int(3) + [7]=> + int(2) + [8]=> + int(1) + [3]=> + int(1) + [6]=> + int(1) +} +-- Iteration 6 -- +array(8) { + [u"-"]=> + int(1) + [2]=> + int(1) + [1]=> + int(1) + [4]=> + int(3) + [7]=> + int(1) + [8]=> + int(2) + [3]=> + int(1) + [6]=> + int(1) +} +-- Iteration 7 -- +array(4) { + [1]=> + int(1) + [0]=> + int(1) + [u"."]=> + int(1) + [5]=> + int(1) +} +-- Iteration 8 -- +array(5) { + [u"-"]=> + int(1) + [2]=> + int(1) + [0]=> + int(1) + [u"."]=> + int(1) + [5]=> + int(1) +} +-- Iteration 9 -- +array(8) { + [1]=> + int(2) + [0]=> + int(4) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) + [7]=> + int(1) +} +-- Iteration 10 -- + +Warning: count_chars() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: count_chars() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: count_chars() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- +array(1) { + [1]=> + int(1) +} +-- Iteration 14 -- +array(0) { +} +-- Iteration 15 -- +array(1) { + [1]=> + int(1) +} +-- Iteration 16 -- +array(0) { +} +-- Iteration 17 -- +array(0) { +} +-- Iteration 18 -- +array(0) { +} +-- Iteration 19 -- +array(12) { + [u"s"]=> + int(1) + [u"a"]=> + int(1) + [u"m"]=> + int(1) + [u"p"]=> + int(1) + [u"l"]=> + int(1) + [u"e"]=> + int(2) + [u" "]=> + int(1) + [u"o"]=> + int(1) + [u"b"]=> + int(1) + [u"j"]=> + int(1) + [u"c"]=> + int(1) + [u"t"]=> + int(1) +} +-- Iteration 20 -- + +Warning: count_chars() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 21 -- +array(0) { +} +-- Iteration 22 -- +array(0) { +} +===DONE=== diff --git a/ext/standard/tests/strings/count_chars_variation2.phpt b/ext/standard/tests/strings/count_chars_variation2.phpt new file mode 100644 index 0000000000..ee62c5e791 --- /dev/null +++ b/ext/standard/tests/strings/count_chars_variation2.phpt @@ -0,0 +1,178 @@ +--TEST-- +Test count_chars() function : usage variations - test values for $mode argument +--FILE-- + 0 + var_dump(is_array(count_chars($string, $input))); + $count ++; +} + + +?> +===DONE=== +--EXPECTF-- +*** Testing count_chars() function: with unexpected inputs for 'mode' argument *** +-- Iteration 1 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- 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 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- 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 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- Iteration 15 -- +bool(true) +-- Iteration 16 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: count_chars() expects parameter 2 to be long, Unicode string given in %s on line %d +bool(false) +-- Iteration 20 -- + +Warning: count_chars() expects parameter 2 to be long, Unicode 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 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +-- Iteration 25 -- + +Warning: count_chars(): Only mode=1 is supported with Unicode strings in %s on line %d +bool(false) +===DONE=== -- 2.50.1