Annotation of embedaddon/php/ext/standard/tests/strings/count_chars_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test count_chars() function : usage variations - test values for $mode argument
        !             3: --FILE--
        !             4: <?php
        !             5: 
        !             6: /* Prototype  : mixed count_chars  ( string $string  [, int $mode  ] )
        !             7:  * Description: Return information about characters used in a string
        !             8:  * Source code: ext/standard/string.c
        !             9: */
        !            10: 
        !            11: echo "*** Testing count_chars() function: with unexpected inputs for 'mode' argument ***\n";
        !            12: 
        !            13: //get an unset variable
        !            14: $unset_var = 'string_val';
        !            15: unset($unset_var);
        !            16: 
        !            17: //defining a class
        !            18: class sample  {
        !            19: }
        !            20: 
        !            21: // array with different values for $input
        !            22: $inputs =  array (
        !            23: 
        !            24:                          // integer values
        !            25: /* 1 */                  0,
        !            26:                          1,
        !            27:                          255,
        !            28:                          2147483647,
        !            29:                      -2147483648,
        !            30:                        
        !            31:                          // float values
        !            32: /* 6 */                  0.0,
        !            33:                          1.3,
        !            34:                          10.5,
        !            35:                          -20.5,
        !            36:                          10.1234567e10,
        !            37:                        
        !            38:                          // array values
        !            39: /* 11 */         array(),
        !            40:                          array(1, 2, 3, 4, 5, 6, 7, 8, 9),
        !            41:                        
        !            42:                          // boolean values
        !            43: /* 14 */         true,
        !            44:                          false,
        !            45:                          TRUE,
        !            46:                          FALSE,
        !            47:                        
        !            48:                          // null values
        !            49: /* 18 */         NULL,
        !            50:                          null,
        !            51:                          
        !            52:                          // string values
        !            53: /* 20 */         "ABCD",
        !            54:                          'abcd',
        !            55:                          "1ABC",
        !            56:                          "5ABC",
        !            57:                          
        !            58:                          // objects
        !            59: /* 24 */         new sample(),
        !            60:                        
        !            61:                           // undefined variable
        !            62: /* 25 */         @$undefined_var,
        !            63:                        
        !            64:                          // unset variable
        !            65: /* 26 */         @$unset_var
        !            66: );
        !            67: 
        !            68: // loop through with each element of the $inputs array to test count_chars() function
        !            69: // with unexepcted values for the 'mode' argument
        !            70: $count = 1;
        !            71: $string = "Return information about characters used in a string";
        !            72: foreach($inputs as $input) {
        !            73:   echo "-- Iteration $count --\n";
        !            74:   // only list characters with a frequency > 0
        !            75:   var_dump(is_array(count_chars($string, $input)));
        !            76:   $count ++;
        !            77: }
        !            78: 
        !            79: 
        !            80: ?>
        !            81: ===DONE===
        !            82: --EXPECTF--
        !            83: *** Testing count_chars() function: with unexpected inputs for 'mode' argument ***
        !            84: -- Iteration 1 --
        !            85: bool(true)
        !            86: -- Iteration 2 --
        !            87: bool(true)
        !            88: -- Iteration 3 --
        !            89: 
        !            90: Warning: count_chars(): Unknown mode in %s on line %d
        !            91: bool(false)
        !            92: -- Iteration 4 --
        !            93: 
        !            94: Warning: count_chars(): Unknown mode in %s on line %d
        !            95: bool(false)
        !            96: -- Iteration 5 --
        !            97: 
        !            98: Warning: count_chars(): Unknown mode in %s on line %d
        !            99: bool(false)
        !           100: -- Iteration 6 --
        !           101: bool(true)
        !           102: -- Iteration 7 --
        !           103: bool(true)
        !           104: -- Iteration 8 --
        !           105: 
        !           106: Warning: count_chars(): Unknown mode in %s on line %d
        !           107: bool(false)
        !           108: -- Iteration 9 --
        !           109: 
        !           110: Warning: count_chars(): Unknown mode in %s on line %d
        !           111: bool(false)
        !           112: -- Iteration 10 --
        !           113: 
        !           114: Warning: count_chars(): Unknown mode in %s on line %d
        !           115: bool(false)
        !           116: -- Iteration 11 --
        !           117: 
        !           118: Warning: count_chars() expects parameter 2 to be long, array given in %s on line %d
        !           119: bool(false)
        !           120: -- Iteration 12 --
        !           121: 
        !           122: Warning: count_chars() expects parameter 2 to be long, array given in %s on line %d
        !           123: bool(false)
        !           124: -- Iteration 13 --
        !           125: bool(true)
        !           126: -- Iteration 14 --
        !           127: bool(true)
        !           128: -- Iteration 15 --
        !           129: bool(true)
        !           130: -- Iteration 16 --
        !           131: bool(true)
        !           132: -- Iteration 17 --
        !           133: bool(true)
        !           134: -- Iteration 18 --
        !           135: bool(true)
        !           136: -- Iteration 19 --
        !           137: 
        !           138: Warning: count_chars() expects parameter 2 to be long, string given in %s on line %d
        !           139: bool(false)
        !           140: -- Iteration 20 --
        !           141: 
        !           142: Warning: count_chars() expects parameter 2 to be long, string given in %s on line %d
        !           143: bool(false)
        !           144: -- Iteration 21 --
        !           145: 
        !           146: Notice: A non well formed numeric value encountered in %s on line %d
        !           147: bool(true)
        !           148: -- Iteration 22 --
        !           149: 
        !           150: Notice: A non well formed numeric value encountered in %s on line %d
        !           151: 
        !           152: Warning: count_chars(): Unknown mode in %s on line %d
        !           153: bool(false)
        !           154: -- Iteration 23 --
        !           155: 
        !           156: Warning: count_chars() expects parameter 2 to be long, object given in %s on line %d
        !           157: bool(false)
        !           158: -- Iteration 24 --
        !           159: bool(true)
        !           160: -- Iteration 25 --
        !           161: bool(true)
        !           162: ===DONE===

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