1--TEST--
2Test strtolower() function
3--FILE--
4<?php
5
6echo "*** Testing strtolower() with 256 chars ***\n";
7for ($i=0; $i<=255; $i++){
8  $char = chr($i);
9  print(bin2hex($char))." => ".(bin2hex(strtolower("$char")))."\n";
10}
11
12echo "*** Testing strlower() with basic strings ***\n";
13$str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
14var_dump(strtolower($str));
15
16echo "\n*** Testing strtolower() with various strings ***";
17/* strings to pass strtolower() */
18$strings = array (
19  "",
20  "string",
21  "stRINg0234",
22  "1.233.344StrinG12333",
23  "$$$$$$!!!!@@@@@@@ ABCDEF !!!***",
24  "ABCD\0abcdABCD",
25  TRUE,
26  FALSE,
27
28  /* Check for off-by-one errors in the SSE implementation */
29  "AAAAAAAAAAAAAAAAAAAA",
30  "ZZZZZZZZZZZZZZZZZZZZ",
31  "@@@@@@@@@@@@@@@@@@@@",
32  "[[[[[[[[[[[[[[[[[[[[",
33  "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34);
35
36$count = 0;
37/* loop through to check possible variations */
38foreach ($strings as $string) {
39  echo "\n-- Iteration $count --\n";
40  var_dump( strtolower($string) );
41  $count++;
42}
43
44echo "\n*** Testing strtolower() with two different case strings ***\n";
45if (strtolower("HeLLo woRLd") === strtolower("hEllo WORLD"))
46  echo "strings are same, with Case Insensitive\n";
47else
48  echo "strings are not same\n";
49
50echo "*** Done ***";
51?>
52--EXPECTF--
53*** Testing strtolower() with 256 chars ***
5400 => 00
5501 => 01
5602 => 02
5703 => 03
5804 => 04
5905 => 05
6006 => 06
6107 => 07
6208 => 08
6309 => 09
640a => 0a
650b => 0b
660c => 0c
670d => 0d
680e => 0e
690f => 0f
7010 => 10
7111 => 11
7212 => 12
7313 => 13
7414 => 14
7515 => 15
7616 => 16
7717 => 17
7818 => 18
7919 => 19
801a => 1a
811b => 1b
821c => 1c
831d => 1d
841e => 1e
851f => 1f
8620 => 20
8721 => 21
8822 => 22
8923 => 23
9024 => 24
9125 => 25
9226 => 26
9327 => 27
9428 => 28
9529 => 29
962a => 2a
972b => 2b
982c => 2c
992d => 2d
1002e => 2e
1012f => 2f
10230 => 30
10331 => 31
10432 => 32
10533 => 33
10634 => 34
10735 => 35
10836 => 36
10937 => 37
11038 => 38
11139 => 39
1123a => 3a
1133b => 3b
1143c => 3c
1153d => 3d
1163e => 3e
1173f => 3f
11840 => 40
11941 => 61
12042 => 62
12143 => 63
12244 => 64
12345 => 65
12446 => 66
12547 => 67
12648 => 68
12749 => 69
1284a => 6a
1294b => 6b
1304c => 6c
1314d => 6d
1324e => 6e
1334f => 6f
13450 => 70
13551 => 71
13652 => 72
13753 => 73
13854 => 74
13955 => 75
14056 => 76
14157 => 77
14258 => 78
14359 => 79
1445a => 7a
1455b => 5b
1465c => 5c
1475d => 5d
1485e => 5e
1495f => 5f
15060 => 60
15161 => 61
15262 => 62
15363 => 63
15464 => 64
15565 => 65
15666 => 66
15767 => 67
15868 => 68
15969 => 69
1606a => 6a
1616b => 6b
1626c => 6c
1636d => 6d
1646e => 6e
1656f => 6f
16670 => 70
16771 => 71
16872 => 72
16973 => 73
17074 => 74
17175 => 75
17276 => 76
17377 => 77
17478 => 78
17579 => 79
1767a => 7a
1777b => 7b
1787c => 7c
1797d => 7d
1807e => 7e
1817f => 7f
18280 => 80
18381 => 81
18482 => 82
18583 => 83
18684 => 84
18785 => 85
18886 => 86
18987 => 87
19088 => 88
19189 => 89
1928a => 8a
1938b => 8b
1948c => 8c
1958d => 8d
1968e => 8e
1978f => 8f
19890 => 90
19991 => 91
20092 => 92
20193 => 93
20294 => 94
20395 => 95
20496 => 96
20597 => 97
20698 => 98
20799 => 99
2089a => 9a
2099b => 9b
2109c => 9c
2119d => 9d
2129e => 9e
2139f => 9f
214a0 => a0
215a1 => a1
216a2 => a2
217a3 => a3
218a4 => a4
219a5 => a5
220a6 => a6
221a7 => a7
222a8 => a8
223a9 => a9
224aa => aa
225ab => ab
226ac => ac
227ad => ad
228ae => ae
229af => af
230b0 => b0
231b1 => b1
232b2 => b2
233b3 => b3
234b4 => b4
235b5 => b5
236b6 => b6
237b7 => b7
238b8 => b8
239b9 => b9
240ba => ba
241bb => bb
242bc => bc
243bd => bd
244be => be
245bf => bf
246c0 => c0
247c1 => c1
248c2 => c2
249c3 => c3
250c4 => c4
251c5 => c5
252c6 => c6
253c7 => c7
254c8 => c8
255c9 => c9
256ca => ca
257cb => cb
258cc => cc
259cd => cd
260ce => ce
261cf => cf
262d0 => d0
263d1 => d1
264d2 => d2
265d3 => d3
266d4 => d4
267d5 => d5
268d6 => d6
269d7 => d7
270d8 => d8
271d9 => d9
272da => da
273db => db
274dc => dc
275dd => dd
276de => de
277df => df
278e0 => e0
279e1 => e1
280e2 => e2
281e3 => e3
282e4 => e4
283e5 => e5
284e6 => e6
285e7 => e7
286e8 => e8
287e9 => e9
288ea => ea
289eb => eb
290ec => ec
291ed => ed
292ee => ee
293ef => ef
294f0 => f0
295f1 => f1
296f2 => f2
297f3 => f3
298f4 => f4
299f5 => f5
300f6 => f6
301f7 => f7
302f8 => f8
303f9 => f9
304fa => fa
305fb => fb
306fc => fc
307fd => fd
308fe => fe
309ff => ff
310*** Testing strlower() with basic strings ***
311string(43) "mary had a little lamb and she loved it so
312"
313
314*** Testing strtolower() with various strings ***
315-- Iteration 0 --
316string(0) ""
317
318-- Iteration 1 --
319string(6) "string"
320
321-- Iteration 2 --
322string(10) "string0234"
323
324-- Iteration 3 --
325string(20) "1.233.344string12333"
326
327-- Iteration 4 --
328string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***"
329
330-- Iteration 5 --
331string(13) "abcd%0abcdabcd"
332
333-- Iteration 6 --
334string(1) "1"
335
336-- Iteration 7 --
337string(0) ""
338
339-- Iteration 8 --
340string(20) "aaaaaaaaaaaaaaaaaaaa"
341
342-- Iteration 9 --
343string(20) "zzzzzzzzzzzzzzzzzzzz"
344
345-- Iteration 10 --
346string(20) "@@@@@@@@@@@@@@@@@@@@"
347
348-- Iteration 11 --
349string(20) "[[[[[[[[[[[[[[[[[[[["
350
351-- Iteration 12 --
352string(62) "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz"
353
354*** Testing strtolower() with two different case strings ***
355strings are same, with Case Insensitive
356*** Done ***
357