1--TEST--
2Test strncasecmp() function : usage variations - binary safe - all ASCII chars
3--FILE--
4<?php
5/* Test strncasecmp() function with binary values passed to 'str1' & 'str2' */
6
7echo "*** Test strncasecmp() function: with binary inputs ***\n";
8
9/* A binary function should work with all 256 characters that a character(8-bit) can take */
10echo "\n-- Checking with all 256 characters given, in binary format --\n";
11/* loop through to get all 256 character's equivalent binary value, and check working of strncasecmp() */
12$count = 1;
13for($ASCII = 0; $ASCII <= 255; $ASCII++) {
14  $str1 = decbin($ASCII);  //ASCII value in binary form
15  $str2 = decbin( ord( chr($ASCII) ) );  //Getting equivalent ASCII value for the character in binary form
16  echo "-- Iteration $count --\n";
17  var_dump( strncasecmp($str1, $str2, 8) );  //comparing all the 8-bits; expected: int(0)
18  var_dump( strncasecmp($str1, $str2, 4) );  //comparing only 4-bits; expected: int(0)
19  $count++;
20}
21
22echo "\n-- Checking with out of character's range, given in binary format --\n";
23$str1 = decbin(256);
24$str2 = decbin( ord( chr(256) ));
25var_dump( strncasecmp($str1, $str2, 8) );  //comparing all the 8-bits; expected: int(1)
26
27echo "\n*** Done ***\n";
28?>
29--EXPECT--
30*** Test strncasecmp() function: with binary inputs ***
31
32-- Checking with all 256 characters given, in binary format --
33-- Iteration 1 --
34int(0)
35int(0)
36-- Iteration 2 --
37int(0)
38int(0)
39-- Iteration 3 --
40int(0)
41int(0)
42-- Iteration 4 --
43int(0)
44int(0)
45-- Iteration 5 --
46int(0)
47int(0)
48-- Iteration 6 --
49int(0)
50int(0)
51-- Iteration 7 --
52int(0)
53int(0)
54-- Iteration 8 --
55int(0)
56int(0)
57-- Iteration 9 --
58int(0)
59int(0)
60-- Iteration 10 --
61int(0)
62int(0)
63-- Iteration 11 --
64int(0)
65int(0)
66-- Iteration 12 --
67int(0)
68int(0)
69-- Iteration 13 --
70int(0)
71int(0)
72-- Iteration 14 --
73int(0)
74int(0)
75-- Iteration 15 --
76int(0)
77int(0)
78-- Iteration 16 --
79int(0)
80int(0)
81-- Iteration 17 --
82int(0)
83int(0)
84-- Iteration 18 --
85int(0)
86int(0)
87-- Iteration 19 --
88int(0)
89int(0)
90-- Iteration 20 --
91int(0)
92int(0)
93-- Iteration 21 --
94int(0)
95int(0)
96-- Iteration 22 --
97int(0)
98int(0)
99-- Iteration 23 --
100int(0)
101int(0)
102-- Iteration 24 --
103int(0)
104int(0)
105-- Iteration 25 --
106int(0)
107int(0)
108-- Iteration 26 --
109int(0)
110int(0)
111-- Iteration 27 --
112int(0)
113int(0)
114-- Iteration 28 --
115int(0)
116int(0)
117-- Iteration 29 --
118int(0)
119int(0)
120-- Iteration 30 --
121int(0)
122int(0)
123-- Iteration 31 --
124int(0)
125int(0)
126-- Iteration 32 --
127int(0)
128int(0)
129-- Iteration 33 --
130int(0)
131int(0)
132-- Iteration 34 --
133int(0)
134int(0)
135-- Iteration 35 --
136int(0)
137int(0)
138-- Iteration 36 --
139int(0)
140int(0)
141-- Iteration 37 --
142int(0)
143int(0)
144-- Iteration 38 --
145int(0)
146int(0)
147-- Iteration 39 --
148int(0)
149int(0)
150-- Iteration 40 --
151int(0)
152int(0)
153-- Iteration 41 --
154int(0)
155int(0)
156-- Iteration 42 --
157int(0)
158int(0)
159-- Iteration 43 --
160int(0)
161int(0)
162-- Iteration 44 --
163int(0)
164int(0)
165-- Iteration 45 --
166int(0)
167int(0)
168-- Iteration 46 --
169int(0)
170int(0)
171-- Iteration 47 --
172int(0)
173int(0)
174-- Iteration 48 --
175int(0)
176int(0)
177-- Iteration 49 --
178int(0)
179int(0)
180-- Iteration 50 --
181int(0)
182int(0)
183-- Iteration 51 --
184int(0)
185int(0)
186-- Iteration 52 --
187int(0)
188int(0)
189-- Iteration 53 --
190int(0)
191int(0)
192-- Iteration 54 --
193int(0)
194int(0)
195-- Iteration 55 --
196int(0)
197int(0)
198-- Iteration 56 --
199int(0)
200int(0)
201-- Iteration 57 --
202int(0)
203int(0)
204-- Iteration 58 --
205int(0)
206int(0)
207-- Iteration 59 --
208int(0)
209int(0)
210-- Iteration 60 --
211int(0)
212int(0)
213-- Iteration 61 --
214int(0)
215int(0)
216-- Iteration 62 --
217int(0)
218int(0)
219-- Iteration 63 --
220int(0)
221int(0)
222-- Iteration 64 --
223int(0)
224int(0)
225-- Iteration 65 --
226int(0)
227int(0)
228-- Iteration 66 --
229int(0)
230int(0)
231-- Iteration 67 --
232int(0)
233int(0)
234-- Iteration 68 --
235int(0)
236int(0)
237-- Iteration 69 --
238int(0)
239int(0)
240-- Iteration 70 --
241int(0)
242int(0)
243-- Iteration 71 --
244int(0)
245int(0)
246-- Iteration 72 --
247int(0)
248int(0)
249-- Iteration 73 --
250int(0)
251int(0)
252-- Iteration 74 --
253int(0)
254int(0)
255-- Iteration 75 --
256int(0)
257int(0)
258-- Iteration 76 --
259int(0)
260int(0)
261-- Iteration 77 --
262int(0)
263int(0)
264-- Iteration 78 --
265int(0)
266int(0)
267-- Iteration 79 --
268int(0)
269int(0)
270-- Iteration 80 --
271int(0)
272int(0)
273-- Iteration 81 --
274int(0)
275int(0)
276-- Iteration 82 --
277int(0)
278int(0)
279-- Iteration 83 --
280int(0)
281int(0)
282-- Iteration 84 --
283int(0)
284int(0)
285-- Iteration 85 --
286int(0)
287int(0)
288-- Iteration 86 --
289int(0)
290int(0)
291-- Iteration 87 --
292int(0)
293int(0)
294-- Iteration 88 --
295int(0)
296int(0)
297-- Iteration 89 --
298int(0)
299int(0)
300-- Iteration 90 --
301int(0)
302int(0)
303-- Iteration 91 --
304int(0)
305int(0)
306-- Iteration 92 --
307int(0)
308int(0)
309-- Iteration 93 --
310int(0)
311int(0)
312-- Iteration 94 --
313int(0)
314int(0)
315-- Iteration 95 --
316int(0)
317int(0)
318-- Iteration 96 --
319int(0)
320int(0)
321-- Iteration 97 --
322int(0)
323int(0)
324-- Iteration 98 --
325int(0)
326int(0)
327-- Iteration 99 --
328int(0)
329int(0)
330-- Iteration 100 --
331int(0)
332int(0)
333-- Iteration 101 --
334int(0)
335int(0)
336-- Iteration 102 --
337int(0)
338int(0)
339-- Iteration 103 --
340int(0)
341int(0)
342-- Iteration 104 --
343int(0)
344int(0)
345-- Iteration 105 --
346int(0)
347int(0)
348-- Iteration 106 --
349int(0)
350int(0)
351-- Iteration 107 --
352int(0)
353int(0)
354-- Iteration 108 --
355int(0)
356int(0)
357-- Iteration 109 --
358int(0)
359int(0)
360-- Iteration 110 --
361int(0)
362int(0)
363-- Iteration 111 --
364int(0)
365int(0)
366-- Iteration 112 --
367int(0)
368int(0)
369-- Iteration 113 --
370int(0)
371int(0)
372-- Iteration 114 --
373int(0)
374int(0)
375-- Iteration 115 --
376int(0)
377int(0)
378-- Iteration 116 --
379int(0)
380int(0)
381-- Iteration 117 --
382int(0)
383int(0)
384-- Iteration 118 --
385int(0)
386int(0)
387-- Iteration 119 --
388int(0)
389int(0)
390-- Iteration 120 --
391int(0)
392int(0)
393-- Iteration 121 --
394int(0)
395int(0)
396-- Iteration 122 --
397int(0)
398int(0)
399-- Iteration 123 --
400int(0)
401int(0)
402-- Iteration 124 --
403int(0)
404int(0)
405-- Iteration 125 --
406int(0)
407int(0)
408-- Iteration 126 --
409int(0)
410int(0)
411-- Iteration 127 --
412int(0)
413int(0)
414-- Iteration 128 --
415int(0)
416int(0)
417-- Iteration 129 --
418int(0)
419int(0)
420-- Iteration 130 --
421int(0)
422int(0)
423-- Iteration 131 --
424int(0)
425int(0)
426-- Iteration 132 --
427int(0)
428int(0)
429-- Iteration 133 --
430int(0)
431int(0)
432-- Iteration 134 --
433int(0)
434int(0)
435-- Iteration 135 --
436int(0)
437int(0)
438-- Iteration 136 --
439int(0)
440int(0)
441-- Iteration 137 --
442int(0)
443int(0)
444-- Iteration 138 --
445int(0)
446int(0)
447-- Iteration 139 --
448int(0)
449int(0)
450-- Iteration 140 --
451int(0)
452int(0)
453-- Iteration 141 --
454int(0)
455int(0)
456-- Iteration 142 --
457int(0)
458int(0)
459-- Iteration 143 --
460int(0)
461int(0)
462-- Iteration 144 --
463int(0)
464int(0)
465-- Iteration 145 --
466int(0)
467int(0)
468-- Iteration 146 --
469int(0)
470int(0)
471-- Iteration 147 --
472int(0)
473int(0)
474-- Iteration 148 --
475int(0)
476int(0)
477-- Iteration 149 --
478int(0)
479int(0)
480-- Iteration 150 --
481int(0)
482int(0)
483-- Iteration 151 --
484int(0)
485int(0)
486-- Iteration 152 --
487int(0)
488int(0)
489-- Iteration 153 --
490int(0)
491int(0)
492-- Iteration 154 --
493int(0)
494int(0)
495-- Iteration 155 --
496int(0)
497int(0)
498-- Iteration 156 --
499int(0)
500int(0)
501-- Iteration 157 --
502int(0)
503int(0)
504-- Iteration 158 --
505int(0)
506int(0)
507-- Iteration 159 --
508int(0)
509int(0)
510-- Iteration 160 --
511int(0)
512int(0)
513-- Iteration 161 --
514int(0)
515int(0)
516-- Iteration 162 --
517int(0)
518int(0)
519-- Iteration 163 --
520int(0)
521int(0)
522-- Iteration 164 --
523int(0)
524int(0)
525-- Iteration 165 --
526int(0)
527int(0)
528-- Iteration 166 --
529int(0)
530int(0)
531-- Iteration 167 --
532int(0)
533int(0)
534-- Iteration 168 --
535int(0)
536int(0)
537-- Iteration 169 --
538int(0)
539int(0)
540-- Iteration 170 --
541int(0)
542int(0)
543-- Iteration 171 --
544int(0)
545int(0)
546-- Iteration 172 --
547int(0)
548int(0)
549-- Iteration 173 --
550int(0)
551int(0)
552-- Iteration 174 --
553int(0)
554int(0)
555-- Iteration 175 --
556int(0)
557int(0)
558-- Iteration 176 --
559int(0)
560int(0)
561-- Iteration 177 --
562int(0)
563int(0)
564-- Iteration 178 --
565int(0)
566int(0)
567-- Iteration 179 --
568int(0)
569int(0)
570-- Iteration 180 --
571int(0)
572int(0)
573-- Iteration 181 --
574int(0)
575int(0)
576-- Iteration 182 --
577int(0)
578int(0)
579-- Iteration 183 --
580int(0)
581int(0)
582-- Iteration 184 --
583int(0)
584int(0)
585-- Iteration 185 --
586int(0)
587int(0)
588-- Iteration 186 --
589int(0)
590int(0)
591-- Iteration 187 --
592int(0)
593int(0)
594-- Iteration 188 --
595int(0)
596int(0)
597-- Iteration 189 --
598int(0)
599int(0)
600-- Iteration 190 --
601int(0)
602int(0)
603-- Iteration 191 --
604int(0)
605int(0)
606-- Iteration 192 --
607int(0)
608int(0)
609-- Iteration 193 --
610int(0)
611int(0)
612-- Iteration 194 --
613int(0)
614int(0)
615-- Iteration 195 --
616int(0)
617int(0)
618-- Iteration 196 --
619int(0)
620int(0)
621-- Iteration 197 --
622int(0)
623int(0)
624-- Iteration 198 --
625int(0)
626int(0)
627-- Iteration 199 --
628int(0)
629int(0)
630-- Iteration 200 --
631int(0)
632int(0)
633-- Iteration 201 --
634int(0)
635int(0)
636-- Iteration 202 --
637int(0)
638int(0)
639-- Iteration 203 --
640int(0)
641int(0)
642-- Iteration 204 --
643int(0)
644int(0)
645-- Iteration 205 --
646int(0)
647int(0)
648-- Iteration 206 --
649int(0)
650int(0)
651-- Iteration 207 --
652int(0)
653int(0)
654-- Iteration 208 --
655int(0)
656int(0)
657-- Iteration 209 --
658int(0)
659int(0)
660-- Iteration 210 --
661int(0)
662int(0)
663-- Iteration 211 --
664int(0)
665int(0)
666-- Iteration 212 --
667int(0)
668int(0)
669-- Iteration 213 --
670int(0)
671int(0)
672-- Iteration 214 --
673int(0)
674int(0)
675-- Iteration 215 --
676int(0)
677int(0)
678-- Iteration 216 --
679int(0)
680int(0)
681-- Iteration 217 --
682int(0)
683int(0)
684-- Iteration 218 --
685int(0)
686int(0)
687-- Iteration 219 --
688int(0)
689int(0)
690-- Iteration 220 --
691int(0)
692int(0)
693-- Iteration 221 --
694int(0)
695int(0)
696-- Iteration 222 --
697int(0)
698int(0)
699-- Iteration 223 --
700int(0)
701int(0)
702-- Iteration 224 --
703int(0)
704int(0)
705-- Iteration 225 --
706int(0)
707int(0)
708-- Iteration 226 --
709int(0)
710int(0)
711-- Iteration 227 --
712int(0)
713int(0)
714-- Iteration 228 --
715int(0)
716int(0)
717-- Iteration 229 --
718int(0)
719int(0)
720-- Iteration 230 --
721int(0)
722int(0)
723-- Iteration 231 --
724int(0)
725int(0)
726-- Iteration 232 --
727int(0)
728int(0)
729-- Iteration 233 --
730int(0)
731int(0)
732-- Iteration 234 --
733int(0)
734int(0)
735-- Iteration 235 --
736int(0)
737int(0)
738-- Iteration 236 --
739int(0)
740int(0)
741-- Iteration 237 --
742int(0)
743int(0)
744-- Iteration 238 --
745int(0)
746int(0)
747-- Iteration 239 --
748int(0)
749int(0)
750-- Iteration 240 --
751int(0)
752int(0)
753-- Iteration 241 --
754int(0)
755int(0)
756-- Iteration 242 --
757int(0)
758int(0)
759-- Iteration 243 --
760int(0)
761int(0)
762-- Iteration 244 --
763int(0)
764int(0)
765-- Iteration 245 --
766int(0)
767int(0)
768-- Iteration 246 --
769int(0)
770int(0)
771-- Iteration 247 --
772int(0)
773int(0)
774-- Iteration 248 --
775int(0)
776int(0)
777-- Iteration 249 --
778int(0)
779int(0)
780-- Iteration 250 --
781int(0)
782int(0)
783-- Iteration 251 --
784int(0)
785int(0)
786-- Iteration 252 --
787int(0)
788int(0)
789-- Iteration 253 --
790int(0)
791int(0)
792-- Iteration 254 --
793int(0)
794int(0)
795-- Iteration 255 --
796int(0)
797int(0)
798-- Iteration 256 --
799int(0)
800int(0)
801
802-- Checking with out of character's range, given in binary format --
803int(1)
804
805*** Done ***
806