From: Raghubansh Kumar Date: Mon, 3 Dec 2007 11:56:39 +0000 (+0000) Subject: New testcases for array_pad() function X-Git-Tag: RELEASE_2_0_0a1~1248 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00926c853511b2008278de00b5e72957aae86be4;p=php New testcases for array_pad() function --- diff --git a/ext/standard/tests/array/array_pad_basic.phpt b/ext/standard/tests/array/array_pad_basic.phpt new file mode 100644 index 0000000000..85c99e28a9 --- /dev/null +++ b/ext/standard/tests/array/array_pad_basic.phpt @@ -0,0 +1,151 @@ +--TEST-- +Test array_pad() function : basic functionality +--FILE-- + +--EXPECTF-- +*** Testing array_pad() : basic functionality *** +-- Positive pad_size -- +array(8) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(-3) + [4]=> + int(-3) + [5]=> + int(-3) + [6]=> + int(-3) + [7]=> + int(-3) +} +-- Negative pad_size -- +array(8) { + [0]=> + int(-3) + [1]=> + int(-3) + [2]=> + int(-3) + [3]=> + int(-3) + [4]=> + int(-3) + [5]=> + int(1) + [6]=> + int(2) + [7]=> + int(3) +} +-- Pad_size lesser than array_size -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +-- Pad_size equal to array_size -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_pad() : basic functionality *** +-- Positive pad_size -- +array(8) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(-3) + [4]=> + int(-3) + [5]=> + int(-3) + [6]=> + int(-3) + [7]=> + int(-3) +} +-- Negative pad_size -- +array(8) { + [0]=> + int(-3) + [1]=> + int(-3) + [2]=> + int(-3) + [3]=> + int(-3) + [4]=> + int(-3) + [5]=> + int(1) + [6]=> + int(2) + [7]=> + int(3) +} +-- Pad_size lesser than array_size -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +-- Pad_size equal to array_size -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +Done diff --git a/ext/standard/tests/array/array_pad_error.phpt b/ext/standard/tests/array/array_pad_error.phpt new file mode 100644 index 0000000000..56682b07de --- /dev/null +++ b/ext/standard/tests/array/array_pad_error.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test array_pad() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing array_pad() : error conditions *** + +-- Testing array_pad() function with Zero arguments -- + +Warning: array_pad() expects exactly 3 parameters, 0 given in %s on line %d +NULL + +-- Testing array_pad() function with more than expected no. of arguments -- + +Warning: array_pad() expects exactly 3 parameters, 4 given in %s on line %d +NULL + +-- Testing array_pad() function with less than expected no. of arguments -- + +Warning: array_pad() expects exactly 3 parameters, 2 given in %s on line %d +NULL + +Warning: array_pad() expects exactly 3 parameters, 1 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_pad() : error conditions *** + +-- Testing array_pad() function with Zero arguments -- + +Warning: array_pad() expects exactly 3 parameters, 0 given in %s on line %d +NULL + +-- Testing array_pad() function with more than expected no. of arguments -- + +Warning: array_pad() expects exactly 3 parameters, 4 given in %s on line %d +NULL + +-- Testing array_pad() function with less than expected no. of arguments -- + +Warning: array_pad() expects exactly 3 parameters, 2 given in %s on line %d +NULL + +Warning: array_pad() expects exactly 3 parameters, 1 given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_pad_variation1.phpt b/ext/standard/tests/array/array_pad_variation1.phpt new file mode 100644 index 0000000000..7beecefe58 --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation1.phpt @@ -0,0 +1,441 @@ +--TEST-- +Test array_pad() function : usage variations - unexpected values for 'input' argument +--FILE-- + +--EXPECTF-- +*** Testing array_pad() : passing non array values to $input argument *** + +-- Iteration 1 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 17 -- +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 18 -- +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 19 -- +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 20 -- +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 21 -- +Warning: array_pad() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- +Warning: array_pad() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_pad() : passing non array values to $input argument *** + +-- Iteration 1 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 19 -- +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- +Warning: array_pad() expects parameter 1 to be array, object given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- +Warning: array_pad() expects parameter 1 to be array, resource given in %s on line %d +NULL + +Warning: array_pad() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_pad_variation2.phpt b/ext/standard/tests/array/array_pad_variation2.phpt new file mode 100644 index 0000000000..df130e5741 --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation2.phpt @@ -0,0 +1,423 @@ +--TEST-- +Test array_pad() function : usage variations - unexpected values for 'pad_size' argument(Bug#43482) +--FILE-- + 'red', 'item' => 'pen'), + + // null data +/*11*/ NULL, + null, + + // boolean data +/*13*/ true, + false, + TRUE, + FALSE, + + // empty data +/*17*/ "", + '', + + // string data +/*19*/ "string", + 'string', + + // object data +/*21*/ new classA(), + + // undefined data +/*22*/ @$undefined_var, + + // unset data +/*23*/ @$unset_var, +); + +// loop through each element of $pad_sizes to check the behavior of array_pad() +$iterator = 1; +foreach($pad_sizes as $pad_size) { + echo "-- Iteration $iterator --\n"; + var_dump( array_pad($input, $pad_size, $pad_value) ); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_pad() : passing non integer values to $pad_size argument *** +-- Iteration 1 -- +array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) + [7]=> + int(1) + [8]=> + int(1) + [9]=> + int(1) +} +-- Iteration 2 -- +array(10) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) + [7]=> + int(1) + [8]=> + int(1) + [9]=> + int(2) +} +-- Iteration 3 -- + +Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d +bool(false) +-- Iteration 5 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 6 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 7 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 8 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 12 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 13 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 14 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 15 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 16 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 17 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 18 -- + +Warning: array_pad() expects parameter 2 to be long, string given in %s on line %d +NULL +-- Iteration 19 -- + +Warning: array_pad() expects parameter 2 to be long, string given in %s on line %d +NULL +-- Iteration 20 -- + +Warning: array_pad() expects parameter 2 to be long, string given in %s on line %d +NULL +-- Iteration 21 -- + +Warning: array_pad() expects parameter 2 to be long, string given in %s on line %d +NULL +-- Iteration 22 -- + +Warning: array_pad() expects parameter 2 to be long, object given in %s on line %d +NULL +-- Iteration 23 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 24 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done +--UEXPECTF-- +*** Testing array_pad() : passing non integer values to $pad_size argument *** +-- Iteration 1 -- +array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) + [7]=> + int(1) + [8]=> + int(1) + [9]=> + int(1) +} +-- Iteration 2 -- +array(10) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + [4]=> + int(1) + [5]=> + int(1) + [6]=> + int(1) + [7]=> + int(1) + [8]=> + int(1) + [9]=> + int(2) +} +-- Iteration 3 -- + +Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d +bool(false) +-- Iteration 5 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 6 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 7 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 8 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: array_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 12 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 13 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 14 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 15 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 16 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 17 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 18 -- + +Warning: array_pad() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 19 -- + +Warning: array_pad() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 20 -- + +Warning: array_pad() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 21 -- + +Warning: array_pad() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 22 -- + +Warning: array_pad() expects parameter 2 to be long, object given in %s on line %d +NULL +-- Iteration 23 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +-- Iteration 24 -- +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} +Done diff --git a/ext/standard/tests/array/array_pad_variation3.phpt b/ext/standard/tests/array/array_pad_variation3.phpt new file mode 100644 index 0000000000..bff495d9b8 --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation3.phpt @@ -0,0 +1,1628 @@ +--TEST-- +Test array_pad() function : usage variations - possible values for 'pad_value' argument +--FILE-- + 'red', 'item' => 'pen'), + + // null data +/*15*/ NULL, + null, + + // boolean data +/*17*/ true, + false, + TRUE, + FALSE, + + // empty data +/*21*/ "", + '', + + // string data +/*23*/ "string", + 'string', + $heredoc, + + // strings with different white spaces +/*26*/ "\v\fHello\t world!! \rstring\n", + '\v\fHello\t world!! \rstring\n', + + // object data +/*28*/ new classA(), + + // undefined data +/*29*/ @$undefined_var, + + // unset data +/*30*/ @$unset_var, + + // resource variable +/*31*/ $fp, + + // reference variable +/*32*/ $reference +); + +// loop through each element of $pad_values to check the behavior of array_pad() +$iterator = 1; +foreach($pad_values as $pad_value) { + echo "-- Iteration $iterator --\n"; + var_dump( array_pad($input, $pad_size, $pad_value) ); // positive 'pad_size' + var_dump( array_pad($input, -$pad_size, $pad_value) ); // negative 'pad_size' + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_pad() : possible values for $pad_value argument *** +-- Iteration 1 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(0) + [3]=> + int(0) +} +array(4) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 2 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(1) + [3]=> + int(1) +} +array(4) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 3 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(12345) + [3]=> + int(12345) +} +array(4) { + [0]=> + int(12345) + [1]=> + int(12345) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 4 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(-2345) + [3]=> + int(-2345) +} +array(4) { + [0]=> + int(-2345) + [1]=> + int(-2345) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 5 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(10.5) + [3]=> + float(10.5) +} +array(4) { + [0]=> + float(10.5) + [1]=> + float(10.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 6 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(-10.5) + [3]=> + float(-10.5) +} +array(4) { + [0]=> + float(-10.5) + [1]=> + float(-10.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 7 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(123456789000) + [3]=> + float(123456789000) +} +array(4) { + [0]=> + float(123456789000) + [1]=> + float(123456789000) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 8 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(1.23456789E-9) + [3]=> + float(1.23456789E-9) +} +array(4) { + [0]=> + float(1.23456789E-9) + [1]=> + float(1.23456789E-9) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 9 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(0.5) + [3]=> + float(0.5) +} +array(4) { + [0]=> + float(0.5) + [1]=> + float(0.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 10 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(0) { + } + [3]=> + array(0) { + } +} +array(4) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 11 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(1) { + [0]=> + int(0) + } + [3]=> + array(1) { + [0]=> + int(0) + } +} +array(4) { + [0]=> + array(1) { + [0]=> + int(0) + } + [1]=> + array(1) { + [0]=> + int(0) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 12 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(1) { + [0]=> + int(1) + } + [3]=> + array(1) { + [0]=> + int(1) + } +} +array(4) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(1) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 13 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [3]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } +} +array(4) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [1]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 14 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(2) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + } + [3]=> + array(2) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + } +} +array(4) { + [0]=> + array(2) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + } + [1]=> + array(2) { + ["color"]=> + string(3) "red" + ["item"]=> + string(3) "pen" + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 15 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 16 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 17 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(true) + [3]=> + bool(true) +} +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 18 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(false) + [3]=> + bool(false) +} +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 19 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(true) + [3]=> + bool(true) +} +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 20 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(false) + [3]=> + bool(false) +} +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 21 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(0) "" + [3]=> + string(0) "" +} +array(4) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 22 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(0) "" + [3]=> + string(0) "" +} +array(4) { + [0]=> + string(0) "" + [1]=> + string(0) "" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 23 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(6) "string" + [3]=> + string(6) "string" +} +array(4) { + [0]=> + string(6) "string" + [1]=> + string(6) "string" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 24 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(6) "string" + [3]=> + string(6) "string" +} +array(4) { + [0]=> + string(6) "string" + [1]=> + string(6) "string" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 25 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(11) "hello world" + [3]=> + string(11) "hello world" +} +array(4) { + [0]=> + string(11) "hello world" + [1]=> + string(11) "hello world" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 26 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(25) " Hello world!! +string +" + [3]=> + string(25) " Hello world!! +string +" +} +array(4) { + [0]=> + string(25) " Hello world!! +string +" + [1]=> + string(25) " Hello world!! +string +" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 27 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(30) "\v\fHello\t world!! \rstring\n" + [3]=> + string(30) "\v\fHello\t world!! \rstring\n" +} +array(4) { + [0]=> + string(30) "\v\fHello\t world!! \rstring\n" + [1]=> + string(30) "\v\fHello\t world!! \rstring\n" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 28 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + object(classA)#%d (0) { + } + [3]=> + object(classA)#%d (0) { + } +} +array(4) { + [0]=> + object(classA)#%d (0) { + } + [1]=> + object(classA)#%d (0) { + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 29 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 30 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 31 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + resource(%d) of type (stream) + [3]=> + resource(%d) of type (stream) +} +array(4) { + [0]=> + resource(%d) of type (stream) + [1]=> + resource(%d) of type (stream) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 32 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "hello" + [3]=> + string(5) "hello" +} +array(4) { + [0]=> + string(5) "hello" + [1]=> + string(5) "hello" + [2]=> + int(1) + [3]=> + int(2) +} +Done +--UEXPECTF-- +*** Testing array_pad() : possible values for $pad_value argument *** +-- Iteration 1 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(0) + [3]=> + int(0) +} +array(4) { + [0]=> + int(0) + [1]=> + int(0) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 2 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(1) + [3]=> + int(1) +} +array(4) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 3 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(12345) + [3]=> + int(12345) +} +array(4) { + [0]=> + int(12345) + [1]=> + int(12345) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 4 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(-2345) + [3]=> + int(-2345) +} +array(4) { + [0]=> + int(-2345) + [1]=> + int(-2345) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 5 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(10.5) + [3]=> + float(10.5) +} +array(4) { + [0]=> + float(10.5) + [1]=> + float(10.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 6 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(-10.5) + [3]=> + float(-10.5) +} +array(4) { + [0]=> + float(-10.5) + [1]=> + float(-10.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 7 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(123456789000) + [3]=> + float(123456789000) +} +array(4) { + [0]=> + float(123456789000) + [1]=> + float(123456789000) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 8 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(1.23456789E-9) + [3]=> + float(1.23456789E-9) +} +array(4) { + [0]=> + float(1.23456789E-9) + [1]=> + float(1.23456789E-9) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 9 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(0.5) + [3]=> + float(0.5) +} +array(4) { + [0]=> + float(0.5) + [1]=> + float(0.5) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 10 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(0) { + } + [3]=> + array(0) { + } +} +array(4) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 11 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(1) { + [0]=> + int(0) + } + [3]=> + array(1) { + [0]=> + int(0) + } +} +array(4) { + [0]=> + array(1) { + [0]=> + int(0) + } + [1]=> + array(1) { + [0]=> + int(0) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 12 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(1) { + [0]=> + int(1) + } + [3]=> + array(1) { + [0]=> + int(1) + } +} +array(4) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(1) { + [0]=> + int(1) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 13 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [3]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } +} +array(4) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [1]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 14 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + array(2) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + } + [3]=> + array(2) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + } +} +array(4) { + [0]=> + array(2) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + } + [1]=> + array(2) { + [u"color"]=> + unicode(3) "red" + [u"item"]=> + unicode(3) "pen" + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 15 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 16 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 17 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(true) + [3]=> + bool(true) +} +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 18 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(false) + [3]=> + bool(false) +} +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 19 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(true) + [3]=> + bool(true) +} +array(4) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 20 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + bool(false) + [3]=> + bool(false) +} +array(4) { + [0]=> + bool(false) + [1]=> + bool(false) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 21 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(0) "" + [3]=> + unicode(0) "" +} +array(4) { + [0]=> + unicode(0) "" + [1]=> + unicode(0) "" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 22 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(0) "" + [3]=> + unicode(0) "" +} +array(4) { + [0]=> + unicode(0) "" + [1]=> + unicode(0) "" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 23 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(6) "string" + [3]=> + unicode(6) "string" +} +array(4) { + [0]=> + unicode(6) "string" + [1]=> + unicode(6) "string" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 24 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(6) "string" + [3]=> + unicode(6) "string" +} +array(4) { + [0]=> + unicode(6) "string" + [1]=> + unicode(6) "string" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 25 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(11) "hello world" + [3]=> + unicode(11) "hello world" +} +array(4) { + [0]=> + unicode(11) "hello world" + [1]=> + unicode(11) "hello world" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 26 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(25) " Hello world!! +string +" + [3]=> + unicode(25) " Hello world!! +string +" +} +array(4) { + [0]=> + unicode(25) " Hello world!! +string +" + [1]=> + unicode(25) " Hello world!! +string +" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 27 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(30) "\v\fHello\t world!! \rstring\n" + [3]=> + unicode(30) "\v\fHello\t world!! \rstring\n" +} +array(4) { + [0]=> + unicode(30) "\v\fHello\t world!! \rstring\n" + [1]=> + unicode(30) "\v\fHello\t world!! \rstring\n" + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 28 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + object(classA)#%d (0) { + } + [3]=> + object(classA)#%d (0) { + } +} +array(4) { + [0]=> + object(classA)#%d (0) { + } + [1]=> + object(classA)#%d (0) { + } + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 29 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 30 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + NULL + [3]=> + NULL +} +array(4) { + [0]=> + NULL + [1]=> + NULL + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 31 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + resource(%d) of type (stream) + [3]=> + resource(%d) of type (stream) +} +array(4) { + [0]=> + resource(%d) of type (stream) + [1]=> + resource(%d) of type (stream) + [2]=> + int(1) + [3]=> + int(2) +} +-- Iteration 32 -- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "hello" + [3]=> + unicode(5) "hello" +} +array(4) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "hello" + [2]=> + int(1) + [3]=> + int(2) +} +Done diff --git a/ext/standard/tests/array/array_pad_variation4.phpt b/ext/standard/tests/array/array_pad_variation4.phpt new file mode 100644 index 0000000000..46d3ea6798 --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation4.phpt @@ -0,0 +1,91 @@ +--TEST-- +Test array_pad() function : usage variations - binary safe checking +--FILE-- + +--EXPECTF-- +*** Testing array_pad() : Passing binary values to $pad_value argument *** +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + string(5) "hello" + [4]=> + string(5) "hello" + [5]=> + string(5) "hello" +} +array(6) { + [0]=> + string(5) "hello" + [1]=> + string(5) "hello" + [2]=> + string(5) "hello" + [3]=> + int(1) + [4]=> + int(2) + [5]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_pad() : Passing binary values to $pad_value argument *** +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + string(5) "hello" + [4]=> + string(5) "hello" + [5]=> + string(5) "hello" +} +array(6) { + [0]=> + string(5) "hello" + [1]=> + string(5) "hello" + [2]=> + string(5) "hello" + [3]=> + int(1) + [4]=> + int(2) + [5]=> + int(3) +} +Done diff --git a/ext/standard/tests/array/array_pad_variation5.phpt b/ext/standard/tests/array/array_pad_variation5.phpt new file mode 100644 index 0000000000..975599a7ac --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation5.phpt @@ -0,0 +1,247 @@ +--TEST-- +Test array_pad() function : usage variations - two dimensional array for 'pad_value' argument +--FILE-- + 1, 'two' => 2) +); + +var_dump( array_pad($input, $pad_size, $pad_value) ); // positive 'pad_value' +var_dump( array_pad($input, -$pad_size, $pad_value) ); // negative 'pad_value' + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_pad() : Passing 2-d array to $pad_value argument *** +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [2]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } + } + [4]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [2]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } + } +} +array(5) { + [0]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [2]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } + } + [1]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [2]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } + } + [2]=> + int(1) + [3]=> + int(2) + [4]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_pad() : Passing 2-d array to $pad_value argument *** +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [2]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } + } + [4]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [2]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } + } +} +array(5) { + [0]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [2]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } + } + [1]=> + array(3) { + [0]=> + array(1) { + [0]=> + int(1) + } + [1]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [2]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } + } + [2]=> + int(1) + [3]=> + int(2) + [4]=> + int(3) +} +Done diff --git a/ext/standard/tests/array/array_pad_variation6.phpt b/ext/standard/tests/array/array_pad_variation6.phpt new file mode 100644 index 0000000000..7db5e14621 --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation6.phpt @@ -0,0 +1,1252 @@ +--TEST-- +Test array_pad() function : usage variations - different arrays for 'input' argument +--FILE-- +22 +'single quoted string' +"double quoted string" +2222 != 1111.\t 0000 = 0000\n +EOT; + +// different arrays to be passed to $input argument +$inputs = array ( +/*1*/ array(1, 2), // with default keys and numeric values + array(1.1, 2.2), // with default keys & float values + array(false,true), // with default keys and boolean values + array(), // empty array +/*5*/ array(NULL), // with NULL + array("a\v\f", "aaaa\r", "b\tbbb", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings + array('a\v\f', 'aaaa\r', 'b\tbbb', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings + array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // with heredocs + + // associative arrays +/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values + array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values + array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values + array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value + array("one" => 1, 2 => "two", 4 => "four"), //mixed + + // associative array, containing null/empty/boolean values as key/value +/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null), + array(true => "true", false => "false", "false" => false, "true" => true), + array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''), + array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true), + array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6), + + // array with repetative keys +/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3) +); + +// initialize the $pad_size and $pad_value arguments +$pad_size = 6; +$pad_value = "HELLO"; + +// loop through each sub-array within $inputs to check the behavior of array_pad() +$iterator = 1; +foreach($inputs as $input) { + echo "-- Iteration $iterator --\n"; + var_dump( array_pad($input, $pad_size, $pad_value) ); // positive 'pad_size' + var_dump( array_pad($input, -$pad_size, $pad_value) ); // negative 'pad_size' + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_pad() : Passing different arrays to $input argument *** +-- Iteration 1 -- +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + int(1) + [5]=> + int(2) +} +-- Iteration 2 -- +array(6) { + [0]=> + float(1.1) + [1]=> + float(2.2) + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + float(1.1) + [5]=> + float(2.2) +} +-- Iteration 3 -- +array(6) { + [0]=> + bool(false) + [1]=> + bool(true) + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + bool(false) + [5]=> + bool(true) +} +-- Iteration 4 -- +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +-- Iteration 5 -- +array(6) { + [0]=> + NULL + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + NULL +} +-- Iteration 6 -- +array(6) { + [0]=> + string(3) "a " + [1]=> + string(5) "aaaa +" + [2]=> + string(5) "b bbb" + [3]=> + string(27) "\[\]\!\@\#$\%\^\&\*\(\)\{\}" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(3) "a " + [3]=> + string(5) "aaaa +" + [4]=> + string(5) "b bbb" + [5]=> + string(27) "\[\]\!\@\#$\%\^\&\*\(\)\{\}" +} +-- Iteration 7 -- +array(6) { + [0]=> + string(5) "a\v\f" + [1]=> + string(6) "aaaa\r" + [2]=> + string(6) "b\tbbb" + [3]=> + string(28) "\[\]\!\@\#\$\%\^\&\*\(\)\{\}" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "a\v\f" + [3]=> + string(6) "aaaa\r" + [4]=> + string(6) "b\tbbb" + [5]=> + string(28) "\[\]\!\@\#\$\%\^\&\*\(\)\{\}" +} +-- Iteration 8 -- +array(6) { + ["h1"]=> + string(1) " +" + ["h2"]=> + string(86) "hello world +The big brown fox jumped over; +the lazy dog +This is a double quoted string" + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [0]=> + string(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + ["h1"]=> + string(1) " +" + ["h2"]=> + string(86) "hello world +The big brown fox jumped over; +the lazy dog +This is a double quoted string" + ["h3"]=> + string(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [2]=> + string(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +-- Iteration 9 -- +array(6) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" + [2]=> + string(5) "three" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(3) "one" + [4]=> + string(3) "two" + [5]=> + string(5) "three" +} +-- Iteration 10 -- +array(6) { + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + ["one"]=> + int(1) + ["two"]=> + int(2) + ["three"]=> + int(3) +} +-- Iteration 11 -- +array(6) { + [0]=> + int(10) + [1]=> + int(20) + [2]=> + int(40) + [3]=> + int(30) + [4]=> + string(5) "HELLO" + [5]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + int(10) + [3]=> + int(20) + [4]=> + int(40) + [5]=> + int(30) +} +-- Iteration 12 -- +array(6) { + ["one"]=> + string(3) "ten" + ["two"]=> + string(6) "twenty" + ["three"]=> + string(6) "thirty" + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + ["one"]=> + string(3) "ten" + ["two"]=> + string(6) "twenty" + ["three"]=> + string(6) "thirty" +} +-- Iteration 13 -- +array(6) { + ["one"]=> + int(1) + [0]=> + string(3) "two" + [1]=> + string(4) "four" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + ["one"]=> + int(1) + [3]=> + string(3) "two" + [4]=> + string(4) "four" +} +-- Iteration 14 -- +array(6) { + [""]=> + string(4) "null" + ["NULL"]=> + NULL + ["null"]=> + NULL + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [""]=> + string(4) "null" + ["NULL"]=> + NULL + ["null"]=> + NULL +} +-- Iteration 15 -- +array(6) { + [0]=> + string(4) "true" + [1]=> + string(5) "false" + ["false"]=> + bool(false) + ["true"]=> + bool(true) + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(4) "true" + [3]=> + string(5) "false" + ["false"]=> + bool(false) + ["true"]=> + bool(true) +} +-- Iteration 16 -- +array(6) { + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" + ["emptys"]=> + string(0) "" + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [""]=> + string(6) "emptys" + ["emptyd"]=> + string(0) "" + ["emptys"]=> + string(0) "" +} +-- Iteration 17 -- +array(6) { + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +array(6) { + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +-- Iteration 18 -- +array(6) { + [""]=> + int(4) + [0]=> + int(5) + [1]=> + int(6) + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [""]=> + int(4) + [3]=> + int(5) + [4]=> + int(6) +} +-- Iteration 19 -- +array(6) { + ["One"]=> + int(10) + ["two"]=> + int(20) + ["three"]=> + int(3) + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" +} +array(6) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + ["One"]=> + int(10) + ["two"]=> + int(20) + ["three"]=> + int(3) +} +Done +--UEXPECTF-- +*** Testing array_pad() : Passing different arrays to $input argument *** +-- Iteration 1 -- +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + int(1) + [5]=> + int(2) +} +-- Iteration 2 -- +array(6) { + [0]=> + float(1.1) + [1]=> + float(2.2) + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + float(1.1) + [5]=> + float(2.2) +} +-- Iteration 3 -- +array(6) { + [0]=> + bool(false) + [1]=> + bool(true) + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + bool(false) + [5]=> + bool(true) +} +-- Iteration 4 -- +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +-- Iteration 5 -- +array(6) { + [0]=> + NULL + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + NULL +} +-- Iteration 6 -- +array(6) { + [0]=> + unicode(3) "a " + [1]=> + unicode(5) "aaaa +" + [2]=> + unicode(5) "b bbb" + [3]=> + unicode(27) "\[\]\!\@\#$\%\^\&\*\(\)\{\}" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(3) "a " + [3]=> + unicode(5) "aaaa +" + [4]=> + unicode(5) "b bbb" + [5]=> + unicode(27) "\[\]\!\@\#$\%\^\&\*\(\)\{\}" +} +-- Iteration 7 -- +array(6) { + [0]=> + unicode(5) "a\v\f" + [1]=> + unicode(6) "aaaa\r" + [2]=> + unicode(6) "b\tbbb" + [3]=> + unicode(28) "\[\]\!\@\#\$\%\^\&\*\(\)\{\}" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "a\v\f" + [3]=> + unicode(6) "aaaa\r" + [4]=> + unicode(6) "b\tbbb" + [5]=> + unicode(28) "\[\]\!\@\#\$\%\^\&\*\(\)\{\}" +} +-- Iteration 8 -- +array(6) { + [u"h1"]=> + unicode(1) " +" + [u"h2"]=> + unicode(86) "hello world +The big brown fox jumped over; +the lazy dog +This is a double quoted string" + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [0]=> + unicode(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [u"h1"]=> + unicode(1) " +" + [u"h2"]=> + unicode(86) "hello world +The big brown fox jumped over; +the lazy dog +This is a double quoted string" + [u"h3"]=> + unicode(88) "hello + world +1111 != 2222 +heredoc +double quoted string. with different white spaces" + [2]=> + unicode(90) "11 < 12. 123 >22 +'single quoted string' +"double quoted string" +2222 != 1111. 0000 = 0000 +" +} +-- Iteration 9 -- +array(6) { + [0]=> + unicode(3) "one" + [1]=> + unicode(3) "two" + [2]=> + unicode(5) "three" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(3) "one" + [4]=> + unicode(3) "two" + [5]=> + unicode(5) "three" +} +-- Iteration 10 -- +array(6) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u"one"]=> + int(1) + [u"two"]=> + int(2) + [u"three"]=> + int(3) +} +-- Iteration 11 -- +array(6) { + [0]=> + int(10) + [1]=> + int(20) + [2]=> + int(40) + [3]=> + int(30) + [4]=> + unicode(5) "HELLO" + [5]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + int(10) + [3]=> + int(20) + [4]=> + int(40) + [5]=> + int(30) +} +-- Iteration 12 -- +array(6) { + [u"one"]=> + unicode(3) "ten" + [u"two"]=> + unicode(6) "twenty" + [u"three"]=> + unicode(6) "thirty" + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u"one"]=> + unicode(3) "ten" + [u"two"]=> + unicode(6) "twenty" + [u"three"]=> + unicode(6) "thirty" +} +-- Iteration 13 -- +array(6) { + [u"one"]=> + int(1) + [0]=> + unicode(3) "two" + [1]=> + unicode(4) "four" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u"one"]=> + int(1) + [3]=> + unicode(3) "two" + [4]=> + unicode(4) "four" +} +-- Iteration 14 -- +array(6) { + [u""]=> + unicode(4) "null" + [u"NULL"]=> + NULL + [u"null"]=> + NULL + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u""]=> + unicode(4) "null" + [u"NULL"]=> + NULL + [u"null"]=> + NULL +} +-- Iteration 15 -- +array(6) { + [0]=> + unicode(4) "true" + [1]=> + unicode(5) "false" + [u"false"]=> + bool(false) + [u"true"]=> + bool(true) + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(4) "true" + [3]=> + unicode(5) "false" + [u"false"]=> + bool(false) + [u"true"]=> + bool(true) +} +-- Iteration 16 -- +array(6) { + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" + [u"emptys"]=> + unicode(0) "" + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u""]=> + unicode(6) "emptys" + [u"emptyd"]=> + unicode(0) "" + [u"emptys"]=> + unicode(0) "" +} +-- Iteration 17 -- +array(6) { + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +array(6) { + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + NULL + [4]=> + NULL + [5]=> + bool(false) + [6]=> + bool(true) +} +-- Iteration 18 -- +array(6) { + [u""]=> + int(4) + [0]=> + int(5) + [1]=> + int(6) + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u""]=> + int(4) + [3]=> + int(5) + [4]=> + int(6) +} +-- Iteration 19 -- +array(6) { + [u"One"]=> + int(10) + [u"two"]=> + int(20) + [u"three"]=> + int(3) + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" +} +array(6) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [u"One"]=> + int(10) + [u"two"]=> + int(20) + [u"three"]=> + int(3) +} +Done diff --git a/ext/standard/tests/array/array_pad_variation7.phpt b/ext/standard/tests/array/array_pad_variation7.phpt new file mode 100644 index 0000000000..f93575724a --- /dev/null +++ b/ext/standard/tests/array/array_pad_variation7.phpt @@ -0,0 +1,214 @@ +--TEST-- +Test array_pad() function : usage variations - two dimensional array for 'input' argument +--FILE-- + 1, "two" => 2) +); + +// initialize the $pad_size and $pad_value arguments +$pad_size = 5; +$pad_value = "HELLO"; + +// entire 2-d array +echo "-- Entire 2-d array for \$input argument --\n"; +var_dump( array_pad($input, $pad_size, $pad_value) ); // positive 'pad_size' +var_dump( array_pad($input, -$pad_size, $pad_value) ); // negative 'pad_size' + +// sub array +echo "-- Sub array for \$input argument --\n"; +var_dump( array_pad($input[1], $pad_size, $pad_value) ); // positive 'pad_size' +var_dump( array_pad($input[1], -$pad_size, $pad_value) ); // negative 'pad_size' + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_pad() : Passing 2-D array to $input argument *** +-- Entire 2-d array for $input argument -- +array(5) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [1]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [2]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" +} +array(5) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [3]=> + array(2) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + } + [4]=> + array(2) { + ["one"]=> + int(1) + ["two"]=> + int(2) + } +} +-- Sub array for $input argument -- +array(5) { + [0]=> + string(5) "hello" + [1]=> + string(5) "world" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "HELLO" + [4]=> + string(5) "HELLO" +} +array(5) { + [0]=> + string(5) "HELLO" + [1]=> + string(5) "HELLO" + [2]=> + string(5) "HELLO" + [3]=> + string(5) "hello" + [4]=> + string(5) "world" +} +Done +--UEXPECTF-- +*** Testing array_pad() : Passing 2-D array to $input argument *** +-- Entire 2-d array for $input argument -- +array(5) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [1]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [2]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" +} +array(5) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [3]=> + array(2) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + } + [4]=> + array(2) { + [u"one"]=> + int(1) + [u"two"]=> + int(2) + } +} +-- Sub array for $input argument -- +array(5) { + [0]=> + unicode(5) "hello" + [1]=> + unicode(5) "world" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "HELLO" + [4]=> + unicode(5) "HELLO" +} +array(5) { + [0]=> + unicode(5) "HELLO" + [1]=> + unicode(5) "HELLO" + [2]=> + unicode(5) "HELLO" + [3]=> + unicode(5) "hello" + [4]=> + unicode(5) "world" +} +Done