Annotation of embedaddon/php/ext/standard/tests/strings/strtolower.phpt, revision 1.1.1.2
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:
1.1.1.2 ! misho 28: echo "*** Testing strtolower() with 128 chars ***\n";
! 29: for ($i=0; $i<=127; $i++){
1.1 misho 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--
1.1.1.2 ! misho 74: *** Testing strtolower() with 128 chars ***
1.1 misho 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: *** Testing strlower() with basic strings ***
204: string(43) "mary had a little lamb and she loved it so
205: "
206:
207: *** Testing strtolower() with various strings ***
208: -- Iteration 0 --
209: string(0) ""
210:
211: -- Iteration 1 --
212: string(6) "string"
213:
214: -- Iteration 2 --
215: string(10) "string0234"
216:
217: -- Iteration 3 --
218: string(20) "1.233.344string12333"
219:
220: -- Iteration 4 --
221: string(31) "$$$$$$!!!!@@@@@@@ abcdef !!!***"
222:
223: -- Iteration 5 --
224: string(13) "abcd abcdabcd"
225:
226: -- Iteration 6 --
227: string(0) ""
228:
229: -- Iteration 7 --
230: string(1) "1"
231:
232: -- Iteration 8 --
233: string(0) ""
234:
235: -- Iteration 9 --
236:
237: Warning: strtolower() expects parameter 1 to be string, array given in %s on line %d
238: NULL
239:
240: *** Testing strtolower() with two different case strings ***
241: strings are same, with Case Insensitive
242:
243: *** Testing error conditions ***
244: Warning: strtolower() expects exactly 1 parameter, 0 given in %s on line %d
245: NULL
246:
247: Warning: strtolower() expects exactly 1 parameter, 2 given in %s on line %d
248: NULL
249: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>