Annotation of embedaddon/php/ext/standard/tests/strings/strtoupper1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strtoupper() 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 strtoupper ( string $string );
19: Description:
20: Returns string with all alphabetic characters converted to uppercase
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 strtoupper() with all 256 chars ***\n";
29: for ($i=0; $i<=255; $i++){
30: $char = chr($i);
31: print(bin2hex($char))." => ".(bin2hex(strtoupper("$char")))."\n";
32: }
33:
34: echo "\n*** Testing strtoupper() with basic strings ***\n";
35: $str = "Mary Had A liTTle LAmb and ShE loveD IT So\n";
36: var_dump(strtoupper($str));
37:
38: echo "\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 */
55: foreach ($strings as $string) {
56: echo "\n-- Iteration $count --\n";
57: var_dump( strtoupper($string) );
58: $count++;
59: }
60:
61: echo "\n*** Testing strtoupper() with two different case strings ***\n";
62: if (strtoupper("HeLLo woRLd") === strtoupper("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( strtoupper() ); /* Zero arguments */
69: var_dump( strtoupper("a", "b") ); /* Arguments > Expected */
70:
71: echo "*** Done ***";
72: ?>
73: --EXPECTF--
74: *** Testing strtoupper() 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 => 41
141: 42 => 42
142: 43 => 43
143: 44 => 44
144: 45 => 45
145: 46 => 46
146: 47 => 47
147: 48 => 48
148: 49 => 49
149: 4a => 4a
150: 4b => 4b
151: 4c => 4c
152: 4d => 4d
153: 4e => 4e
154: 4f => 4f
155: 50 => 50
156: 51 => 51
157: 52 => 52
158: 53 => 53
159: 54 => 54
160: 55 => 55
161: 56 => 56
162: 57 => 57
163: 58 => 58
164: 59 => 59
165: 5a => 5a
166: 5b => 5b
167: 5c => 5c
168: 5d => 5d
169: 5e => 5e
170: 5f => 5f
171: 60 => 60
172: 61 => 41
173: 62 => 42
174: 63 => 43
175: 64 => 44
176: 65 => 45
177: 66 => 46
178: 67 => 47
179: 68 => 48
180: 69 => 49
181: 6a => 4a
182: 6b => 4b
183: 6c => 4c
184: 6d => 4d
185: 6e => 4e
186: 6f => 4f
187: 70 => 50
188: 71 => 51
189: 72 => 52
190: 73 => 53
191: 74 => 54
192: 75 => 55
193: 76 => 56
194: 77 => 57
195: 78 => 58
196: 79 => 59
197: 7a => 5a
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:
332: *** Testing strtoupper() with basic strings ***
333: string(43) "MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
334: "
335:
336: *** Testing strtoupper() with various strings ***
337: -- Iteration 0 --
338: string(0) ""
339:
340: -- Iteration 1 --
341: string(6) "STRING"
342:
343: -- Iteration 2 --
344: string(10) "STRING0234"
345:
346: -- Iteration 3 --
347: string(20) "1.233.344STRING12333"
348:
349: -- Iteration 4 --
350: string(31) "$$$$$$!!!!@@@@@@@ ABCDEF !!!***"
351:
352: -- Iteration 5 --
353: string(13) "ABCD ABCDABCD"
354:
355: -- Iteration 6 --
356: string(0) ""
357:
358: -- Iteration 7 --
359: string(1) "1"
360:
361: -- Iteration 8 --
362: string(0) ""
363:
364: -- Iteration 9 --
365:
366: Warning: strtoupper() expects parameter 1 to be string, array given in %s on line %d
367: NULL
368:
369: *** Testing strtoupper() with two different case strings ***
370: strings are same, with Case Insensitive
371:
372: *** Testing error conditions ***
373: Warning: strtoupper() expects exactly 1 parameter, 0 given in %s on line %d
374: NULL
375:
376: Warning: strtoupper() expects exactly 1 parameter, 2 given in %s on line %d
377: NULL
378: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>