Annotation of embedaddon/php/ext/iconv/tests/iconv_strpos_variation3_64bit.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test iconv_strpos() function : usage variations - pass different data types as $offset arg
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('iconv') or die('skip');
! 6: function_exists('iconv_strpos') or die("skip iconv_strpos() is not available in this build");
! 7: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: /* Prototype : int iconv_strpos(string haystack, string needle [, int offset [, string charset]])
! 12: * Description: Find position of first occurrence of a string within another
! 13: * Source code: ext/iconv/iconv.c
! 14: */
! 15:
! 16: /*
! 17: * Pass iconv_strpos different data types as $offset arg to test behaviour
! 18: */
! 19:
! 20: echo "*** Testing iconv_strpos() : usage variations ***\n";
! 21:
! 22: // Initialise function arguments not being substituted
! 23: $needle = b'a';
! 24: $haystack = b'string_val';
! 25: $encoding = 'utf-8';
! 26:
! 27: //get an unset variable
! 28: $unset_var = 10;
! 29: unset ($unset_var);
! 30:
! 31: // get a class
! 32: class classA
! 33: {
! 34: public function __toString() {
! 35: return "Class A object";
! 36: }
! 37: }
! 38:
! 39: // heredoc string
! 40: $heredoc = <<<EOT
! 41: hello world
! 42: EOT;
! 43:
! 44: // get a resource variable
! 45: $fp = fopen(__FILE__, "r");
! 46:
! 47: // unexpected values to be passed to $offest argument
! 48: $inputs = array(
! 49:
! 50: // int data
! 51: /*1*/ 0,
! 52: 1,
! 53: 12345,
! 54: -2345,
! 55:
! 56: // float data
! 57: /*5*/ 10.5,
! 58: -10.5,
! 59: 12.3456789000e10,
! 60: 12.3456789000E-10,
! 61: .5,
! 62:
! 63: // null data
! 64: /*10*/ NULL,
! 65: null,
! 66:
! 67: // boolean data
! 68: /*12*/ true,
! 69: false,
! 70: TRUE,
! 71: FALSE,
! 72:
! 73: // empty data
! 74: /*16*/ "",
! 75: '',
! 76:
! 77: // string data
! 78: /*18*/ "string",
! 79: 'string',
! 80: $heredoc,
! 81:
! 82: // object data
! 83: /*21*/ new classA(),
! 84:
! 85: // undefined data
! 86: /*22*/ @$undefined_var,
! 87:
! 88: // unset data
! 89: /*23*/ @$unset_var,
! 90:
! 91: // resource variable
! 92: /*24*/ $fp
! 93: );
! 94:
! 95: // loop through each element of $inputs to check the behavior of iconv_strpos()
! 96: $iterator = 1;
! 97: foreach($inputs as $input) {
! 98: echo "\n-- Iteration $iterator --\n";
! 99: var_dump( iconv_strpos($haystack, $needle, $input, $encoding));
! 100: $iterator++;
! 101: };
! 102:
! 103: fclose($fp);
! 104:
! 105: echo "Done";
! 106: ?>
! 107: --EXPECTF--
! 108: *** Testing iconv_strpos() : usage variations ***
! 109:
! 110: -- Iteration 1 --
! 111: int(8)
! 112:
! 113: -- Iteration 2 --
! 114: int(8)
! 115:
! 116: -- Iteration 3 --
! 117: bool(false)
! 118:
! 119: -- Iteration 4 --
! 120:
! 121: Warning: iconv_strpos(): Offset not contained in string. in %s on line %d
! 122: bool(false)
! 123:
! 124: -- Iteration 5 --
! 125: bool(false)
! 126:
! 127: -- Iteration 6 --
! 128:
! 129: Warning: iconv_strpos(): Offset not contained in string. in %s on line %d
! 130: bool(false)
! 131:
! 132: -- Iteration 7 --
! 133: int(8)
! 134:
! 135: -- Iteration 8 --
! 136: int(8)
! 137:
! 138: -- Iteration 9 --
! 139: int(8)
! 140:
! 141: -- Iteration 10 --
! 142: int(8)
! 143:
! 144: -- Iteration 11 --
! 145: int(8)
! 146:
! 147: -- Iteration 12 --
! 148: int(8)
! 149:
! 150: -- Iteration 13 --
! 151: int(8)
! 152:
! 153: -- Iteration 14 --
! 154: int(8)
! 155:
! 156: -- Iteration 15 --
! 157: int(8)
! 158:
! 159: -- Iteration 16 --
! 160:
! 161: Warning: iconv_strpos() expects parameter 3 to be long, string given in %s on line %d
! 162: bool(false)
! 163:
! 164: -- Iteration 17 --
! 165:
! 166: Warning: iconv_strpos() expects parameter 3 to be long, string given in %s on line %d
! 167: bool(false)
! 168:
! 169: -- Iteration 18 --
! 170:
! 171: Warning: iconv_strpos() expects parameter 3 to be long, string given in %s on line %d
! 172: bool(false)
! 173:
! 174: -- Iteration 19 --
! 175:
! 176: Warning: iconv_strpos() expects parameter 3 to be long, string given in %s on line %d
! 177: bool(false)
! 178:
! 179: -- Iteration 20 --
! 180:
! 181: Warning: iconv_strpos() expects parameter 3 to be long, string given in %s on line %d
! 182: bool(false)
! 183:
! 184: -- Iteration 21 --
! 185:
! 186: Warning: iconv_strpos() expects parameter 3 to be long, object given in %s on line %d
! 187: bool(false)
! 188:
! 189: -- Iteration 22 --
! 190: int(8)
! 191:
! 192: -- Iteration 23 --
! 193: int(8)
! 194:
! 195: -- Iteration 24 --
! 196:
! 197: Warning: iconv_strpos() expects parameter 3 to be long, resource given in %s on line %d
! 198: bool(false)
! 199: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>