Annotation of embedaddon/php/ext/mbstring/tests/mb_strtoupper_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test mb_strtoupper() function : usage varitations - pass different data types as $sourcestring arg
        !             3: --SKIPIF--
        !             4: <?php
        !             5: extension_loaded('mbstring') or die('skip');
        !             6: function_exists('mb_strtoupper') or die("skip mb_strtoupper() is not available in this build");
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /* Prototype  : string mb_strtoupper(string $sourcestring [, string $encoding]
        !            11:  * Description: Returns a uppercased version of $sourcestring
        !            12:  * Source code: ext/mbstring/mbstring.c
        !            13:  */
        !            14: 
        !            15: /*
        !            16:  * 
        !            17:  * Pass different data types as $sourcestring argument to mb_strtoupper to test behaviour
        !            18:  */
        !            19: 
        !            20: echo "*** Testing mb_strtoupper() : usage variations ***\n";
        !            21: 
        !            22: // Initialise function arguments not being substituted
        !            23: 
        !            24: //get an unset variable
        !            25: $unset_var = 10;
        !            26: unset ($unset_var);
        !            27: 
        !            28: // get a class
        !            29: class classA
        !            30: {
        !            31:   public function __toString() {
        !            32:     return "Class A object";
        !            33:   }
        !            34: }
        !            35: 
        !            36: // heredoc string
        !            37: $heredoc = <<<EOT
        !            38: Hello, World
        !            39: EOT;
        !            40: 
        !            41: // get a resource variable
        !            42: $fp = fopen(__FILE__, "r");
        !            43: 
        !            44: // unexpected values to be passed to $sourcestring argument
        !            45: $inputs = array(
        !            46: 
        !            47:        // int data
        !            48: /*1*/  0,
        !            49:        1,
        !            50:        12345,
        !            51:        -2345,
        !            52: 
        !            53:        // float data
        !            54: /*5*/  10.5,
        !            55:        -10.5,
        !            56:        12.3456789000e10,
        !            57:        12.3456789000E-10,
        !            58:        .5,
        !            59: 
        !            60:        // null data
        !            61: /*10*/ NULL,
        !            62:        null,
        !            63: 
        !            64:        // boolean data
        !            65: /*12*/ true,
        !            66:        false,
        !            67:        TRUE,
        !            68:        FALSE,
        !            69:        
        !            70:        // empty data
        !            71: /*16*/ "",
        !            72:        '',
        !            73: 
        !            74:        // string data
        !            75: /*18*/ "String",
        !            76:        'String',
        !            77:        $heredoc,
        !            78:        
        !            79:        // object data
        !            80: /*21*/ new classA(),
        !            81: 
        !            82:        // undefined data
        !            83: /*22*/ @$undefined_var,
        !            84: 
        !            85:        // unset data
        !            86: /*23*/ @$unset_var,
        !            87: 
        !            88:        // resource variable
        !            89: /*24*/ $fp
        !            90: );
        !            91: 
        !            92: // loop through each element of $inputs to check the behavior of mb_strtoupper()
        !            93: $iterator = 1;
        !            94: foreach($inputs as $input) {
        !            95:   echo "\n-- Iteration $iterator --\n";
        !            96:   var_dump( mb_strtoupper($input) );
        !            97:   $iterator++;
        !            98: };
        !            99: 
        !           100: fclose($fp);
        !           101: 
        !           102: echo "Done";
        !           103: ?>
        !           104: 
        !           105: --EXPECTF--
        !           106: *** Testing mb_strtoupper() : usage variations ***
        !           107: 
        !           108: -- Iteration 1 --
        !           109: string(1) "0"
        !           110: 
        !           111: -- Iteration 2 --
        !           112: string(1) "1"
        !           113: 
        !           114: -- Iteration 3 --
        !           115: string(5) "12345"
        !           116: 
        !           117: -- Iteration 4 --
        !           118: string(5) "-2345"
        !           119: 
        !           120: -- Iteration 5 --
        !           121: string(4) "10.5"
        !           122: 
        !           123: -- Iteration 6 --
        !           124: string(5) "-10.5"
        !           125: 
        !           126: -- Iteration 7 --
        !           127: string(12) "123456789000"
        !           128: 
        !           129: -- Iteration 8 --
        !           130: string(13) "1.23456789E-9"
        !           131: 
        !           132: -- Iteration 9 --
        !           133: string(3) "0.5"
        !           134: 
        !           135: -- Iteration 10 --
        !           136: string(0) ""
        !           137: 
        !           138: -- Iteration 11 --
        !           139: string(0) ""
        !           140: 
        !           141: -- Iteration 12 --
        !           142: string(1) "1"
        !           143: 
        !           144: -- Iteration 13 --
        !           145: string(0) ""
        !           146: 
        !           147: -- Iteration 14 --
        !           148: string(1) "1"
        !           149: 
        !           150: -- Iteration 15 --
        !           151: string(0) ""
        !           152: 
        !           153: -- Iteration 16 --
        !           154: string(0) ""
        !           155: 
        !           156: -- Iteration 17 --
        !           157: string(0) ""
        !           158: 
        !           159: -- Iteration 18 --
        !           160: string(6) "STRING"
        !           161: 
        !           162: -- Iteration 19 --
        !           163: string(6) "STRING"
        !           164: 
        !           165: -- Iteration 20 --
        !           166: string(12) "HELLO, WORLD"
        !           167: 
        !           168: -- Iteration 21 --
        !           169: string(14) "CLASS A OBJECT"
        !           170: 
        !           171: -- Iteration 22 --
        !           172: string(0) ""
        !           173: 
        !           174: -- Iteration 23 --
        !           175: string(0) ""
        !           176: 
        !           177: -- Iteration 24 --
        !           178: 
        !           179: Warning: mb_strtoupper() expects parameter 1 to be string, resource given in %s on line %d
        !           180: NULL
        !           181: Done

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