Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <stddef.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "test.h"
  5.  
  6. #define T(s, c, n) { \
  7.         char *p = s; \
  8.         char *q = c; \
  9.         size_t r = strcspn(p, q); \
  10.         if (r != n) \
  11.                 t_error("strcspn(%s,%s) returned %lu, wanted %lu\n", #s, #c, (unsigned long)r, (unsigned long)(n)); \
  12. }
  13.  
  14. int main(void)
  15. {
  16.         int i;
  17.         char a[128];
  18.         char s[256];
  19.  
  20.         for (i = 0; i < 128; i++)
  21.                 a[i] = (i+1) & 127;
  22.         for (i = 0; i < 256; i++)
  23.                 *((unsigned char*)s+i) = i+1;
  24.  
  25.         T("", "", 0)
  26.         T("a", "", 1)
  27.         T("", "a", 0)
  28.         T("abc", "cde", 2)
  29.         T("abc", "ccc", 2)
  30.         T("abc", a, 0)
  31.         T("\xff\x80 abc", a, 2)
  32.         T(s, "\xff", 254)
  33.  
  34.         printf("%s finished\n", __FILE__);
  35.         return t_status;
  36. }
  37.