1--TEST--
2Test strtoupper() function
3--FILE--
4<?php
5echo "*** Testing strtoupper() with 256 chars ***\n";
6for ($i=0; $i<=255; $i++){
7  $char = chr($i);
8  print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
9}
10
11echo "\n*** Testing strtoupper() with basic strings ***\n";
12$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
13var_dump(strtoupper($str));
14
15echo "\n*** Testing strtoupper() with various strings ***";
16/* strings to pass strtoupper() */
17$strings = array (
18  "",
19  "string",
20  "stRINg0234",
21  "1.233.344StrinG12333",
22  "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
23  "ABCD\0abcdABCD",
24  TRUE,
25  FALSE,
26  /* Check for off-by-one errors in the SSE implementation */
27  "aaaaaaaaaaaaaaaaaaaa",
28  "zzzzzzzzzzzzzzzzzzzz",
29  "````````````````````",
30  "{{{{{{{{{{{{{{{{{{{{",
31  /* And the AVX2 implementation also */
32  "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{",
33  "abcdefghijklmnopqrstuvwxyz01234",
34  "abcdefghijklmnopqrstuvwxyz012345",
35  "abcdefghijklmnopqrstuvwxyz0123456",
36  "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
37);
38
39$count = 0;
40/* loop through to check possible variations */
41foreach ($strings as $string) {
42  echo "\n-- Iteration $count --\n";
43  var_dump( strtoupper($string) );
44  $count++;
45}
46
47echo "\n*** Testing strtoupper() with two different case strings ***\n";
48if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
49  echo "strings are same, with Case Insensitive\n";
50else
51  echo "strings are not same\n";
52
53echo "*** Done ***";
54?>
55--EXPECTF--
56*** Testing strtoupper() with 256 chars ***
5700 => 00
5801 => 01
5902 => 02
6003 => 03
6104 => 04
6205 => 05
6306 => 06
6407 => 07
6508 => 08
6609 => 09
670a => 0a
680b => 0b
690c => 0c
700d => 0d
710e => 0e
720f => 0f
7310 => 10
7411 => 11
7512 => 12
7613 => 13
7714 => 14
7815 => 15
7916 => 16
8017 => 17
8118 => 18
8219 => 19
831a => 1a
841b => 1b
851c => 1c
861d => 1d
871e => 1e
881f => 1f
8920 => 20
9021 => 21
9122 => 22
9223 => 23
9324 => 24
9425 => 25
9526 => 26
9627 => 27
9728 => 28
9829 => 29
992a => 2a
1002b => 2b
1012c => 2c
1022d => 2d
1032e => 2e
1042f => 2f
10530 => 30
10631 => 31
10732 => 32
10833 => 33
10934 => 34
11035 => 35
11136 => 36
11237 => 37
11338 => 38
11439 => 39
1153a => 3a
1163b => 3b
1173c => 3c
1183d => 3d
1193e => 3e
1203f => 3f
12140 => 40
12241 => 41
12342 => 42
12443 => 43
12544 => 44
12645 => 45
12746 => 46
12847 => 47
12948 => 48
13049 => 49
1314a => 4a
1324b => 4b
1334c => 4c
1344d => 4d
1354e => 4e
1364f => 4f
13750 => 50
13851 => 51
13952 => 52
14053 => 53
14154 => 54
14255 => 55
14356 => 56
14457 => 57
14558 => 58
14659 => 59
1475a => 5a
1485b => 5b
1495c => 5c
1505d => 5d
1515e => 5e
1525f => 5f
15360 => 60
15461 => 41
15562 => 42
15663 => 43
15764 => 44
15865 => 45
15966 => 46
16067 => 47
16168 => 48
16269 => 49
1636a => 4a
1646b => 4b
1656c => 4c
1666d => 4d
1676e => 4e
1686f => 4f
16970 => 50
17071 => 51
17172 => 52
17273 => 53
17374 => 54
17475 => 55
17576 => 56
17677 => 57
17778 => 58
17879 => 59
1797a => 5a
1807b => 7b
1817c => 7c
1827d => 7d
1837e => 7e
1847f => 7f
18580 => 80
18681 => 81
18782 => 82
18883 => 83
18984 => 84
19085 => 85
19186 => 86
19287 => 87
19388 => 88
19489 => 89
1958a => 8a
1968b => 8b
1978c => 8c
1988d => 8d
1998e => 8e
2008f => 8f
20190 => 90
20291 => 91
20392 => 92
20493 => 93
20594 => 94
20695 => 95
20796 => 96
20897 => 97
20998 => 98
21099 => 99
2119a => 9a
2129b => 9b
2139c => 9c
2149d => 9d
2159e => 9e
2169f => 9f
217a0 => a0
218a1 => a1
219a2 => a2
220a3 => a3
221a4 => a4
222a5 => a5
223a6 => a6
224a7 => a7
225a8 => a8
226a9 => a9
227aa => aa
228ab => ab
229ac => ac
230ad => ad
231ae => ae
232af => af
233b0 => b0
234b1 => b1
235b2 => b2
236b3 => b3
237b4 => b4
238b5 => b5
239b6 => b6
240b7 => b7
241b8 => b8
242b9 => b9
243ba => ba
244bb => bb
245bc => bc
246bd => bd
247be => be
248bf => bf
249c0 => c0
250c1 => c1
251c2 => c2
252c3 => c3
253c4 => c4
254c5 => c5
255c6 => c6
256c7 => c7
257c8 => c8
258c9 => c9
259ca => ca
260cb => cb
261cc => cc
262cd => cd
263ce => ce
264cf => cf
265d0 => d0
266d1 => d1
267d2 => d2
268d3 => d3
269d4 => d4
270d5 => d5
271d6 => d6
272d7 => d7
273d8 => d8
274d9 => d9
275da => da
276db => db
277dc => dc
278dd => dd
279de => de
280df => df
281e0 => e0
282e1 => e1
283e2 => e2
284e3 => e3
285e4 => e4
286e5 => e5
287e6 => e6
288e7 => e7
289e8 => e8
290e9 => e9
291ea => ea
292eb => eb
293ec => ec
294ed => ed
295ee => ee
296ef => ef
297f0 => f0
298f1 => f1
299f2 => f2
300f3 => f3
301f4 => f4
302f5 => f5
303f6 => f6
304f7 => f7
305f8 => f8
306f9 => f9
307fa => fa
308fb => fb
309fc => fc
310fd => fd
311fe => fe
312ff => ff
313
314*** Testing strtoupper() with basic strings ***
315string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
316"
317
318*** Testing strtoupper() with various strings ***
319-- Iteration 0 --
320string(0) ""
321
322-- Iteration 1 --
323string(6) "STRING"
324
325-- Iteration 2 --
326string(10) "STRING0234"
327
328-- Iteration 3 --
329string(20) "1.233.344STRING12333"
330
331-- Iteration 4 --
332string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
333
334-- Iteration 5 --
335string(13) "ABCD%0ABCDABCD"
336
337-- Iteration 6 --
338string(1) "1"
339
340-- Iteration 7 --
341string(0) ""
342
343-- Iteration 8 --
344string(20) "AAAAAAAAAAAAAAAAAAAA"
345
346-- Iteration 9 --
347string(20) "ZZZZZZZZZZZZZZZZZZZZ"
348
349-- Iteration 10 --
350string(20) "````````````````````"
351
352-- Iteration 11 --
353string(20) "{{{{{{{{{{{{{{{{{{{{"
354
355-- Iteration 12 --
356string(40) "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{"
357
358-- Iteration 13 --
359string(31) "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234"
360
361-- Iteration 14 --
362string(32) "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
363
364-- Iteration 15 --
365string(33) "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456"
366
367-- Iteration 16 --
368string(62) "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
369
370*** Testing strtoupper() with two different case strings ***
371strings are same, with Case Insensitive
372*** Done ***
373