|
| 1 | +#include <stdio.h> |
| 2 | +#include <string.h> |
| 3 | +#include <ti/screen.h> |
| 4 | +#include <ti/getkey.h> |
| 5 | + |
| 6 | +#define C(expr) if (!(expr)) { return __LINE__; } |
| 7 | +static int libc_test(void) { |
| 8 | + |
| 9 | + char const * str = "abcdef"; |
| 10 | + char const * empty = ""; |
| 11 | + |
| 12 | + C(strspn(str, "abc") == 3); |
| 13 | + C(strspn(str, "cba") == 3); |
| 14 | + C(strspn(str, "def") == 0); |
| 15 | + C(strspn(str, "fed") == 0); |
| 16 | + C(strspn(str, "ABCDEF") == 0); |
| 17 | + C(strspn(str, "bbeebe") == 0); |
| 18 | + C(strspn(str, "eebbeb") == 0); |
| 19 | + C(strspn(str, "aaffaf") == 1); |
| 20 | + C(strspn(str, "ffaafa") == 1); |
| 21 | + C(strspn(str, str) == 6); |
| 22 | + C(strspn(str, empty) == 0); |
| 23 | + C(strspn(empty, str) == 0); |
| 24 | + C(strspn(empty, empty) == 0); |
| 25 | + |
| 26 | + C(strcspn(str, "abc") == 0); |
| 27 | + C(strcspn(str, "cba") == 0); |
| 28 | + C(strcspn(str, "def") == 3); |
| 29 | + C(strcspn(str, "fed") == 3); |
| 30 | + C(strcspn(str, "ABCDEF") == 6); |
| 31 | + C(strcspn(str, "bbeebe") == 1); |
| 32 | + C(strcspn(str, "eebbeb") == 1); |
| 33 | + C(strcspn(str, "aaffaf") == 0); |
| 34 | + C(strcspn(str, "ffaafa") == 0); |
| 35 | + C(strcspn(str, str) == 0); |
| 36 | + C(strcspn(str, empty) == 6); |
| 37 | + C(strcspn(empty, str) == 0); |
| 38 | + C(strcspn(empty, empty) == 0); |
| 39 | + |
| 40 | + C(strpbrk(str, "abc") == str + 0); |
| 41 | + C(strpbrk(str, "cba") == str + 0); |
| 42 | + C(strpbrk(str, "def") == str + 3); |
| 43 | + C(strpbrk(str, "fed") == str + 3); |
| 44 | + C(strpbrk(str, "ABCDEF") == NULL); |
| 45 | + C(strpbrk(str, "bbeebe") == str + 1); |
| 46 | + C(strpbrk(str, "eebbeb") == str + 1); |
| 47 | + C(strpbrk(str, "aaffaf") == str + 0); |
| 48 | + C(strpbrk(str, "ffaafa") == str + 0); |
| 49 | + C(strpbrk(str, str) == str); |
| 50 | + C(strpbrk(str, empty) == NULL); |
| 51 | + C(strpbrk(empty, str) == NULL); |
| 52 | + C(strpbrk(empty, empty) == NULL); |
| 53 | + |
| 54 | + return 0; |
| 55 | +} |
| 56 | +#undef C |
| 57 | + |
| 58 | +int main(void) |
| 59 | +{ |
| 60 | + os_ClrHome(); |
| 61 | + |
| 62 | + printf("%d\n", libc_test()); |
| 63 | + |
| 64 | + os_GetKey(); |
| 65 | + |
| 66 | + return 0; |
| 67 | +} |
0 commit comments