Annotation of embedaddon/php/ext/standard/tests/strings/wordwrap_variation3.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test wordwrap() function : usage variations  - unexptected values for break argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )
                      6:  * Description: Wraps buffer to selected number of characters using string break char
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11:  * test wordwrap by passing different values for break argument 
                     12: */
                     13: echo "*** Testing wordwrap() : usage variations ***\n";
                     14: // initialize all required variables
                     15: $str = 'testing wordwrap function';
                     16: $width = 10;
                     17: $cut = true;
                     18: 
                     19: // resource var
                     20: $fp = fopen(__FILE__, "r");
                     21: 
                     22: // get an unset variable
                     23: $unset_var = 'string_val';
                     24: unset($unset_var);
                     25: 
                     26: 
                     27: // array with different values for break arg
                     28: $values =  array (
                     29: 
                     30:   // integer values
                     31:   0,
                     32:   1,
                     33:   12345,
                     34:   -2345,
                     35: 
                     36:   // float values
                     37:   10.5,
                     38:   -10.5,
                     39:   10.1234567e10,
                     40:   10.7654321E-10,
                     41:   .5,
                     42: 
                     43:   // array values
                     44:   array(),
                     45:   array(0),
                     46:   array(1),
                     47:   array(1, 2),
                     48:   array('color' => 'red', 'item' => 'pen'),
                     49: 
                     50:   // boolean values
                     51:   true,
                     52:   false,
                     53:   TRUE,
                     54:   FALSE,
                     55: 
                     56:   // objects
                     57:   new stdclass(),
                     58: 
                     59:   // empty string
                     60:   "",
                     61:   '',
                     62: 
                     63:   //Null
                     64:   NULL,
                     65:   null,
                     66: 
                     67:   // resource var
                     68:   $fp,
                     69: 
                     70:   // undefined variable
                     71:   @$undefined_var,
                     72: 
                     73:   // unset variable
                     74:   @$unset_var
                     75: );
                     76: 
                     77: // loop though each element of the array and check the working of wordwrap()
                     78: // when $break arugment is supplied with different values
                     79: echo "\n--- Testing wordwrap() by supplying different values for 'break' argument ---\n";
                     80: $counter = 1;
                     81: for($index = 0; $index < count($values); $index ++) {
                     82:   echo "-- Iteration $counter --\n";
                     83:   $break = $values [$index];
                     84: 
                     85:   var_dump( wordwrap($str, $width, $break) );
                     86: 
                     87:   // $cut as false
                     88:   $cut = false;
                     89:   var_dump( wordwrap($str, $width, $break, $cut) );
                     90: 
                     91:   // $cut as true 
                     92:   $cut = true;
                     93:   var_dump( wordwrap($str, $width, $break, $cut) );
                     94: 
                     95:   $counter ++;
                     96: }
                     97: 
                     98: // close the resource used
                     99: fclose($fp);
                    100: 
                    101: echo "Done\n";
                    102: ?>
                    103: --EXPECTF--
                    104: *** Testing wordwrap() : usage variations ***
                    105: 
                    106: --- Testing wordwrap() by supplying different values for 'break' argument ---
                    107: -- Iteration 1 --
                    108: string(25) "testing0wordwrap0function"
                    109: string(25) "testing0wordwrap0function"
                    110: string(25) "testing0wordwrap0function"
                    111: -- Iteration 2 --
                    112: string(25) "testing1wordwrap1function"
                    113: string(25) "testing1wordwrap1function"
                    114: string(25) "testing1wordwrap1function"
                    115: -- Iteration 3 --
                    116: string(33) "testing12345wordwrap12345function"
                    117: string(33) "testing12345wordwrap12345function"
                    118: string(33) "testing12345wordwrap12345function"
                    119: -- Iteration 4 --
                    120: string(33) "testing-2345wordwrap-2345function"
                    121: string(33) "testing-2345wordwrap-2345function"
                    122: string(33) "testing-2345wordwrap-2345function"
                    123: -- Iteration 5 --
                    124: string(31) "testing10.5wordwrap10.5function"
                    125: string(31) "testing10.5wordwrap10.5function"
                    126: string(31) "testing10.5wordwrap10.5function"
                    127: -- Iteration 6 --
                    128: string(33) "testing-10.5wordwrap-10.5function"
                    129: string(33) "testing-10.5wordwrap-10.5function"
                    130: string(33) "testing-10.5wordwrap-10.5function"
                    131: -- Iteration 7 --
                    132: string(47) "testing101234567000wordwrap101234567000function"
                    133: string(47) "testing101234567000wordwrap101234567000function"
                    134: string(47) "testing101234567000wordwrap101234567000function"
                    135: -- Iteration 8 --
                    136: string(49) "testing1.07654321E-9wordwrap1.07654321E-9function"
                    137: string(49) "testing1.07654321E-9wordwrap1.07654321E-9function"
                    138: string(49) "testing1.07654321E-9wordwrap1.07654321E-9function"
                    139: -- Iteration 9 --
                    140: string(29) "testing0.5wordwrap0.5function"
                    141: string(29) "testing0.5wordwrap0.5function"
                    142: string(29) "testing0.5wordwrap0.5function"
                    143: -- Iteration 10 --
                    144: 
                    145: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    146: NULL
                    147: 
                    148: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    149: NULL
                    150: 
                    151: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    152: NULL
                    153: -- Iteration 11 --
                    154: 
                    155: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    156: NULL
                    157: 
                    158: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    159: NULL
                    160: 
                    161: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    162: NULL
                    163: -- Iteration 12 --
                    164: 
                    165: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    166: NULL
                    167: 
                    168: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    169: NULL
                    170: 
                    171: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    172: NULL
                    173: -- Iteration 13 --
                    174: 
                    175: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    176: NULL
                    177: 
                    178: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    179: NULL
                    180: 
                    181: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    182: NULL
                    183: -- Iteration 14 --
                    184: 
                    185: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    186: NULL
                    187: 
                    188: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    189: NULL
                    190: 
                    191: Warning: wordwrap() expects parameter 3 to be string, array given in %s on line %d
                    192: NULL
                    193: -- Iteration 15 --
                    194: string(25) "testing1wordwrap1function"
                    195: string(25) "testing1wordwrap1function"
                    196: string(25) "testing1wordwrap1function"
                    197: -- Iteration 16 --
                    198: 
                    199: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    200: bool(false)
                    201: 
                    202: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    203: bool(false)
                    204: 
                    205: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    206: bool(false)
                    207: -- Iteration 17 --
                    208: string(25) "testing1wordwrap1function"
                    209: string(25) "testing1wordwrap1function"
                    210: string(25) "testing1wordwrap1function"
                    211: -- Iteration 18 --
                    212: 
                    213: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    214: bool(false)
                    215: 
                    216: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    217: bool(false)
                    218: 
                    219: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    220: bool(false)
                    221: -- Iteration 19 --
                    222: 
                    223: Warning: wordwrap() expects parameter 3 to be string, object given in %s on line %d
                    224: NULL
                    225: 
                    226: Warning: wordwrap() expects parameter 3 to be string, object given in %s on line %d
                    227: NULL
                    228: 
                    229: Warning: wordwrap() expects parameter 3 to be string, object given in %s on line %d
                    230: NULL
                    231: -- Iteration 20 --
                    232: 
                    233: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    234: bool(false)
                    235: 
                    236: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    237: bool(false)
                    238: 
                    239: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    240: bool(false)
                    241: -- Iteration 21 --
                    242: 
                    243: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    244: bool(false)
                    245: 
                    246: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    247: bool(false)
                    248: 
                    249: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    250: bool(false)
                    251: -- Iteration 22 --
                    252: 
                    253: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    254: bool(false)
                    255: 
                    256: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    257: bool(false)
                    258: 
                    259: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    260: bool(false)
                    261: -- Iteration 23 --
                    262: 
                    263: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    264: bool(false)
                    265: 
                    266: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    267: bool(false)
                    268: 
                    269: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    270: bool(false)
                    271: -- Iteration 24 --
                    272: 
                    273: Warning: wordwrap() expects parameter 3 to be string, resource given in %s on line %d
                    274: NULL
                    275: 
                    276: Warning: wordwrap() expects parameter 3 to be string, resource given in %s on line %d
                    277: NULL
                    278: 
                    279: Warning: wordwrap() expects parameter 3 to be string, resource given in %s on line %d
                    280: NULL
                    281: -- Iteration 25 --
                    282: 
                    283: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    284: bool(false)
                    285: 
                    286: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    287: bool(false)
                    288: 
                    289: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    290: bool(false)
                    291: -- Iteration 26 --
                    292: 
                    293: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    294: bool(false)
                    295: 
                    296: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    297: bool(false)
                    298: 
                    299: Warning: wordwrap(): Break string cannot be empty in %s on line %d
                    300: bool(false)
                    301: Done

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