Annotation of embedaddon/php/ext/standard/tests/array/sizeof_basic2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test sizeof() function : basic functionality - for non-scalar type(array)
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : int sizeof(mixed $var[, int $mode] )
                      6:  * Description: Counts an elements in an array. If Standard PHP library is 
                      7:  *              installed, it will return the properties of an object.
                      8:  * Source code: ext/standard/basic_functions.c
                      9:  * Alias to functions: count()
                     10:  */
                     11: 
                     12: /* Testing the sizeof() for non-scalar type(array) value 
                     13:  * in default, COUNT_NORMAL and COUNT_RECURSIVE modes.
                     14:  * Sizeof() has been tested for simple integer, string,
                     15:  * indexed and mixed arrays.
                     16:  */ 
                     17: 
                     18: echo "*** Testing sizeof() : basic functionality ***\n";
                     19: 
                     20: $int_array = array(1, 2, 3, 4);
                     21: $string_array = array("Saffron", "White", "Green");
                     22: $indexed_array = array("Agression" => "Saffron", "Peace" => "White", "Growth" => "Green");
                     23: $mixed_array = array(1, 2, "Aggression" => "Saffron", 10 => "Ten", "Ten" => 10);
                     24: 
                     25: echo "-- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
                     26: echo "default mode: ";
                     27: var_dump( sizeof($int_array) );
                     28: echo "\n";
                     29: echo "COUNT_NORMAL mode: ";
                     30: var_dump( sizeof($int_array, COUNT_NORMAL) );
                     31: echo "\n";
                     32: echo "COUNT_RECURSIVE mode: ";
                     33: var_dump( sizeof($int_array, COUNT_RECURSIVE) );
                     34: echo "\n";
                     35: 
                     36: echo "-- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
                     37: echo "default mode: ";
                     38: var_dump( sizeof($string_array) );
                     39: echo "\n";
                     40: echo "COUNT_NORMAL mode: ";
                     41: var_dump( sizeof($string_array, COUNT_NORMAL) );
                     42: echo "\n";
                     43: echo "COUNT_RECURSIVE mode: ";
                     44: var_dump( sizeof($string_array, COUNT_RECURSIVE) );
                     45: echo "\n";
                     46: 
                     47: echo "-- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
                     48: echo "default mode: ";
                     49: var_dump( sizeof($indexed_array) );
                     50: echo "\n";
                     51: echo "COUNT_NORMAL mode: ";
                     52: var_dump( sizeof($indexed_array, COUNT_NORMAL) );
                     53: echo "\n";
                     54: echo "COUNT_RECURSIVE mode: ";
                     55: var_dump( sizeof($indexed_array, COUNT_RECURSIVE) );
                     56: echo "\n";
                     57: 
                     58: echo "-- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --\n";
                     59: echo "default mode: ";
                     60: var_dump( sizeof($mixed_array) );
                     61: echo "\n";
                     62: echo "COUNT_NORMAL mode: ";
                     63: var_dump( sizeof($mixed_array, COUNT_NORMAL) );
                     64: echo "\n";
                     65: echo "COUNT_RECURSIVE mode: ";
                     66: var_dump( sizeof($mixed_array, COUNT_RECURSIVE) );
                     67: 
                     68: echo "Done";
                     69: ?>
                     70: --EXPECTF--
                     71: *** Testing sizeof() : basic functionality ***
                     72: -- Testing sizeof() with integer array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
                     73: default mode: int(4)
                     74: 
                     75: COUNT_NORMAL mode: int(4)
                     76: 
                     77: COUNT_RECURSIVE mode: int(4)
                     78: 
                     79: -- Testing sizeof() with string array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
                     80: default mode: int(3)
                     81: 
                     82: COUNT_NORMAL mode: int(3)
                     83: 
                     84: COUNT_RECURSIVE mode: int(3)
                     85: 
                     86: -- Testing sizeof() with indexed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
                     87: default mode: int(3)
                     88: 
                     89: COUNT_NORMAL mode: int(3)
                     90: 
                     91: COUNT_RECURSIVE mode: int(3)
                     92: 
                     93: -- Testing sizeof() with mixed array in default, COUNT_NORMAL, COUNT_RECURSIVE modes --
                     94: default mode: int(5)
                     95: 
                     96: COUNT_NORMAL mode: int(5)
                     97: 
                     98: COUNT_RECURSIVE mode: int(5)
                     99: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>