Annotation of embedaddon/php/ext/standard/tests/strings/pack.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Generic pack()/unpack() tests
! 3: --SKIPIF--
! 4: <?php
! 5: if (PHP_INT_MAX > 2147483647) {
! 6: die("skip 32bit test only");
! 7: }
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: print_r(unpack("A", pack("A", "hello world")));
! 12: print_r(unpack("A*", pack("A*", "hello world")));
! 13: echo '"'.pack("A9", "hello").'"';
! 14: echo "\n";
! 15:
! 16: print_r(unpack("C", pack("C", -127)));
! 17: print_r(unpack("C", pack("C", 127)));
! 18: print_r(unpack("C", pack("C", 255)));
! 19: print_r(unpack("C", pack("C", -129)));
! 20:
! 21: print_r(unpack("H", pack("H", 0x04)));
! 22:
! 23: print_r(unpack("I", pack("I", 65534)));
! 24: print_r(unpack("I", pack("I", 0)));
! 25: print_r(unpack("I", pack("I", -1000)));
! 26: print_r(unpack("I", pack("I", -64434)));
! 27: print_r(unpack("I", pack("I", 4294967296)));
! 28: print_r(unpack("I", pack("I", -4294967296)));
! 29:
! 30: print_r(unpack("L", pack("L", 65534)));
! 31: print_r(unpack("L", pack("L", 0)));
! 32: print_r(unpack("L", pack("L", 2147483650)));
! 33: print_r(unpack("L", pack("L", 4294967295)));
! 34: print_r(unpack("L", pack("L", -2147483648)));
! 35:
! 36: print_r(unpack("N", pack("N", 65534)));
! 37: print_r(unpack("N", pack("N", 0)));
! 38: print_r(unpack("N", pack("N", 2147483650)));
! 39: print_r(unpack("N", pack("N", 4294967296)));
! 40: print_r(unpack("N", pack("N", -2147483648)));
! 41: print_r(unpack("N", pack("N", -30000)));
! 42:
! 43: print_r(unpack("S", pack("S", 65534)));
! 44: print_r(unpack("S", pack("S", 65537)));
! 45: print_r(unpack("S", pack("S", 0)));
! 46: print_r(unpack("S", pack("S", -1000)));
! 47: print_r(unpack("S", pack("S", -64434)));
! 48: print_r(unpack("S", pack("S", -65535)));
! 49:
! 50: print_r(unpack("V", pack("V", 65534)));
! 51: print_r(unpack("V", pack("V", 0)));
! 52: print_r(unpack("V", pack("V", 2147483650)));
! 53: print_r(unpack("V", pack("V", 4294967296)));
! 54: print_r(unpack("V", pack("V", -2147483648)));
! 55:
! 56: print_r(unpack("a", pack("a", "hello world")));
! 57: print_r(unpack("a*", pack("a*", "hello world")));
! 58:
! 59: print_r(unpack("c", pack("c", -127)));
! 60: print_r(unpack("c", pack("c", 127)));
! 61: print_r(unpack("c", pack("c", 255)));
! 62: print_r(unpack("c", pack("c", -129)));
! 63:
! 64: print_r(unpack("h", pack("h", 3000000)));
! 65:
! 66: print_r(unpack("i", pack("i", 65534)));
! 67: print_r(unpack("i", pack("i", 0)));
! 68: print_r(unpack("i", pack("i", -1000)));
! 69: print_r(unpack("i", pack("i", -64434)));
! 70: print_r(unpack("i", pack("i", -65535)));
! 71: print_r(unpack("i", pack("i", -2147483647)));
! 72:
! 73: print_r(unpack("l", pack("l", 65534)));
! 74: print_r(unpack("l", pack("l", 0)));
! 75: print_r(unpack("l", pack("l", 2147483650)));
! 76: print_r(unpack("l", pack("l", 4294967296)));
! 77: print_r(unpack("l", pack("l", -2147483648)));
! 78:
! 79: print_r(unpack("n", pack("n", 65534)));
! 80: print_r(unpack("n", pack("n", 65537)));
! 81: print_r(unpack("n", pack("n", 0)));
! 82: print_r(unpack("n", pack("n", -1000)));
! 83: print_r(unpack("n", pack("n", -64434)));
! 84: print_r(unpack("n", pack("n", -65535)));
! 85:
! 86: print_r(unpack("s", pack("s", 32767)));
! 87: print_r(unpack("s", pack("s", 65535)));
! 88: print_r(unpack("s", pack("s", 0)));
! 89: print_r(unpack("s", pack("s", -1000)));
! 90: print_r(unpack("s", pack("s", -64434)));
! 91: print_r(unpack("s", pack("s", -65535)));
! 92:
! 93: print_r(unpack("v", pack("v", 65534)));
! 94: print_r(unpack("v", pack("v", 65537)));
! 95: print_r(unpack("v", pack("v", 0)));
! 96: print_r(unpack("v", pack("v", -1000)));
! 97: print_r(unpack("v", pack("v", -64434)));
! 98: print_r(unpack("v", pack("v", -65535)));
! 99: ?>
! 100: --EXPECTF--
! 101: Array
! 102: (
! 103: [1] => h
! 104: )
! 105: Array
! 106: (
! 107: [1] => hello world
! 108: )
! 109: "hello "
! 110: Array
! 111: (
! 112: [1] => 129
! 113: )
! 114: Array
! 115: (
! 116: [1] => 127
! 117: )
! 118: Array
! 119: (
! 120: [1] => 255
! 121: )
! 122: Array
! 123: (
! 124: [1] => 127
! 125: )
! 126: Array
! 127: (
! 128: [1] => 4
! 129: )
! 130: Array
! 131: (
! 132: [1] => 65534
! 133: )
! 134: Array
! 135: (
! 136: [1] => 0
! 137: )
! 138: Array
! 139: (
! 140: [1] => -1000
! 141: )
! 142: Array
! 143: (
! 144: [1] => -64434
! 145: )
! 146: Array
! 147: (
! 148: [1] => 0
! 149: )
! 150: Array
! 151: (
! 152: [1] => 0
! 153: )
! 154: Array
! 155: (
! 156: [1] => 65534
! 157: )
! 158: Array
! 159: (
! 160: [1] => 0
! 161: )
! 162: Array
! 163: (
! 164: [1] => -2147483646
! 165: )
! 166: Array
! 167: (
! 168: [1] => -1
! 169: )
! 170: Array
! 171: (
! 172: [1] => -2147483648
! 173: )
! 174: Array
! 175: (
! 176: [1] => 65534
! 177: )
! 178: Array
! 179: (
! 180: [1] => 0
! 181: )
! 182: Array
! 183: (
! 184: [1] => -2147483646
! 185: )
! 186: Array
! 187: (
! 188: [1] => 0
! 189: )
! 190: Array
! 191: (
! 192: [1] => -2147483648
! 193: )
! 194: Array
! 195: (
! 196: [1] => -30000
! 197: )
! 198: Array
! 199: (
! 200: [1] => 65534
! 201: )
! 202: Array
! 203: (
! 204: [1] => 1
! 205: )
! 206: Array
! 207: (
! 208: [1] => 0
! 209: )
! 210: Array
! 211: (
! 212: [1] => 64536
! 213: )
! 214: Array
! 215: (
! 216: [1] => 1102
! 217: )
! 218: Array
! 219: (
! 220: [1] => 1
! 221: )
! 222: Array
! 223: (
! 224: [1] => 65534
! 225: )
! 226: Array
! 227: (
! 228: [1] => 0
! 229: )
! 230: Array
! 231: (
! 232: [1] => -2147483646
! 233: )
! 234: Array
! 235: (
! 236: [1] => 0
! 237: )
! 238: Array
! 239: (
! 240: [1] => -2147483648
! 241: )
! 242: Array
! 243: (
! 244: [1] => h
! 245: )
! 246: Array
! 247: (
! 248: [1] => hello world
! 249: )
! 250: Array
! 251: (
! 252: [1] => -127
! 253: )
! 254: Array
! 255: (
! 256: [1] => 127
! 257: )
! 258: Array
! 259: (
! 260: [1] => -1
! 261: )
! 262: Array
! 263: (
! 264: [1] => 127
! 265: )
! 266: Array
! 267: (
! 268: [1] => 3
! 269: )
! 270: Array
! 271: (
! 272: [1] => 65534
! 273: )
! 274: Array
! 275: (
! 276: [1] => 0
! 277: )
! 278: Array
! 279: (
! 280: [1] => -1000
! 281: )
! 282: Array
! 283: (
! 284: [1] => -64434
! 285: )
! 286: Array
! 287: (
! 288: [1] => -65535
! 289: )
! 290: Array
! 291: (
! 292: [1] => -2147483647
! 293: )
! 294: Array
! 295: (
! 296: [1] => 65534
! 297: )
! 298: Array
! 299: (
! 300: [1] => 0
! 301: )
! 302: Array
! 303: (
! 304: [1] => -2147483646
! 305: )
! 306: Array
! 307: (
! 308: [1] => 0
! 309: )
! 310: Array
! 311: (
! 312: [1] => -2147483648
! 313: )
! 314: Array
! 315: (
! 316: [1] => 65534
! 317: )
! 318: Array
! 319: (
! 320: [1] => 1
! 321: )
! 322: Array
! 323: (
! 324: [1] => 0
! 325: )
! 326: Array
! 327: (
! 328: [1] => 64536
! 329: )
! 330: Array
! 331: (
! 332: [1] => 1102
! 333: )
! 334: Array
! 335: (
! 336: [1] => 1
! 337: )
! 338: Array
! 339: (
! 340: [1] => 32767
! 341: )
! 342: Array
! 343: (
! 344: [1] => -1
! 345: )
! 346: Array
! 347: (
! 348: [1] => 0
! 349: )
! 350: Array
! 351: (
! 352: [1] => -1000
! 353: )
! 354: Array
! 355: (
! 356: [1] => 1102
! 357: )
! 358: Array
! 359: (
! 360: [1] => 1
! 361: )
! 362: Array
! 363: (
! 364: [1] => 65534
! 365: )
! 366: Array
! 367: (
! 368: [1] => 1
! 369: )
! 370: Array
! 371: (
! 372: [1] => 0
! 373: )
! 374: Array
! 375: (
! 376: [1] => 64536
! 377: )
! 378: Array
! 379: (
! 380: [1] => 1102
! 381: )
! 382: Array
! 383: (
! 384: [1] => 1
! 385: )
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>