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

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

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