From 904042bb83162c7a8fc3760a51ccf2c1780d2ef7 Mon Sep 17 00:00:00 2001 From: Zoe Slattery Date: Wed, 11 Apr 2007 11:44:37 +0000 Subject: [PATCH] new tests: array_merge, array_push, fprintf. modified tests: count_recursive, md5. --- ext/standard/tests/array/array_merge.phpt | 762 ++++++++++++++++++ ext/standard/tests/array/array_push.phpt | 282 +++++++ ext/standard/tests/array/count_recursive.phpt | 210 ++++- ext/standard/tests/strings/fprintf.phpt | Bin 0 -> 5884 bytes ext/standard/tests/strings/md5.phpt | Bin 612 -> 5821 bytes 5 files changed, 1240 insertions(+), 14 deletions(-) create mode 100644 ext/standard/tests/array/array_merge.phpt create mode 100644 ext/standard/tests/array/array_push.phpt create mode 100644 ext/standard/tests/strings/fprintf.phpt diff --git a/ext/standard/tests/array/array_merge.phpt b/ext/standard/tests/array/array_merge.phpt new file mode 100644 index 0000000000..85eeca8ab1 --- /dev/null +++ b/ext/standard/tests/array/array_merge.phpt @@ -0,0 +1,762 @@ +--TEST-- +Test array_merge() function +--FILE-- + "string"), + array( "" => "string"), + array( -2.44444 => 12), + array( "a" => 1, "b" => -2.344, "b" => "string", "c" => NULL, "d" => -2.344), + array( 4 => 1, 3 => -2.344, "3" => "string", "2" => NULL,1 => -2.344), + array( NULL, 1.23 => "Hi", "string" => "hello", + array("" => "World", "-2.34" => "a", "0" => "b")) +); + +$end_array = array( + array(), + array( 1 => "string"), + array( "" => "string"), + array( -2.44444 => 12), + array( "a" => 1, "b" => -2.344, "b" => "string", "c" => NULL, "d" => -2.344), + array( 4 => 1, 3 => -2.344, "3" => "string", "2" => NULL, 1=> -2.344), + array( NULL, 1.23 => "Hi", "string" => "hello", + array("" => "World", "-2.34" => "a", "0" => "b")) +); + +/* loop through to merge two arrays */ +$count_outer = 0; +foreach($begin_array as $first) { + echo "\n\n--- Iteration $count_outer ---"; + $count_inner = 0; + foreach($end_array as $second) { + echo "\n-- Inner iteration $count_inner of Iteration $count_outer --\n"; + $result = array_merge($first, $second); + print_r($result); + $count_inner++; + } + $count_outer++; +} + + +echo "\n*** Testing array_merge() with three or more arrays ***\n"; +var_dump( array_merge( $end_array[0], + $end_array[5], + $end_array[4], + $end_array[6] + ) + ); + +var_dump( array_merge( $end_array[0], + $end_array[5], + array("array on fly"), + array("nullarray" => array()) + ) + ); + + +echo "\n*** Testing single array argument ***\n"; +/* Empty array */ +var_dump(array_merge(array())); + +/* associative array with string keys, which will not be re-indexed */ +var_dump(array_merge($begin_array[4])); + +/* associative array with numeric keys, which will be re-indexed */ +var_dump(array_merge($begin_array[5])); + +/* associative array with mixed keys and sub-array as element */ +var_dump(array_merge($begin_array[6])); + +echo "\n*** Testing array_merge() with typecasting non-array to array ***\n"; +var_dump(array_merge($begin_array[4], (array)"type1", (array)10, (array)12.34)); + +echo "\n*** Testing error conditions ***"; +/* Invalid argumens */ +var_dump(array_merge()); +var_dump(array_merge(100, 200)); +var_dump(array_merge($begin_array[0], $begin_array[1], 100)); +var_dump(array_merge($begin_array[0], $begin_array[1], $arr4)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_merge() basic functionality *** + +--- Iteration 0 --- +-- Inner iteration 0 of Iteration 0 -- +Array +( +) + +-- Inner iteration 1 of Iteration 0 -- +Array +( + [0] => string +) + +-- Inner iteration 2 of Iteration 0 -- +Array +( + [] => string +) + +-- Inner iteration 3 of Iteration 0 -- +Array +( + [0] => 12 +) + +-- Inner iteration 4 of Iteration 0 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 0 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 +) + +-- Inner iteration 6 of Iteration 0 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 1 --- +-- Inner iteration 0 of Iteration 1 -- +Array +( + [0] => string +) + +-- Inner iteration 1 of Iteration 1 -- +Array +( + [0] => string + [1] => string +) + +-- Inner iteration 2 of Iteration 1 -- +Array +( + [0] => string + [] => string +) + +-- Inner iteration 3 of Iteration 1 -- +Array +( + [0] => string + [1] => 12 +) + +-- Inner iteration 4 of Iteration 1 -- +Array +( + [0] => string + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 1 -- +Array +( + [0] => string + [1] => 1 + [2] => string + [3] => + [4] => -2.344 +) + +-- Inner iteration 6 of Iteration 1 -- +Array +( + [0] => string + [1] => + [2] => Hi + [string] => hello + [3] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 2 --- +-- Inner iteration 0 of Iteration 2 -- +Array +( + [] => string +) + +-- Inner iteration 1 of Iteration 2 -- +Array +( + [] => string + [0] => string +) + +-- Inner iteration 2 of Iteration 2 -- +Array +( + [] => string +) + +-- Inner iteration 3 of Iteration 2 -- +Array +( + [] => string + [0] => 12 +) + +-- Inner iteration 4 of Iteration 2 -- +Array +( + [] => string + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 2 -- +Array +( + [] => string + [0] => 1 + [1] => string + [2] => + [3] => -2.344 +) + +-- Inner iteration 6 of Iteration 2 -- +Array +( + [] => string + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 3 --- +-- Inner iteration 0 of Iteration 3 -- +Array +( + [0] => 12 +) + +-- Inner iteration 1 of Iteration 3 -- +Array +( + [0] => 12 + [1] => string +) + +-- Inner iteration 2 of Iteration 3 -- +Array +( + [0] => 12 + [] => string +) + +-- Inner iteration 3 of Iteration 3 -- +Array +( + [0] => 12 + [1] => 12 +) + +-- Inner iteration 4 of Iteration 3 -- +Array +( + [0] => 12 + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 3 -- +Array +( + [0] => 12 + [1] => 1 + [2] => string + [3] => + [4] => -2.344 +) + +-- Inner iteration 6 of Iteration 3 -- +Array +( + [0] => 12 + [1] => + [2] => Hi + [string] => hello + [3] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 4 --- +-- Inner iteration 0 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 1 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 + [0] => string +) + +-- Inner iteration 2 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 + [] => string +) + +-- Inner iteration 3 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 + [0] => 12 +) + +-- Inner iteration 4 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 + [0] => 1 + [1] => string + [2] => + [3] => -2.344 +) + +-- Inner iteration 6 of Iteration 4 -- +Array +( + [a] => 1 + [b] => string + [c] => + [d] => -2.344 + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 5 --- +-- Inner iteration 0 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 +) + +-- Inner iteration 1 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [4] => string +) + +-- Inner iteration 2 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [] => string +) + +-- Inner iteration 3 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [4] => 12 +) + +-- Inner iteration 4 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [4] => 1 + [5] => string + [6] => + [7] => -2.344 +) + +-- Inner iteration 6 of Iteration 5 -- +Array +( + [0] => 1 + [1] => string + [2] => + [3] => -2.344 + [4] => + [5] => Hi + [string] => hello + [6] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + + +--- Iteration 6 --- +-- Inner iteration 0 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + +-- Inner iteration 1 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [3] => string +) + +-- Inner iteration 2 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [] => string +) + +-- Inner iteration 3 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [3] => 12 +) + +-- Inner iteration 4 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [a] => 1 + [b] => string + [c] => + [d] => -2.344 +) + +-- Inner iteration 5 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [3] => 1 + [4] => string + [5] => + [6] => -2.344 +) + +-- Inner iteration 6 of Iteration 6 -- +Array +( + [0] => + [1] => Hi + [string] => hello + [2] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + + [3] => + [4] => Hi + [5] => Array + ( + [] => World + [-2.34] => a + [0] => b + ) + +) + +*** Testing array_merge() with three or more arrays *** +array(12) { + [0]=> + int(1) + [1]=> + string(6) "string" + [2]=> + NULL + [3]=> + float(-2.344) + ["a"]=> + int(1) + ["b"]=> + string(6) "string" + ["c"]=> + NULL + ["d"]=> + float(-2.344) + [4]=> + NULL + [5]=> + string(2) "Hi" + ["string"]=> + string(5) "hello" + [6]=> + array(3) { + [""]=> + string(5) "World" + ["-2.34"]=> + string(1) "a" + [0]=> + string(1) "b" + } +} +array(6) { + [0]=> + int(1) + [1]=> + string(6) "string" + [2]=> + NULL + [3]=> + float(-2.344) + [4]=> + string(12) "array on fly" + ["nullarray"]=> + array(0) { + } +} + +*** Testing single array argument *** +array(0) { +} +array(4) { + ["a"]=> + int(1) + ["b"]=> + string(6) "string" + ["c"]=> + NULL + ["d"]=> + float(-2.344) +} +array(4) { + [0]=> + int(1) + [1]=> + string(6) "string" + [2]=> + NULL + [3]=> + float(-2.344) +} +array(4) { + [0]=> + NULL + [1]=> + string(2) "Hi" + ["string"]=> + string(5) "hello" + [2]=> + array(3) { + [""]=> + string(5) "World" + ["-2.34"]=> + string(1) "a" + [0]=> + string(1) "b" + } +} + +*** Testing array_merge() with typecasting non-array to array *** +array(7) { + ["a"]=> + int(1) + ["b"]=> + string(6) "string" + ["c"]=> + NULL + ["d"]=> + float(-2.344) + [0]=> + string(5) "type1" + [1]=> + int(10) + [2]=> + float(12.34) +} + +*** Testing error conditions *** +Warning: Wrong parameter count for array_merge() in %s on line %d +NULL + +Warning: array_merge(): Argument #1 is not an array in %s on line %d + +Warning: array_merge(): Argument #2 is not an array in %s on line %d +NULL + +Warning: array_merge(): Argument #3 is not an array in %s on line %d +NULL + +Notice: Undefined variable: arr4 in %s on line %d + +Warning: array_merge(): Argument #3 is not an array in %s on line %d +NULL +Done diff --git a/ext/standard/tests/array/array_push.phpt b/ext/standard/tests/array/array_push.phpt new file mode 100644 index 0000000000..b06ee6d3d3 --- /dev/null +++ b/ext/standard/tests/array/array_push.phpt @@ -0,0 +1,282 @@ +--TEST-- +Test array_push() function +--FILE-- + "aaa", "A" => "AAA", "c" => "ccc", "d" => "ddd", "e" => "eee" ), + array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ), + array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ), + array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF", + "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ), + array( 12, "name", 'age', '45' ), + array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ), + array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6, + 5.4 => 54, 5.7 => 57, "5.4" => 554, "5.7" => 557 ) +); + +/* Error Conditions */ +echo "\n*** Testing Error Conditions ***\n"; + +/* Zero argument */ +var_dump( array_push() ); + +/* Scalar argument */ +var_dump( array_push($number, 22) ); + +/* String argument */ +var_dump( array_push($str, 22) ); + +/* Invalid Number of arguments */ +var_dump( array_push($mixed_array[1],1,2) ); + +/* Empty Array as argument */ +var_dump( array_push($empty_array, 2) ); + + +/* Loop to test normal functionality with different arrays inputs */ +echo "\n*** Testing with various array inputs ***\n"; + +$counter = 1; +foreach( $mixed_array as $sub_array ) +{ + echo "\n-- Input Array for Iteration $counter is --\n"; + print_r( $sub_array ); + echo "\nOutput after push is :\n"; + var_dump( array_push($sub_array, 22, "abc") ); + $counter++; +} + +/* Checking for return value and the new array formed from push operation */ +echo "\n*** Checking for return value and the new array formed from push operation ***\n"; +var_dump( array_push($mixed_array[2], 22, 33, "44") ); +var_dump( $mixed_array[2] ); + +echo"\nDone"; +?> +--EXPECTF-- +*** Testing Error Conditions *** + +Warning: Wrong parameter count for array_push() in %s on line %d +NULL + +Warning: array_push(): First argument should be an array in %s on line %d +bool(false) + +Warning: array_push(): First argument should be an array in %s on line %d +bool(false) +int(11) +int(1) + +*** Testing with various array inputs *** + +-- Input Array for Iteration 1 is -- +Array +( +) + +Output after push is : +int(2) + +-- Input Array for Iteration 2 is -- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 1 + [10] => 2 +) + +Output after push is : +int(13) + +-- Input Array for Iteration 3 is -- +Array +( + [0] => One + [1] => _Two + [2] => Three + [3] => Four + [4] => Five +) + +Output after push is : +int(7) + +-- Input Array for Iteration 4 is -- +Array +( + [0] => 6 + [1] => six + [2] => 7 + [3] => seven + [4] => 8 + [5] => eight + [6] => 9 + [7] => nine +) + +Output after push is : +int(10) + +-- Input Array for Iteration 5 is -- +Array +( + [a] => aaa + [A] => AAA + [c] => ccc + [d] => ddd + [e] => eee +) + +Output after push is : +int(7) + +-- Input Array for Iteration 6 is -- +Array +( + [1] => one + [2] => two + [3] => three + [4] => four + [5] => five +) + +Output after push is : +int(7) + +-- Input Array for Iteration 7 is -- +Array +( + [1] => one + [2] => two + [3] => 7 + [4] => four + [5] => five +) + +Output after push is : +int(7) + +-- Input Array for Iteration 8 is -- +Array +( + [f] => fff + [1] => one + [4] => 6 + [] => 3 + [2] => float + [F] => FFF + [blank] => + [3] => 3.7 + [5] => Five + [6] => 8.6 + [4name] => jonny + [a] => +) + +Output after push is : +int(14) + +-- Input Array for Iteration 9 is -- +Array +( + [0] => 12 + [1] => name + [2] => age + [3] => 45 +) + +Output after push is : +int(6) + +-- Input Array for Iteration 10 is -- +Array +( + [0] => Array + ( + [0] => oNe + [1] => tWo + [2] => 4 + ) + + [1] => Array + ( + [0] => 10 + [1] => 20 + [2] => 30 + [3] => 40 + [4] => 50 + ) + + [2] => Array + ( + ) + +) + +Output after push is : +int(5) + +-- Input Array for Iteration 11 is -- +Array +( + [one] => 2 + [three] => 3 + [0] => 3 + [1] => 4 + [3] => 33 + [4] => 44 + [5] => 57 + [6] => 6 + [5.4] => 554 + [5.7] => 557 +) + +Output after push is : +int(12) + +*** Checking for return value and the new array formed from push operation *** +int(8) +array(8) { + [0]=> + string(3) "One" + [1]=> + string(4) "_Two" + [2]=> + string(5) "Three" + [3]=> + string(4) "Four" + [4]=> + string(4) "Five" + [5]=> + int(22) + [6]=> + int(33) + [7]=> + string(2) "44" +} + +Done diff --git a/ext/standard/tests/array/count_recursive.phpt b/ext/standard/tests/array/count_recursive.phpt index e6824ab0e5..71f620afbd 100644 --- a/ext/standard/tests/array/count_recursive.phpt +++ b/ext/standard/tests/array/count_recursive.phpt @@ -1,52 +1,234 @@ --TEST-- -count +Test count() function --FILE-- 1, "b" => 2, array("c" => 3, array("d" => 5))); print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n"; print "COUNT_RECURSIVE: should be 6, is ".count($arr, COUNT_RECURSIVE)."\n"; -print "Testing strings...\n"; +print "-- Testing strings --\n"; print "COUNT_NORMAL: should be 1, is ".count("string", COUNT_NORMAL)."\n"; print "COUNT_RECURSIVE: should be 1, is ".count("string", COUNT_RECURSIVE)."\n"; -print "Testing various types with no second argument.\n"; +print "-- Testing various types with no second argument --\n"; print "COUNT_NORMAL: should be 1, is ".count("string")."\n"; print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n"; $arr = array('a'=>array(NULL, NULL, NULL), 1=>array(NULL=>1, 1=>NULL), array(array(array(array(array(NULL)))))); -print "Testing really cool arrays ;)\n"; +print "-- Testing really cool arrays --\n"; print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n"; print "COUNT_RECURSIVE: should be 13, is ".count($arr, COUNT_RECURSIVE)."\n"; + +echo "\n*** Testing possible variations of count() function on arrays ***"; +$count_array = array( + array(), + array( 1 => "string"), + array( "" => "string", 0 => "a", NULL => "b", -1.00 => "c", + array(array(array(NULL)))), + array( -2.44444 => 12, array(array(1, 2, array(array("0"))))), + array( "a" => 1, "b" => -2.344, "b" => "string", "c" => NULL, "d" => -2.344), + array( 4 => 1, 3 => -2.344, "3" => "string", "2" => NULL, + 1 => -2.344, array()), + array( TRUE => TRUE, FALSE => FALSE, "" => "", " " => " ", + NULL => NULL, "\x000" => "\x000", "\000" => "\000"), + array( NULL, 1.23 => "Hi", "string" => "hello", + array("" => "World", "-2.34" => "a", "0" => "b")) +); + +$i = 0; +foreach ($count_array as $count_value) { + echo "\n-- Iteration $i --\n"; + print "COUNT_NORMAL is ".count($count_value, COUNT_NORMAL)."\n"; + print "COUNT_RECURSIVE is ".count($count_value, COUNT_RECURSIVE)."\n"; + $i++; +} + + +/* Testing count() by passing constant with no second argument */ +print "\n-- Testing count() on constants with no second argument --\n"; +print "COUNT_NORMAL: should be 1, is ".count(100)."\n"; +print "COUNT_NORMAL: should be 1, is ".count(-23.45)."\n"; + +print "\n-- Testing count() on NULL and Unset variables --\n"; +print "COUNT_NORMAL: should be 0, is ".count(NULL)."\n"; +print "COUNT_NORMAL: should be 1, is ".count("")."\n"; +print "COUNT_NORMAL: should be 0, is ".@count($a)."\n"; + + +print "\n-- Testing count() on an empty sub-array --\n"; +$arr = array(1, array(3, 4, array())); +print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n"; +print "COUNT_RECURSIVE: should be 5, is ".count($arr, COUNT_RECURSIVE)."\n"; + +echo "\n-- Testing count() on objects with Countable interface --\n"; +class count_class implements Countable { + private $var_private; + public $var_public; + protected $var_protected; + + public function count() { + return 3; + } +} + +$obj = new count_class(); +print "COUNT_NORMAL: should be 3, is ".count($obj)."\n"; + + +echo "\n-- Testing count() on resource type --\n"; +$resource1 = fopen( __FILE__, "r" ); // Creating file(stream type) resource +$resource2 = opendir( "." ); // Creating dir resource + +/* creating an array with resources as elements */ +$arr_resource = array("a" => $resource1, "b" => $resource2); +var_dump(count($arr_resource)); + +echo "\n-- Testing count() on arrays containing references --\n"; +$arr = array(1, array("a", "b", "c")); +$arr[2] = &$arr[1]; + +$mode_arr = array( COUNT_NORMAL, COUNT_RECURSIVE, 0, 1, -1, -1.45, 2, TRUE, + FALSE, NULL); +for( $i =0; $i < count( $mode_arr ); $i++) { + echo "For mode '$mode_arr[$i]' count is => "; + var_dump(count($arr, $mode_arr[$i])); +} + + +echo "\n-- Testing error conditions --"; +var_dump( count() ); // No. of args = 0 +var_dump( count(array(), COUNT_NORMAL, 100) ); // No. of args > expected + +/* Testing Invalid type arguments */ +var_dump( count("string", ABCD) ); +var_dump( count(100, "string") ); +var_dump( count(array(), "") ); + +echo "\nDone"; + +--CLEAN-- +/* closing the resource handles */ +fclose( $resource1 ); +closedir( $resource2 ); ?> ---EXPECT-- -Testing NULL... +--EXPECTF-- +*** Testing basic functionality of count() function *** +-- Testing NULL -- COUNT_NORMAL: should be 0, is 0 COUNT_RECURSIVE: should be 0, is 0 -Testing arrays... +-- Testing arrays -- COUNT_NORMAL: should be 2, is 2 COUNT_RECURSIVE: should be 8, is 8 -Testing hashes... +-- Testing hashes -- COUNT_NORMAL: should be 3, is 3 COUNT_RECURSIVE: should be 6, is 6 -Testing strings... +-- Testing strings -- COUNT_NORMAL: should be 1, is 1 COUNT_RECURSIVE: should be 1, is 1 -Testing various types with no second argument. +-- Testing various types with no second argument -- COUNT_NORMAL: should be 1, is 1 COUNT_NORMAL: should be 2, is 2 -Testing really cool arrays ;) +-- Testing really cool arrays -- COUNT_NORMAL: should be 3, is 3 COUNT_RECURSIVE: should be 13, is 13 + +*** Testing possible variations of count() function on arrays *** +-- Iteration 0 -- +COUNT_NORMAL is 0 +COUNT_RECURSIVE is 0 + +-- Iteration 1 -- +COUNT_NORMAL is 1 +COUNT_RECURSIVE is 1 + +-- Iteration 2 -- +COUNT_NORMAL is 4 +COUNT_RECURSIVE is 7 + +-- Iteration 3 -- +COUNT_NORMAL is 2 +COUNT_RECURSIVE is 8 + +-- Iteration 4 -- +COUNT_NORMAL is 4 +COUNT_RECURSIVE is 4 + +-- Iteration 5 -- +COUNT_NORMAL is 5 +COUNT_RECURSIVE is 5 + +-- Iteration 6 -- +COUNT_NORMAL is 6 +COUNT_RECURSIVE is 6 + +-- Iteration 7 -- +COUNT_NORMAL is 4 +COUNT_RECURSIVE is 7 + +-- Testing count() on constants with no second argument -- +COUNT_NORMAL: should be 1, is 1 +COUNT_NORMAL: should be 1, is 1 + +-- Testing count() on NULL and Unset variables -- +COUNT_NORMAL: should be 0, is 0 +COUNT_NORMAL: should be 1, is 1 +COUNT_NORMAL: should be 0, is 0 + +-- Testing count() on an empty sub-array -- +COUNT_NORMAL: should be 2, is 2 +COUNT_RECURSIVE: should be 5, is 5 + +-- Testing count() on objects with Countable interface -- +COUNT_NORMAL: should be 3, is 3 + +-- Testing count() on resource type -- +int(2) + +-- Testing count() on arrays containing references -- +For mode '0' count is => int(3) +For mode '1' count is => int(9) +For mode '0' count is => int(3) +For mode '1' count is => int(9) +For mode '-1' count is => int(3) +For mode '-1.45' count is => int(3) +For mode '2' count is => int(3) +For mode '1' count is => int(9) +For mode '' count is => int(3) +For mode '' count is => int(3) + +-- Testing error conditions -- +Warning: count() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: count() expects at most 2 parameters, 3 given in %s on line %d +NULL + +Notice: Use of undefined constant ABCD - assumed 'ABCD' in %s on line %d + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +Done diff --git a/ext/standard/tests/strings/fprintf.phpt b/ext/standard/tests/strings/fprintf.phpt new file mode 100644 index 0000000000000000000000000000000000000000..6ffa62a233600e1aa934fb19df18e9d72a7c5373 GIT binary patch literal 5884 zcmd5=ZExE)5Z-703eJh)SGkt#*mJwBAJP;ERtyE2p##>!U}P#5U`rk)ujz*UwEed| zchsA0#jTqTn1bl|ay&kFygME3I5$^sZX8G4=p>cF#)MHCv^z4`Mt&N`k#L+hKV84R zehHTEpKq2MA-K#9^7_@)eBOB`&KD|G^B`Pl%r}_v$zr?S4DQp$ zGZ6;z+xB^|!CVk;bkr`{`?B?+)#=E;gp}G}#W_4 zB>1IzPrCB8iPJd!xY17~%u!fH8lA*jgDsaTTC8+mCMoQNony0B>2H0x4)1|WnY%<5 zy}@Ac{=Mu7*_AJJ;+t?oc6}<}8bYM9#iUOr4X72hwOV7*6Bs;L#VVcup-iY~E$pX^ zQ6Jl~(F_{>M$^F??VcsmfoB^|(Ha&lr);*)cvRB4*&U+o`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