1--TEST--
2Test strtoupper() function
3--SKIPIF--
4<?php
5if( substr(PHP_OS, 0, 3) == 'WIN') {
6  if (!setlocale(LC_ALL, 'C')) {
7    die('skip need "C" locale (this windows is broken)');
8  }
9} else {
10  if (!setlocale(LC_ALL, 'en_US.UTF-8', 'en')) {
11    die('skip need "en_US.UTF-8" locale');
12  }
13}
14?>
15--FILE--
16<?php
17/* Prototype:
18     string strtoupper ( string $string );
19   Description:
20     Returns string with all alphabetic characters converted to uppercase
21*/
22if( substr(PHP_OS, 0, 3) == 'WIN') {
23  setlocale(LC_ALL, 'C');
24} else {
25  setlocale(LC_ALL, 'en_US.UTF-8');
26}
27
28echo "*** Testing strtoupper() with all 256 chars ***\n";
29for ($i=0; $i<=255; $i++){
30  $char = chr($i);
31  print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
32}
33
34echo "\n*** Testing strtoupper() with basic strings ***\n";
35$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
36var_dump(strtoupper($str));
37
38echo "\n*** Testing strtoupper() with various strings ***";
39/* strings to pass strtoupper() */
40$strings = array (
41  "",
42  "string",
43  "stRINg0234",
44  "1.233.344StrinG12333",
45  "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
46  "ABCD\0abcdABCD",
47  NULL,
48  TRUE,
49  FALSE,
50  array()
51);
52
53$count = 0;
54/* loop through to check possible variations */
55foreach ($strings as $string) {
56  echo "\n-- Iteration $count --\n";
57  var_dump( strtoupper($string) );
58  $count++;
59}
60
61echo "\n*** Testing strtoupper() with two different case strings ***\n";
62if (strtoupper("HeLLo woRLd") === strtoupper("hEllo WORLD"))
63  echo "strings are same, with Case Insensitive\n";
64else
65  echo "strings are not same\n";
66
67echo "\n*** Testing error conditions ***";
68var_dump( strtoupper() ); /* Zero arguments */
69var_dump( strtoupper("a", "b") ); /* Arguments > Expected */
70
71echo "*** Done ***";
72?>
73--EXPECTF--
74*** Testing strtoupper() with all 256 chars ***
7500 => 00
7601 => 01
7702 => 02
7803 => 03
7904 => 04
8005 => 05
8106 => 06
8207 => 07
8308 => 08
8409 => 09
850a => 0a
860b => 0b
870c => 0c
880d => 0d
890e => 0e
900f => 0f
9110 => 10
9211 => 11
9312 => 12
9413 => 13
9514 => 14
9615 => 15
9716 => 16
9817 => 17
9918 => 18
10019 => 19
1011a => 1a
1021b => 1b
1031c => 1c
1041d => 1d
1051e => 1e
1061f => 1f
10720 => 20
10821 => 21
10922 => 22
11023 => 23
11124 => 24
11225 => 25
11326 => 26
11427 => 27
11528 => 28
11629 => 29
1172a => 2a
1182b => 2b
1192c => 2c
1202d => 2d
1212e => 2e
1222f => 2f
12330 => 30
12431 => 31
12532 => 32
12633 => 33
12734 => 34
12835 => 35
12936 => 36
13037 => 37
13138 => 38
13239 => 39
1333a => 3a
1343b => 3b
1353c => 3c
1363d => 3d
1373e => 3e
1383f => 3f
13940 => 40
14041 => 41
14142 => 42
14243 => 43
14344 => 44
14445 => 45
14546 => 46
14647 => 47
14748 => 48
14849 => 49
1494a => 4a
1504b => 4b
1514c => 4c
1524d => 4d
1534e => 4e
1544f => 4f
15550 => 50
15651 => 51
15752 => 52
15853 => 53
15954 => 54
16055 => 55
16156 => 56
16257 => 57
16358 => 58
16459 => 59
1655a => 5a
1665b => 5b
1675c => 5c
1685d => 5d
1695e => 5e
1705f => 5f
17160 => 60
17261 => 41
17362 => 42
17463 => 43
17564 => 44
17665 => 45
17766 => 46
17867 => 47
17968 => 48
18069 => 49
1816a => 4a
1826b => 4b
1836c => 4c
1846d => 4d
1856e => 4e
1866f => 4f
18770 => 50
18871 => 51
18972 => 52
19073 => 53
19174 => 54
19275 => 55
19376 => 56
19477 => 57
19578 => 58
19679 => 59
1977a => 5a
1987b => 7b
1997c => 7c
2007d => 7d
2017e => 7e
2027f => 7f
20380 => 80
20481 => 81
20582 => 82
20683 => 83
20784 => 84
20885 => 85
20986 => 86
21087 => 87
21188 => 88
21289 => 89
2138a => 8a
2148b => 8b
2158c => 8c
2168d => 8d
2178e => 8e
2188f => 8f
21990 => 90
22091 => 91
22192 => 92
22293 => 93
22394 => 94
22495 => 95
22596 => 96
22697 => 97
22798 => 98
22899 => 99
2299a => 9a
2309b => 9b
2319c => 9c
2329d => 9d
2339e => 9e
2349f => 9f
235a0 => a0
236a1 => a1
237a2 => a2
238a3 => a3
239a4 => a4
240a5 => a5
241a6 => a6
242a7 => a7
243a8 => a8
244a9 => a9
245aa => aa
246ab => ab
247ac => ac
248ad => ad
249ae => ae
250af => af
251b0 => b0
252b1 => b1
253b2 => b2
254b3 => b3
255b4 => b4
256b5 => b5
257b6 => b6
258b7 => b7
259b8 => b8
260b9 => b9
261ba => ba
262bb => bb
263bc => bc
264bd => bd
265be => be
266bf => bf
267c0 => c0
268c1 => c1
269c2 => c2
270c3 => c3
271c4 => c4
272c5 => c5
273c6 => c6
274c7 => c7
275c8 => c8
276c9 => c9
277ca => ca
278cb => cb
279cc => cc
280cd => cd
281ce => ce
282cf => cf
283d0 => d0
284d1 => d1
285d2 => d2
286d3 => d3
287d4 => d4
288d5 => d5
289d6 => d6
290d7 => d7
291d8 => d8
292d9 => d9
293da => da
294db => db
295dc => dc
296dd => dd
297de => de
298df => df
299e0 => e0
300e1 => e1
301e2 => e2
302e3 => e3
303e4 => e4
304e5 => e5
305e6 => e6
306e7 => e7
307e8 => e8
308e9 => e9
309ea => ea
310eb => eb
311ec => ec
312ed => ed
313ee => ee
314ef => ef
315f0 => f0
316f1 => f1
317f2 => f2
318f3 => f3
319f4 => f4
320f5 => f5
321f6 => f6
322f7 => f7
323f8 => f8
324f9 => f9
325fa => fa
326fb => fb
327fc => fc
328fd => fd
329fe => fe
330ff => ff
331
332*** Testing strtoupper() with basic strings ***
333string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
334"
335
336*** Testing strtoupper() with various strings ***
337-- Iteration 0 --
338string(0) ""
339
340-- Iteration 1 --
341string(6) "STRING"
342
343-- Iteration 2 --
344string(10) "STRING0234"
345
346-- Iteration 3 --
347string(20) "1.233.344STRING12333"
348
349-- Iteration 4 --
350string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
351
352-- Iteration 5 --
353string(13) "ABCD�ABCDABCD"
354
355-- Iteration 6 --
356string(0) ""
357
358-- Iteration 7 --
359string(1) "1"
360
361-- Iteration 8 --
362string(0) ""
363
364-- Iteration 9 --
365
366Warning: strtoupper() expects parameter 1 to be string, array given in %s on line %d
367NULL
368
369*** Testing strtoupper() with two different case strings ***
370strings are same, with Case Insensitive
371
372*** Testing error conditions ***
373Warning: strtoupper() expects exactly 1 parameter, 0 given in %s on line %d
374NULL
375
376Warning: strtoupper() expects exactly 1 parameter, 2 given in %s on line %d
377NULL
378*** Done ***
379