Annotation of embedaddon/php/ext/standard/tests/array/array_combine_error2.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test array_combine() function : error conditions - empty array
3: --FILE--
4: <?php
5: /* Prototype : array array_combine(array $keys, array $values)
6: * Description: Creates an array by using the elements of the first parameter as keys
7: * and the elements of the second as the corresponding values
8: * Source code: ext/standard/array.c
9: */
10:
11: echo "*** Testing array_combine() : error conditions specific to array_combine() ***\n";
12:
13: // Testing array_combine by passing empty arrays to $keys and $values arguments
14: echo "\n-- Testing array_combine() function with empty arrays --\n";
15: var_dump( array_combine(array(), array()) );
16:
17: // Testing array_combine by passing empty array to $keys
18: echo "\n-- Testing array_combine() function with empty array for \$keys argument --\n";
19: var_dump( array_combine(array(), array(1, 2)) );
20:
21: // Testing array_combine by passing empty array to $values
22: echo "\n-- Testing array_combine() function with empty array for \$values argument --\n";
23: var_dump( array_combine(array(1, 2), array()) );
24:
25: // Testing array_combine with arrays having unequal number of elements
26: echo "\n-- Testing array_combine() function by passing array with unequal number of elements --\n";
27: var_dump( array_combine(array(1, 2), array(1, 2, 3)) );
28:
29: echo "Done";
30: ?>
31: --EXPECTF--
32: *** Testing array_combine() : error conditions specific to array_combine() ***
33:
34: -- Testing array_combine() function with empty arrays --
1.1.1.2 ! misho 35: array(0) {
! 36: }
1.1 misho 37:
38: -- Testing array_combine() function with empty array for $keys argument --
39:
40: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
41: bool(false)
42:
43: -- Testing array_combine() function with empty array for $values argument --
44:
45: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
46: bool(false)
47:
48: -- Testing array_combine() function by passing array with unequal number of elements --
49:
50: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
51: bool(false)
52: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>