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