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