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