strtoupper1-win32.phpt 4.8 KB

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