Annotation of embedaddon/php/ext/standard/tests/strings/strncasecmp_variation11.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test strncasecmp() function : usage variations - unexpected values for 'str2'
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : int strncasecmp ( string $str1, string $str2, int $len );
! 6: * Description: Binary safe case-insensitive string comparison of the first n characters
! 7: * Source code: Zend/zend_builtin_functions.c
! 8: */
! 9:
! 10: /* Test strncasecmp() function with the unexpected inputs for 'str2' */
! 11:
! 12: echo "*** Testing strncasecmp() function: with unexpected values for 'str2' ***\n";
! 13: /* get an unset variable */
! 14: $unset_var = 'string_val';
! 15: unset($unset_var);
! 16:
! 17: /* get resource handle */
! 18: $file_handle = fopen(__FILE__, "r");
! 19:
! 20: /* declaring a class */
! 21: class sample {
! 22: public function __toString() {
! 23: return "object";
! 24: }
! 25: }
! 26:
! 27:
! 28: /* array with different values */
! 29: $values = array (
! 30: /* integer values */
! 31: 0,
! 32: 1,
! 33: 12345,
! 34: -2345,
! 35:
! 36: /* float values */
! 37: 10.5,
! 38: -10.5,
! 39: 10.5e10,
! 40: 10.6E-10,
! 41: .5,
! 42:
! 43: /* hexadecimal values */
! 44: 0x12,
! 45: -0x12,
! 46:
! 47: /* octal values */
! 48: 012,
! 49: -012,
! 50: 01.2,
! 51:
! 52: /* array values */
! 53: array(),
! 54: array(0),
! 55: array(1),
! 56: array(1, 2),
! 57: array('color' => 'red', 'item' => 'pen'),
! 58:
! 59: /* boolean values */
! 60: true,
! 61: false,
! 62: TRUE,
! 63: FALSE,
! 64:
! 65: /* nulls */
! 66: NULL,
! 67: null,
! 68:
! 69: /* empty string */
! 70: "",
! 71: '',
! 72:
! 73: /* undefined variable */
! 74: @$undefined_var,
! 75:
! 76: /* unset variable */
! 77: @$unset_var,
! 78:
! 79: /* resource */
! 80: $file_handle,
! 81:
! 82: /* object */
! 83: new sample()
! 84: );
! 85:
! 86: /* loop through each element of the array and check the working of strncasecmp() */
! 87: $counter = 1;
! 88: for($index = 0; $index < count($values); $index ++) {
! 89: echo "-- Iteration $counter --\n";
! 90: $str1 = $values[$index];
! 91: $str2 = $values[$index];
! 92: $len = strlen($values[$index]) + 1;
! 93: var_dump( strncasecmp("string", $str2, $len) );
! 94: $counter ++;
! 95: }
! 96:
! 97: fclose($file_handle); //closing the file handle
! 98:
! 99: echo "*** Done ***\n";
! 100: ?>
! 101: --EXPECTF--
! 102: *** Testing strncasecmp() function: with unexpected values for 'str2' ***
! 103: -- Iteration 1 --
! 104: int(%d)
! 105: -- Iteration 2 --
! 106: int(%d)
! 107: -- Iteration 3 --
! 108: int(%d)
! 109: -- Iteration 4 --
! 110: int(%d)
! 111: -- Iteration 5 --
! 112: int(%d)
! 113: -- Iteration 6 --
! 114: int(%d)
! 115: -- Iteration 7 --
! 116: int(%d)
! 117: -- Iteration 8 --
! 118: int(%d)
! 119: -- Iteration 9 --
! 120: int(%d)
! 121: -- Iteration 10 --
! 122: int(%d)
! 123: -- Iteration 11 --
! 124: int(%d)
! 125: -- Iteration 12 --
! 126: int(%d)
! 127: -- Iteration 13 --
! 128: int(%d)
! 129: -- Iteration 14 --
! 130: int(%d)
! 131: -- Iteration 15 --
! 132:
! 133: Warning: strlen() expects parameter 1 to be string, array given in %s on line %d
! 134:
! 135: Warning: strncasecmp() expects parameter 2 to be string, array given in %s on line %d
! 136: NULL
! 137: -- Iteration 16 --
! 138:
! 139: Warning: strlen() expects parameter 1 to be string, array given in %s on line %d
! 140:
! 141: Warning: strncasecmp() expects parameter 2 to be string, array given in %s on line %d
! 142: NULL
! 143: -- Iteration 17 --
! 144:
! 145: Warning: strlen() expects parameter 1 to be string, array given in %s on line %d
! 146:
! 147: Warning: strncasecmp() expects parameter 2 to be string, array given in %s on line %d
! 148: NULL
! 149: -- Iteration 18 --
! 150:
! 151: Warning: strlen() expects parameter 1 to be string, array given in %s on line %d
! 152:
! 153: Warning: strncasecmp() expects parameter 2 to be string, array given in %s on line %d
! 154: NULL
! 155: -- Iteration 19 --
! 156:
! 157: Warning: strlen() expects parameter 1 to be string, array given in %s on line %d
! 158:
! 159: Warning: strncasecmp() expects parameter 2 to be string, array given in %s on line %d
! 160: NULL
! 161: -- Iteration 20 --
! 162: int(%d)
! 163: -- Iteration 21 --
! 164: int(%d)
! 165: -- Iteration 22 --
! 166: int(%d)
! 167: -- Iteration 23 --
! 168: int(%d)
! 169: -- Iteration 24 --
! 170: int(%d)
! 171: -- Iteration 25 --
! 172: int(%d)
! 173: -- Iteration 26 --
! 174: int(%d)
! 175: -- Iteration 27 --
! 176: int(%d)
! 177: -- Iteration 28 --
! 178: int(%d)
! 179: -- Iteration 29 --
! 180: int(%d)
! 181: -- Iteration 30 --
! 182:
! 183: Warning: strlen() expects parameter 1 to be string, resource given in %s on line %d
! 184:
! 185: Warning: strncasecmp() expects parameter 2 to be string, resource given in %s on line %d
! 186: NULL
! 187: -- Iteration 31 --
! 188: int(4)
! 189: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>