From c1e7564369106a0c72c0d61bd580343b18bc6c10 Mon Sep 17 00:00:00 2001 From: Josie Messa Date: Thu, 14 Feb 2008 16:48:27 +0000 Subject: [PATCH] - New tests for count() function --- ext/standard/tests/array/count_basic.phpt | 57 ++++ ext/standard/tests/array/count_error.phpt | 54 ++++ .../tests/array/count_variation1.phpt | 245 ++++++++++++++++ .../tests/array/count_variation2.phpt | 276 ++++++++++++++++++ .../tests/array/count_variation3.phpt | 42 +++ 5 files changed, 674 insertions(+) create mode 100644 ext/standard/tests/array/count_basic.phpt create mode 100644 ext/standard/tests/array/count_error.phpt create mode 100644 ext/standard/tests/array/count_variation1.phpt create mode 100644 ext/standard/tests/array/count_variation2.phpt create mode 100644 ext/standard/tests/array/count_variation3.phpt diff --git a/ext/standard/tests/array/count_basic.phpt b/ext/standard/tests/array/count_basic.phpt new file mode 100644 index 0000000000..9c92d8c464 --- /dev/null +++ b/ext/standard/tests/array/count_basic.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test count() function : basic functionality +--FILE-- + +--EXPECTF-- +*** Testing count() : basic functionality *** + +-- One Dimensional Array: -- +int(3) + +-- Two Dimensional Array: -- +$mode = COUNT_NORMAL: int(3) +$mode = 0: int(3) +$mode = COUNT_RECURSIVE: int(6) +$mode = 1: int(6) +Done +--UEXPECTF-- +*** Testing count() : basic functionality *** + +-- One Dimensional Array: -- +int(3) + +-- Two Dimensional Array: -- +$mode = COUNT_NORMAL: int(3) +$mode = 0: int(3) +$mode = COUNT_RECURSIVE: int(6) +$mode = 1: int(6) +Done \ No newline at end of file diff --git a/ext/standard/tests/array/count_error.phpt b/ext/standard/tests/array/count_error.phpt new file mode 100644 index 0000000000..71636c6bf5 --- /dev/null +++ b/ext/standard/tests/array/count_error.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test count() function : error conditions - pass incorrect number of args +--FILE-- + +--EXPECTF-- +*** Testing count() : error conditions *** + +-- Testing count() function with Zero arguments -- + +Warning: count() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing count() function with more than expected no. of arguments -- + +Warning: count() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing count() : error conditions *** + +-- Testing count() function with Zero arguments -- + +Warning: count() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing count() function with more than expected no. of arguments -- + +Warning: count() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/ext/standard/tests/array/count_variation1.phpt b/ext/standard/tests/array/count_variation1.phpt new file mode 100644 index 0000000000..27a3119a02 --- /dev/null +++ b/ext/standard/tests/array/count_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test count() function : usage variations - Pass different data types as $var arg +--FILE-- + +--EXPECTF-- +*** Testing count() : usage variations *** + +-- Iteration 1 -- +int(1) + +-- Iteration 2 -- +int(1) + +-- Iteration 3 -- +int(1) + +-- Iteration 4 -- +int(1) + +-- Iteration 5 -- +int(1) + +-- Iteration 6 -- +int(1) + +-- Iteration 7 -- +int(1) + +-- Iteration 8 -- +int(1) + +-- Iteration 9 -- +int(1) + +-- Iteration 10 -- +int(0) + +-- Iteration 11 -- +int(0) + +-- Iteration 12 -- +int(1) + +-- Iteration 13 -- +int(1) + +-- Iteration 14 -- +int(1) + +-- Iteration 15 -- +int(1) + +-- Iteration 16 -- +int(1) + +-- Iteration 17 -- +int(1) + +-- Iteration 18 -- +int(1) + +-- Iteration 19 -- +int(1) + +-- Iteration 20 -- +int(1) + +-- Iteration 21 -- +int(1) + +-- Iteration 22 -- +int(0) + +-- Iteration 23 -- +int(0) + +-- Iteration 24 -- +int(1) +Done +--UEXPECTF-- +*** Testing count() : usage variations *** + +-- Iteration 1 -- +int(1) + +-- Iteration 2 -- +int(1) + +-- Iteration 3 -- +int(1) + +-- Iteration 4 -- +int(1) + +-- Iteration 5 -- +int(1) + +-- Iteration 6 -- +int(1) + +-- Iteration 7 -- +int(1) + +-- Iteration 8 -- +int(1) + +-- Iteration 9 -- +int(1) + +-- Iteration 10 -- +int(0) + +-- Iteration 11 -- +int(0) + +-- Iteration 12 -- +int(1) + +-- Iteration 13 -- +int(1) + +-- Iteration 14 -- +int(1) + +-- Iteration 15 -- +int(1) + +-- Iteration 16 -- +int(1) + +-- Iteration 17 -- +int(1) + +-- Iteration 18 -- +int(1) + +-- Iteration 19 -- +int(1) + +-- Iteration 20 -- +int(1) + +-- Iteration 21 -- +int(1) + +-- Iteration 22 -- +int(0) + +-- Iteration 23 -- +int(0) + +-- Iteration 24 -- +int(1) +Done \ No newline at end of file diff --git a/ext/standard/tests/array/count_variation2.phpt b/ext/standard/tests/array/count_variation2.phpt new file mode 100644 index 0000000000..10f490b4fc --- /dev/null +++ b/ext/standard/tests/array/count_variation2.phpt @@ -0,0 +1,276 @@ +--TEST-- +Test count() function : usage variations - Pass different data types as $mode arg +--FILE-- + +--EXPECTF-- +*** Testing count() : usage variations *** + +-- Iteration 1 -- +int(3) + +-- Iteration 2 -- +int(5) + +-- Iteration 3 -- +int(3) + +-- Iteration 4 -- +int(3) + +-- Iteration 5 -- +int(3) + +-- Iteration 6 -- +int(3) + +-- Iteration 7 -- +int(3) + +-- Iteration 8 -- +int(3) + +-- Iteration 9 -- +int(3) + +-- Iteration 10 -- +int(3) + +-- Iteration 11 -- +int(3) + +-- Iteration 12 -- +int(5) + +-- Iteration 13 -- +int(3) + +-- Iteration 14 -- +int(5) + +-- Iteration 15 -- +int(3) + +-- Iteration 16 -- + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: count() expects parameter 2 to be long, string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: count() expects parameter 2 to be long, object given in %s on line %d +NULL + +-- Iteration 22 -- +int(3) + +-- Iteration 23 -- +int(3) + +-- Iteration 24 -- + +Warning: count() expects parameter 2 to be long, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing count() : usage variations *** + +-- Iteration 1 -- +int(3) + +-- Iteration 2 -- +int(5) + +-- Iteration 3 -- +int(3) + +-- Iteration 4 -- +int(3) + +-- Iteration 5 -- +int(3) + +-- Iteration 6 -- +int(3) + +-- Iteration 7 -- +int(3) + +-- Iteration 8 -- +int(3) + +-- Iteration 9 -- +int(3) + +-- Iteration 10 -- +int(3) + +-- Iteration 11 -- +int(3) + +-- Iteration 12 -- +int(5) + +-- Iteration 13 -- +int(3) + +-- Iteration 14 -- +int(5) + +-- Iteration 15 -- +int(3) + +-- Iteration 16 -- + +Warning: count() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: count() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: count() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: count() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: count() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: count() expects parameter 2 to be long, object given in %s on line %d +NULL + +-- Iteration 22 -- +int(3) + +-- Iteration 23 -- +int(3) + +-- Iteration 24 -- + +Warning: count() expects parameter 2 to be long, resource given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/ext/standard/tests/array/count_variation3.phpt b/ext/standard/tests/array/count_variation3.phpt new file mode 100644 index 0000000000..c867837c77 --- /dev/null +++ b/ext/standard/tests/array/count_variation3.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test count() function : usage variations - Infinitely recursive array +--FILE-- + +--EXPECTF-- +*** Testing count() : usage variations *** + +-- $mode not set: -- +int(4) + +-- $mode = 1: -- +--UEXPECTF-- +*** Testing count() : usage variations *** + +-- $mode not set: -- +int(4) + +-- $mode = 1: -- \ No newline at end of file -- 2.40.0