int main() { //strcpy printf("%d\n", test_strcpy("hello", 0)); //strncpy printf("%d\n", test_strncpy("hellohellohello", 7, 0)); printf("%d\n", test_strncpy("hello", 7, 0)); printf("%d\n", test_strncpy("hellohello", 10, 0)); //strcmp printf("%d\n", test_strcmp("aaa", "arc", 0)); printf("%d\n", test_strcmp("abc", "abc", 0)); printf("%d\n", test_strcmp("ccc", "abc", 0)); //strncmp printf("%d\n", test_strncmp("aaaddd", "alcccc", 3, 0)); printf("%d\n", test_strncmp("abcddd", "abcccc", 3, 0)); printf("%d\n", test_strncmp("cccddd", "abcccc", 3, 0)); //strcat printf("%d\n", test_strcat("world", "hello", 0)); printf("%d\n", test_strcat("fg", "", 0)); printf("%d\n", test_strcat("", "hello", 0)); //strncat printf("%d\n", test_strncat("world", "hello", 3, 0)); printf("%d\n", test_strncat("world", "hello", 10, 0)); printf("%d\n", test_strncat("", "hello", 10, 0)); //strlen printf("%d\n", test_strlen("", 0)); printf("%d\n", test_strlen("hello", 0)); //strchr printf("%d\n", test_strchr("world", 'r', 0)); printf("%d\n", test_strchr("world", 'a', 0)); printf("%d\n", test_strchr("", 'a', 0)); //strstr printf("%d\n", test_strstr("world", "rl", 0)); printf("%d\n", test_strstr("needle", "nee", 0)); printf("%d\n", test_strstr("world", "hello", 0)); return 0; }
int main(int argc, char** argv){ #ifdef USE_SECURE_LIB printf("USE secure lib\n"); #else printf("NOT USE secure lib\n"); #endif test_strncpy(); test_strncat(); test_strlen(); test_snprintf(); test_popen(); test_usleep(); return 0; }
static int __init test_init (void) { int status; /* Test strcmp first because we use it to test other things. */ test_strcmp (); /* Test strcpy next because we need it to set up other tests. */ test_strcpy (); /* strncmp. */ test_strncmp (); /* strncpy. */ test_strncpy (); /* memcmp. */ test_memcmp (); /* memchr. */ test_memchr (); /* memcpy - need not work for overlap. */ test_memcpy (); /* memmove - must work on overlap. */ test_memmove (); /* memset. */ test_memset (); if (errors == 0) { status = 0; printf("TEST PASS.\n"); } else { status = 1; printf("%Zd errors.\n", errors); printf("TEST FAIL.\n"); } return status; }
int main() { test_strchr(); test_strcmp(); test_strncmp(); test_strcpy(); test_strncpy(); test_strcspn(); test_strlen(); test_strcat(); test_strncat(); test_strpbrk(); test_strrchr(); test_strspn(); test_strstr(); test_strtok(); return 0; }
int main ( void ) { char buf[1024]; /* test strncpy, hence repnz stosb */ test_strncpy(); if (errors == 0) { printf("No errors.\n"); } else { printf("%d errors.\n", (int)errors); } /* test __ltostr, hence repnz stosb */ assert(__ltostr(buf,10,1723,10,0)==4); assert(!strcmp(buf,"1723")); assert(__ltostr(buf,3,1723,10,0)==2); assert(!strcmp(buf,"23")); assert(__ltostr(buf,2,0x1234,16,0)==1); assert(!strcmp(buf,"4")); assert(__ltostr(buf,3,0xFEFE,16,1)==2); assert(!strcmp(buf,"FE")); return 0; }
int main(int argc, char **argv) { test_memcpy(); test_memmove(); test_strlen(); test_strnlen(); test_memset(); test_strcmp(); test_strncmp(); test_memcmp(); test_strcat(); // strncat is not tested (code from the man page) test_strcpy(); test_strncpy(); test_strchr(); test_strrchr(); test_memchr(); test_memrchr(); test_strstr(); // strerror not tested // strdup not tested (uses malloc) // strndup not tested (uses malloc) return 0; }