Return to strtolower-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test strtolower() function 3: --SKIPIF-- 4: <?php 5: if( (substr(PHP_OS, 0, 3) != "WIN") || (setlocale(LC_CTYPE, "") != "English_United States.1252") ) 6: die('skip Run only on Windows with locale as "English_United States.1252"'); 7: ?> 8: --FILE-- 9: <?php 10: /* Prototype: 11: string strtolower ( string $str ); 12: Description: 13: Returns string with all alphabetic characters converted to lowercase. 14: */ 15: 16: echo "*** Testing strtolower() with all 256 chars ***\n"; 17: for ($i=0; $i<=255; $i++){ 18: $char = chr($i); 19: print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n"; 20: } 21: 22: echo "*** Testing strlower() with basic strings ***\n"; 23: $str = "Mary Had A liTTle LAmb and ShE loveD IT So\n"; 24: var_dump(strtolower($str)); 25: 26: echo "\n*** Testing strtolower() with various strings ***"; 27: /* strings to pass strtolower() */ 28: $strings = array ( 29: "", 30: "string", 31: "stRINg0234", 32: "1.233.344StrinG12333", 33: "$$$$$$!!!!@@@@@@@ ABCDEF !!!***", 34: "ABCD\0abcdABCD", 35: NULL, 36: TRUE, 37: FALSE, 38: array() 39: ); 40: 41: $count = 0; 42: /* loop through to check possible variations */ 43: foreach ($strings as $string) { 44: echo "\n-- Iteration $count --\n"; 45: var_dump( strtolower($string) ); 46: $count++; 47: } 48: 49: echo "\n*** Testing strtolower() with two different case strings ***\n"; 50: if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD")) 51: echo "strings are same, with Case Insensitive\n"; 52: else 53: echo "strings are not same\n"; 54: 55: echo "\n*** Testing error conditions ***"; 56: var_dump( strtolower() ); /* Zero arguments */ 57: var_dump( strtolower("a", "b") ); /* Arguments > Expected */ 58: 59: echo "*** Done ***"; 60: ?> 61: --EXPECTF-- 62: *** Testing strtolower() with all 256 chars *** 63: 00 => 00 64: 01 => 01 65: 02 => 02 66: 03 => 03 67: 04 => 04 68: 05 => 05 69: 06 => 06 70: 07 => 07 71: 08 => 08 72: 09 => 09 73: 0a => 0a 74: 0b => 0b 75: 0c => 0c 76: 0d => 0d 77: 0e => 0e 78: 0f => 0f 79: 10 => 10 80: 11 => 11 81: 12 => 12 82: 13 => 13 83: 14 => 14 84: 15 => 15 85: 16 => 16 86: 17 => 17 87: 18 => 18 88: 19 => 19 89: 1a => 1a 90: 1b => 1b 91: 1c => 1c 92: 1d => 1d 93: 1e => 1e 94: 1f => 1f 95: 20 => 20 96: 21 => 21 97: 22 => 22 98: 23 => 23 99: 24 => 24 100: 25 => 25 101: 26 => 26 102: 27 => 27 103: 28 => 28 104: 29 => 29 105: 2a => 2a 106: 2b => 2b 107: 2c => 2c 108: 2d => 2d 109: 2e => 2e 110: 2f => 2f 111: 30 => 30 112: 31 => 31 113: 32 => 32 114: 33 => 33 115: 34 => 34 116: 35 => 35 117: 36 => 36 118: 37 => 37 119: 38 => 38 120: 39 => 39 121: 3a => 3a 122: 3b => 3b 123: 3c => 3c 124: 3d => 3d 125: 3e => 3e 126: 3f => 3f 127: 40 => 40 128: 41 => 61 129: 42 => 62 130: 43 => 63 131: 44 => 64 132: 45 => 65 133: 46 => 66 134: 47 => 67 135: 48 => 68 136: 49 => 69 137: 4a => 6a 138: 4b => 6b 139: 4c => 6c 140: 4d => 6d 141: 4e => 6e 142: 4f => 6f 143: 50 => 70 144: 51 => 71 145: 52 => 72 146: 53 => 73 147: 54 => 74 148: 55 => 75 149: 56 => 76 150: 57 => 77 151: 58 => 78 152: 59 => 79 153: 5a => 7a 154: 5b => 5b 155: 5c => 5c 156: 5d => 5d 157: 5e => 5e 158: 5f => 5f 159: 60 => 60 160: 61 => 61 161: 62 => 62 162: 63 => 63 163: 64 => 64 164: 65 => 65 165: 66 => 66 166: 67 => 67 167: 68 => 68 168: 69 => 69 169: 6a => 6a 170: 6b => 6b 171: 6c => 6c 172: 6d => 6d 173: 6e => 6e 174: 6f => 6f 175: 70 => 70 176: 71 => 71 177: 72 => 72 178: 73 => 73 179: 74 => 74 180: 75 => 75 181: 76 => 76 182: 77 => 77 183: 78 => 78 184: 79 => 79 185: 7a => 7a 186: 7b => 7b 187: 7c => 7c 188: 7d => 7d 189: 7e => 7e 190: 7f => 7f 191: 80 => 80 192: 81 => 81 193: 82 => 82 194: 83 => 83 195: 84 => 84 196: 85 => 85 197: 86 => 86 198: 87 => 87 199: 88 => 88 200: 89 => 89 201: 8a => 9a 202: 8b => 8b 203: 8c => 9c 204: 8d => 8d 205: 8e => 9e 206: 8f => 8f 207: 90 => 90 208: 91 => 91 209: 92 => 92 210: 93 => 93 211: 94 => 94 212: 95 => 95 213: 96 => 96 214: 97 => 97 215: 98 => 98 216: 99 => 99 217: 9a => 9a 218: 9b => 9b 219: 9c => 9c 220: 9d => 9d 221: 9e => 9e 222: 9f => ff 223: a0 => a0 224: a1 => a1 225: a2 => a2 226: a3 => a3 227: a4 => a4 228: a5 => a5 229: a6 => a6 230: a7 => a7 231: a8 => a8 232: a9 => a9 233: aa => aa 234: ab => ab 235: ac => ac 236: ad => ad 237: ae => ae 238: af => af 239: b0 => b0 240: b1 => b1 241: b2 => b2 242: b3 => b3 243: b4 => b4 244: b5 => b5 245: b6 => b6 246: b7 => b7 247: b8 => b8 248: b9 => b9 249: ba => ba 250: bb => bb 251: bc => bc 252: bd => bd 253: be => be 254: bf => bf 255: c0 => e0 256: c1 => e1 257: c2 => e2 258: c3 => e3 259: c4 => e4 260: c5 => e5 261: c6 => e6 262: c7 => e7 263: c8 => e8 264: c9 => e9 265: ca => ea 266: cb => eb 267: cc => ec 268: cd => ed 269: ce => ee 270: cf => ef 271: d0 => f0 272: d1 => f1 273: d2 => f2 274: d3 => f3 275: d4 => f4 276: d5 => f5 277: d6 => f6 278: d7 => d7 279: d8 => f8 280: d9 => f9 281: da => fa 282: db => fb 283: dc => fc 284: dd => fd 285: de => fe 286: df => df 287: e0 => e0 288: e1 => e1 289: e2 => e2 290: e3 => e3 291: e4 => e4 292: e5 => e5 293: e6 => e6 294: e7 => e7 295: e8 => e8 296: e9 => e9 297: ea => ea 298: eb => eb 299: ec => ec 300: ed => ed 301: ee => ee 302: ef => ef 303: f0 => f0 304: f1 => f1 305: f2 => f2 306: f3 => f3 307: f4 => f4 308: f5 => f5 309: f6 => f6 310: f7 => f7 311: f8 => f8 312: f9 => f9 313: fa => fa 314: fb => fb 315: fc => fc 316: fd => fd 317: fe => fe 318: ff => ff 319: *** Testing strlower() with basic strings *** 320: string(43) "mary had a little lamb and she loved it so 321: " 322: 323: *** Testing strtolower() with various strings *** 324: -- Iteration 0 -- 325: string(0) "" 326: 327: -- Iteration 1 -- 328: string(6) "string" 329: 330: -- Iteration 2 -- 331: string(10) "string0234" 332: 333: -- Iteration 3 -- 334: string(20) "1.233.344string12333" 335: 336: -- Iteration 4 -- 337: string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***" 338: 339: -- Iteration 5 -- 340: string(13) "abcd abcdabcd" 341: 342: -- Iteration 6 -- 343: string(0) "" 344: 345: -- Iteration 7 -- 346: string(1) "1" 347: 348: -- Iteration 8 -- 349: string(0) "" 350: 351: -- Iteration 9 -- 352: 353: Warning: strtolower() expects parameter 1 to be string, array given in %s on line %d 354: NULL 355: 356: *** Testing strtolower() with two different case strings *** 357: strings are same, with Case Insensitive 358: 359: *** Testing error conditions *** 360: Warning: strtolower() expects exactly 1 parameter, 0 given in %s on line %d 361: NULL 362: 363: Warning: strtolower() expects exactly 1 parameter, 2 given in %s on line %d 364: NULL 365: *** Done ***