home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / compat / bsd / bcmp.c next >
Encoding:
C/C++ Source or Header  |  1995-08-23  |  780 b   |  40 lines

  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. char s1[] = "abcdefghijklmnopqrstuvwxyz";
  6. char s2[] = "abcdefghijklmnopqrstuvwxyz";
  7. char s3[] = "abcdefghijklMNOPQRSTUVWXYZ";
  8. char s4[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  9.  
  10. int ec = 0;
  11.  
  12. void
  13. expect(const char *p1, const char *p2, int len, int ex)
  14. {
  15.   int rv = bcmp(p1, p2, len);
  16.   if (rv != ex)
  17.   {
  18.     printf("failure: bcmp(%s,%s,%d) = %d, and not %d\n",
  19.        p1, p2, len, rv, ex);
  20.     ec ++;
  21.   }
  22. }
  23.  
  24. int
  25. main(void)
  26. {
  27.   expect(s1, s4, 0, 0);
  28.   expect(s1, s2, 26, 0);
  29.   expect(s1, s3, 26, 14);
  30.   expect(s1, s3, 14, 2);
  31.   expect(s1, s3, 13, 1);
  32.   expect(s1, s3, 12, 0);
  33.   expect(0, s3, 1, -1);
  34.   expect(0, 0, 1, 0);
  35.   expect(s3, 0, 1, -1);
  36.   if (!ec)
  37.     printf("pass\n");
  38.   return ec;
  39. }
  40.