Annotation of embedaddon/php/ext/standard/tests/strings/wordwrap_variation2.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test wordwrap() function : usage variations  - unexpected values for width 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 width argument 
                     12: */
                     13: echo "*** Testing wordwrap() : usage variations ***\n";
                     14: // initialize all required variables
                     15: $str = 'testing wordwrap function';
                     16: $break = '<br />\n';
                     17: $cut = true;
                     18: 
                     19: // resource var 
                     20: $fp = fopen(__FILE__, "r");
                     21: 
                     22: // get an unset variable
                     23: $unset_var = 10;
                     24: unset($unset_var);
                     25: 
                     26: 
                     27: // array with different values as width
                     28: $values =  array (
                     29:   // zerovalue for width
                     30:   0,
                     31: 
                     32:   // -ve value for width
                     33:   -1,
                     34:   -10,
                     35: 
                     36:   // array values
                     37:   array(),
                     38:   array(0),
                     39:   array(1),
                     40:   array(1, 2),
                     41:   array('color' => 'red', 'item' => 'pen'),
                     42: 
                     43:   // boolean values
                     44:   true,
                     45:   false,
                     46:   TRUE,
                     47:   FALSE,
                     48: 
                     49:   // string values
                     50:   "string",
                     51:   'string',
                     52: 
                     53:   // objects
                     54:   new stdclass(),
                     55: 
                     56:   // Null value 
                     57:   NULL,
                     58:   null,
                     59: 
                     60:   // empty string
                     61:   "",
                     62:   '',
                     63: 
                     64:   // resource variable
                     65:   $fp,
                     66: 
                     67:   // undefined variable
                     68:   @$undefined_var,
                     69: 
                     70:   // unset variable
                     71:   @$unset_var
                     72: );
                     73: 
                     74: 
                     75: // loop though each element of the array and check the working of wordwrap()
1.1.1.2 ! misho      76: // when $width argument is supplied with different values
1.1       misho      77: echo "\n--- Testing wordwrap() by supplying different values for 'width' argument ---\n";
                     78: $counter = 1;
                     79: for($index = 0; $index < count($values); $index ++) {
                     80:   echo "-- Iteration $counter --\n";
                     81:   $width = $values [$index];
                     82: 
                     83:   var_dump( wordwrap($str, $width) );
                     84:   var_dump( wordwrap($str, $width, $break) );
                     85: 
                     86:   // cut as false 
                     87:   $cut = false;
                     88:   var_dump( wordwrap($str, $width, $break, $cut) );
                     89: 
                     90:   // cut as true
                     91:   $cut = true;
                     92:   var_dump( wordwrap($str, $width, $break, $cut) );
                     93: 
                     94:   $counter ++;
                     95: }
                     96: 
                     97: // close the resource
                     98: fclose($fp);
                     99: 
                    100: echo "Done\n";
                    101: ?>
                    102: --EXPECTF--
                    103: *** Testing wordwrap() : usage variations ***
                    104: 
                    105: --- Testing wordwrap() by supplying different values for 'width' argument ---
                    106: -- Iteration 1 --
                    107: string(25) "testing
                    108: wordwrap
                    109: function"
                    110: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    111: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    112: 
                    113: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    114: bool(false)
                    115: -- Iteration 2 --
                    116: string(25) "testing
                    117: wordwrap
                    118: function"
                    119: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    120: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    121: string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
                    122: -- Iteration 3 --
                    123: string(25) "testing
                    124: wordwrap
                    125: function"
                    126: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    127: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    128: string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
                    129: -- Iteration 4 --
                    130: 
                    131: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    132: NULL
                    133: 
                    134: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    135: NULL
                    136: 
                    137: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    138: NULL
                    139: 
                    140: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    141: NULL
                    142: -- Iteration 5 --
                    143: 
                    144: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    145: NULL
                    146: 
                    147: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    148: NULL
                    149: 
                    150: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    151: NULL
                    152: 
                    153: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    154: NULL
                    155: -- Iteration 6 --
                    156: 
                    157: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    158: NULL
                    159: 
                    160: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    161: NULL
                    162: 
                    163: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    164: NULL
                    165: 
                    166: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    167: NULL
                    168: -- Iteration 7 --
                    169: 
                    170: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    171: NULL
                    172: 
                    173: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    174: NULL
                    175: 
                    176: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    177: NULL
                    178: 
                    179: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    180: NULL
                    181: -- Iteration 8 --
                    182: 
                    183: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    184: NULL
                    185: 
                    186: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    187: NULL
                    188: 
                    189: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    190: NULL
                    191: 
                    192: Warning: wordwrap() expects parameter 2 to be long, array given in %s on line %d
                    193: NULL
                    194: -- Iteration 9 --
                    195: string(25) "testing
                    196: wordwrap
                    197: function"
                    198: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    199: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    200: string(199) "t<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
                    201: -- Iteration 10 --
                    202: string(25) "testing
                    203: wordwrap
                    204: function"
                    205: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    206: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    207: 
                    208: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    209: bool(false)
                    210: -- Iteration 11 --
                    211: string(25) "testing
                    212: wordwrap
                    213: function"
                    214: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    215: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    216: string(199) "t<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
                    217: -- Iteration 12 --
                    218: string(25) "testing
                    219: wordwrap
                    220: function"
                    221: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    222: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    223: 
                    224: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    225: bool(false)
                    226: -- Iteration 13 --
                    227: 
                    228: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    229: NULL
                    230: 
                    231: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    232: NULL
                    233: 
                    234: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    235: NULL
                    236: 
                    237: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    238: NULL
                    239: -- Iteration 14 --
                    240: 
                    241: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    242: NULL
                    243: 
                    244: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    245: NULL
                    246: 
                    247: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    248: NULL
                    249: 
                    250: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    251: NULL
                    252: -- Iteration 15 --
                    253: 
                    254: Warning: wordwrap() expects parameter 2 to be long, object given in %s on line %d
                    255: NULL
                    256: 
                    257: Warning: wordwrap() expects parameter 2 to be long, object given in %s on line %d
                    258: NULL
                    259: 
                    260: Warning: wordwrap() expects parameter 2 to be long, object given in %s on line %d
                    261: NULL
                    262: 
                    263: Warning: wordwrap() expects parameter 2 to be long, object given in %s on line %d
                    264: NULL
                    265: -- Iteration 16 --
                    266: string(25) "testing
                    267: wordwrap
                    268: function"
                    269: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    270: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    271: 
                    272: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    273: bool(false)
                    274: -- Iteration 17 --
                    275: string(25) "testing
                    276: wordwrap
                    277: function"
                    278: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    279: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    280: 
                    281: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    282: bool(false)
                    283: -- Iteration 18 --
                    284: 
                    285: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    286: NULL
                    287: 
                    288: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    289: NULL
                    290: 
                    291: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    292: NULL
                    293: 
                    294: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    295: NULL
                    296: -- Iteration 19 --
                    297: 
                    298: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    299: NULL
                    300: 
                    301: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    302: NULL
                    303: 
                    304: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    305: NULL
                    306: 
                    307: Warning: wordwrap() expects parameter 2 to be long, string given in %s on line %d
                    308: NULL
                    309: -- Iteration 20 --
                    310: 
                    311: Warning: wordwrap() expects parameter 2 to be long, resource given in %s on line %d
                    312: NULL
                    313: 
                    314: Warning: wordwrap() expects parameter 2 to be long, resource given in %s on line %d
                    315: NULL
                    316: 
                    317: Warning: wordwrap() expects parameter 2 to be long, resource given in %s on line %d
                    318: NULL
                    319: 
                    320: Warning: wordwrap() expects parameter 2 to be long, resource given in %s on line %d
                    321: NULL
                    322: -- Iteration 21 --
                    323: string(25) "testing
                    324: wordwrap
                    325: function"
                    326: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    327: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    328: 
                    329: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    330: bool(false)
                    331: -- Iteration 22 --
                    332: string(25) "testing
                    333: wordwrap
                    334: function"
                    335: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    336: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    337: 
                    338: Warning: wordwrap(): Can't force cut when width is zero in %s on line %d
                    339: bool(false)
                    340: Done

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