Annotation of embedaddon/php/ext/standard/tests/strings/sha1_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test sha1() function : usage variations - unexpected values for 'str' argument
! 3: --FILE--
! 4: <?php
! 5:
! 6: /* Prototype: string sha1 ( string $str [, bool $raw_output ] )
! 7: * Description: Calculate the sha1 hash of a string
! 8: */
! 9:
! 10: echo "*** Testing sha1() : unexpected values for 'str' ***\n";
! 11:
! 12: $raw = false;
! 13:
! 14: //get an unset variable
! 15: $unset_var = 10;
! 16: unset ($unset_var);
! 17:
! 18: //defining class for object variable
! 19: class MyClass
! 20: {
! 21: public function __toString()
! 22: {
! 23: return "object";
! 24: }
! 25: }
! 26:
! 27: //resource variable
! 28: $fp = fopen(__FILE__, 'r');
! 29:
! 30: //different values for 'str' argument
! 31: $values = array(
! 32:
! 33: // int data
! 34: /*1*/ 0,
! 35: 1,
! 36: 12345,
! 37: -2345,
! 38:
! 39: // float data
! 40: /*5*/ 10.5,
! 41: -10.5,
! 42: 10.1234567e10,
! 43: 10.1234567E-10,
! 44: .5,
! 45:
! 46: // array data
! 47: /*10*/ array(),
! 48: array(0),
! 49: array(1),
! 50: array(1, 2),
! 51: array('color' => 'red', 'item' => 'pen'),
! 52:
! 53: // null data
! 54: /*15*/ NULL,
! 55: null,
! 56:
! 57: // boolean data
! 58: /*17*/ true,
! 59: false,
! 60: TRUE,
! 61: FALSE,
! 62:
! 63: // empty data
! 64: /*21*/ "",
! 65: '',
! 66:
! 67: // object data
! 68: /*23*/ new MyClass(),
! 69:
! 70: // undefined data
! 71: /*24*/ @$undefined_var,
! 72:
! 73: // unset data
! 74: /*25*/ @$unset_var,
! 75:
! 76: //resource data
! 77: /*26*/ $fp
! 78: );
! 79:
! 80: // loop through each element of $values for 'str' argument
! 81: for($count = 0; $count < count($values); $count++) {
! 82: echo "-- Iteration ".($count+1)." --\n";
! 83: var_dump( sha1($values[$count], $raw) );
! 84: }
! 85:
! 86: //closing resource
! 87: fclose($fp);
! 88:
! 89: ?>
! 90: ===DONE===
! 91: --EXPECTF--
! 92: *** Testing sha1() : unexpected values for 'str' ***
! 93: -- Iteration 1 --
! 94: string(40) "b6589fc6ab0dc82cf12099d1c2d40ab994e8410c"
! 95: -- Iteration 2 --
! 96: string(40) "356a192b7913b04c54574d18c28d46e6395428ab"
! 97: -- Iteration 3 --
! 98: string(40) "8cb2237d0679ca88db6464eac60da96345513964"
! 99: -- Iteration 4 --
! 100: string(40) "bc97c643aba3b6c6abe253222f439d4002a87528"
! 101: -- Iteration 5 --
! 102: string(40) "1287384bc5ef3ab84a36a5ef1d888df2763567f4"
! 103: -- Iteration 6 --
! 104: string(40) "c9d6e1b691f17c8ae6d458984a5f56f80e62a60b"
! 105: -- Iteration 7 --
! 106: string(40) "39493e1e645578a655f532e1f9bcff67991f2c2f"
! 107: -- Iteration 8 --
! 108: string(40) "681b45cae882ad795afd54ccc2a04ad58e056b83"
! 109: -- Iteration 9 --
! 110: string(40) "1b390cd54a0c0d4f27fa7adf23e3c45536e9f37c"
! 111: -- Iteration 10 --
! 112:
! 113: Warning: sha1() expects parameter 1 to be string, array given in %s on line %d
! 114: NULL
! 115: -- Iteration 11 --
! 116:
! 117: Warning: sha1() expects parameter 1 to be string, array given in %s on line %d
! 118: NULL
! 119: -- Iteration 12 --
! 120:
! 121: Warning: sha1() expects parameter 1 to be string, array given in %s on line %d
! 122: NULL
! 123: -- Iteration 13 --
! 124:
! 125: Warning: sha1() expects parameter 1 to be string, array given in %s on line %d
! 126: NULL
! 127: -- Iteration 14 --
! 128:
! 129: Warning: sha1() expects parameter 1 to be string, array given in %s on line %d
! 130: NULL
! 131: -- Iteration 15 --
! 132: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 133: -- Iteration 16 --
! 134: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 135: -- Iteration 17 --
! 136: string(40) "356a192b7913b04c54574d18c28d46e6395428ab"
! 137: -- Iteration 18 --
! 138: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 139: -- Iteration 19 --
! 140: string(40) "356a192b7913b04c54574d18c28d46e6395428ab"
! 141: -- Iteration 20 --
! 142: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 143: -- Iteration 21 --
! 144: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 145: -- Iteration 22 --
! 146: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 147: -- Iteration 23 --
! 148: string(40) "1615307cc4523f183e777df67f168c86908e8007"
! 149: -- Iteration 24 --
! 150: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 151: -- Iteration 25 --
! 152: string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
! 153: -- Iteration 26 --
! 154:
! 155: Warning: sha1() expects parameter 1 to be string, resource given in %s on line %d
! 156: NULL
! 157: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>