From: Derick Rethans Date: Sat, 29 Dec 2001 21:05:03 +0000 (+0000) Subject: - Added test for recursive counting X-Git-Tag: PRE_ISSET_PATCH~369 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae07e930284c72b8367acf11863025d8497f03ce;p=php - Added test for recursive counting --- diff --git a/ext/standard/tests/array/count_recursive.phpt b/ext/standard/tests/array/count_recursive.phpt new file mode 100644 index 0000000000..6e7d141d81 --- /dev/null +++ b/ext/standard/tests/array/count_recursive.phpt @@ -0,0 +1,37 @@ +--TEST-- +count +--POST-- +--GET-- +--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 "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 "COUNT_NORMAL: should be 1, is ".count("string")."\n"; +print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n"; +?> +--EXPECT-- +Testing arrays... +COUNT_NORMAL: should be 2, is 2 +COUNT_RECURSIVE: should be 8, is 8 +Testing hashes... +COUNT_NORMAL: should be 3, is 3 +COUNT_RECURSIVE: should be 6, is 6 +Testing strings... +COUNT_NORMAL: should be 1, is 1 +COUNT_RECURSIVE: should be 1, is 1 +Testing various types with no second argument. +COUNT_NORMAL: should be 1, is 1 +COUNT_NORMAL: should be 2, is 2