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

1.1       misho       1: --TEST--
                      2: Test quoted_printable_decode() function : usage variations - unexpected values for 'str' argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string quoted_printable_decode  ( string $str  )
                      6:  * Description: Convert a quoted-printable string to an 8 bit string
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11: * Testing quoted_printable_decode() : with different unexpected values for format argument other than the strings
                     12: */
                     13: 
                     14: echo "*** Testing quoted_printable_decode() : with unexpected values for 'str' argument ***\n";
                     15: 
                     16: // initialing required variables
                     17: $arg1 = "second arg";
                     18: $arg2 = "third arg";
                     19: 
                     20: //get an unset variable
                     21: $unset_var = 10;
                     22: unset ($unset_var);
                     23: 
                     24: // declaring class
                     25: class sample
                     26: {
                     27:   public function __toString() {
                     28:     return "Object";
                     29:   }
                     30: }
                     31: 
                     32: // creating a file resource
                     33: $file_handle = fopen(__FILE__, 'r');
                     34: 
                     35: //array of values to iterate over
                     36: $values = array(
                     37: 
                     38:                  // int data
                     39: /*1*/        0,
                     40:                      1,
                     41:                      12345,
                     42:                      -2345,
                     43:                
                     44:                      // float data
                     45: /*5*/        10.5,
                     46:                      -10.5,
                     47:                      10.1234567e10,
                     48:                      10.7654321E-10,
                     49:                      .5,
                     50:                
                     51:                      // array data
                     52: /*10*/       array(),
                     53:                      array(0),
                     54:                      array(1),
                     55:                      array(1, 2),
                     56:                      array('color' => 'red', 'item' => 'pen'),
                     57:                
                     58:                      // null data
                     59: /*15*/       NULL,
                     60:                      null,
                     61:                
                     62:                      // boolean data
                     63: /*17*/       true,
                     64:                      false,
                     65:                      TRUE,
                     66:                      FALSE,
                     67:                
                     68:                      // empty data
                     69: /*21*/       "",
                     70:                      '',
                     71:                
                     72:                      // object data
                     73: /*23*/       new sample(),
                     74:                
                     75:                      // undefined data
                     76: /*24*/       @$undefined_var,
                     77:                
                     78:                      // unset data
                     79: /*25*/       @$unset_var,
                     80:                
                     81:                      // resource data
                     82: /*26*/       $file_handle
                     83: );
                     84: 
                     85: // loop through each element of the array for 'str'
                     86: 
                     87: $count = 1;
                     88: foreach($values as $value) {
                     89:   echo "\n-- Iteration $count --\n";
                     90:   var_dump(bin2hex(quoted_printable_decode($value)));
                     91:   $count++;
                     92: };
                     93: 
                     94: // close the resource
                     95: fclose($file_handle);
                     96: 
                     97: ?>
                     98: ===DONE===
                     99: --EXPECTF--
                    100: *** Testing quoted_printable_decode() : with unexpected values for 'str' argument ***
                    101: 
                    102: -- Iteration 1 --
                    103: string(2) "30"
                    104: 
                    105: -- Iteration 2 --
                    106: string(2) "31"
                    107: 
                    108: -- Iteration 3 --
                    109: string(10) "3132333435"
                    110: 
                    111: -- Iteration 4 --
                    112: string(10) "2d32333435"
                    113: 
                    114: -- Iteration 5 --
                    115: string(8) "31302e35"
                    116: 
                    117: -- Iteration 6 --
                    118: string(10) "2d31302e35"
                    119: 
                    120: -- Iteration 7 --
                    121: string(24) "313031323334353637303030"
                    122: 
                    123: -- Iteration 8 --
                    124: string(26) "312e3037363534333231452d39"
                    125: 
                    126: -- Iteration 9 --
                    127: string(6) "302e35"
                    128: 
                    129: -- Iteration 10 --
                    130: 
                    131: Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
                    132: string(0) ""
                    133: 
                    134: -- Iteration 11 --
                    135: 
                    136: Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
                    137: string(0) ""
                    138: 
                    139: -- Iteration 12 --
                    140: 
                    141: Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
                    142: string(0) ""
                    143: 
                    144: -- Iteration 13 --
                    145: 
                    146: Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
                    147: string(0) ""
                    148: 
                    149: -- Iteration 14 --
                    150: 
                    151: Warning: quoted_printable_decode() expects parameter 1 to be string, array given in %s on line %d
                    152: string(0) ""
                    153: 
                    154: -- Iteration 15 --
                    155: string(0) ""
                    156: 
                    157: -- Iteration 16 --
                    158: string(0) ""
                    159: 
                    160: -- Iteration 17 --
                    161: string(2) "31"
                    162: 
                    163: -- Iteration 18 --
                    164: string(0) ""
                    165: 
                    166: -- Iteration 19 --
                    167: string(2) "31"
                    168: 
                    169: -- Iteration 20 --
                    170: string(0) ""
                    171: 
                    172: -- Iteration 21 --
                    173: string(0) ""
                    174: 
                    175: -- Iteration 22 --
                    176: string(0) ""
                    177: 
                    178: -- Iteration 23 --
                    179: string(12) "4f626a656374"
                    180: 
                    181: -- Iteration 24 --
                    182: string(0) ""
                    183: 
                    184: -- Iteration 25 --
                    185: string(0) ""
                    186: 
                    187: -- Iteration 26 --
                    188: 
                    189: Warning: quoted_printable_decode() expects parameter 1 to be string, resource given in %s on line %d
                    190: string(0) ""
                    191: ===DONE===

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