/* void test_putstr(void) { char str[] = "PUTSTR"; printf("\033[1;33m%s\033[0m\n", str); ft_putstr("Bonjour"); ft_putstr(" les"); ft_putstr(" amis"); ft_putstr(" !"); ft_putstr("\n"); ft_putstr(NULL); ft_putstr("\n"); printf("\033[1;32m%s passed.\033[0m\n\n", str); } void test_add(void) { //This function adds i & j char str[] = "ADD"; printf("\033[1;33m%s\033[0m\n", str); printf("3 + 5 = %d\n", ft_add(3, 5)); printf("39 + 39 = %d\n", ft_add(39, 39)); printf("0 + 0 = %d\n", ft_add(0, 0)); printf("0 + (-100) = %d\n", ft_add(0, -100)); printf("\033[1;32m%s passed.\033[0m\n\n", str); } void test_mult(void) { //This function multiplies i & j char str[] = "MULT"; printf("\033[1;33m%s\033[0m\n", str); printf("3 * 5 = %d\n", ft_mult(3, 5)); printf("39 * 39 = %d\n", ft_mult(39, 39)); printf("-3 * -1000 = %d\n", ft_mult(-3, -1000)); printf("0 * (-100) = %d\n", ft_mult(0, -100)); printf("\033[1;32m%s passed.\033[0m\n\n", str); } void test_putstr_fd(void) { char str[] = "PUTSTR_FD"; printf("\033[1;33m%s\033[0m\n", str); ft_putstr_fd("Bonjour", 2); ft_putstr_fd(" les", 1); ft_putstr_fd(" amis", 2); ft_putstr_fd(" !", 1); ft_putstr_fd("\n", 3); ft_putstr_fd(NULL, 1); ft_putstr_fd("\n", 1); printf("\033[1;32m%s passed.\033[0m\n\n", str); } void test_strclr(void) { char str[] = "STRCLR"; char str1[] = "COUCOU"; char str2[] = "LES"; printf("\033[1;33m%s\033[0m\n", str); printf("%s et %s deviennent : \n", str1, str2); ft_strclr(str1); ft_strclr(str2); printf("%s et %s\n", str1, str2); printf("\033[1;32m%s passed.\033[0m\n\n", str); } */ int main(void) { test_isascii(); test_isdigit(); test_isalpha(); test_isalnum(); test_isprint(); test_bzero(); //test_toupper(); //test_tolower(); test_strlen(); test_strcat(); test_memset(); test_memcpy(); test_puts(); test_strdup(); test_cat(); printf("\n\n\033[1;32m !! BONUS !! \033[0m\n\n"); //test_putstr(); //test_add(); //test_mult(); //test_putstr_fd(); //test_strclr(); test_strnew(); test_putchar(); return (0); }
int main(void) { set(MAGENTA); set(BOLD); printf("\n\t\t\t\t\t\t\t\t=============== FUNCTIONS ===============\n\n"); set(UNCOLOR); test_bzero(); test_strcat(); test_isalpha(); test_isdigit(); test_isalnum(); test_isascii(); test_isprint(); test_toupper(); test_tolower(); test_puts(); test_strlen(); test_memset(); test_memcpy(); test_strdup(); set(MAGENTA); set(BOLD); printf("\t\t\t\t\t\t\t\t================= BONUS =================\n\n"); set(UNCOLOR); test_islower(); test_isupper(); test_strcpy(); test_putchar(); test_putstr(); return (0); }
int main (int argc, char *argv[]) { test_sprintf (); test_vsprintf (); test_strdup (); test_strndup (); test_strcat (); test_strncat (); test_strcat_sprintf (); test_strcat_vsprintf (); test_str_split (); test_array_new (); test_array_add (); test_array_addn (); test_array_addp (); test_array_copy (); test_array_append (); test_str_wrap (); test_str_screen_width (); test_str_screen_wrap (); return 0; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_hexdump(); test_parse_uint32(); test_asprintf(); return 0; }
bool torture_local_replace(struct torture_context *ctx) { bool ret = true; ret &= test_ftruncate(); ret &= test_strlcpy(); ret &= test_strlcat(); ret &= test_mktime(); ret &= test_initgroups(); ret &= test_memmove(); ret &= test_strdup(); ret &= test_setlinebuf(); ret &= test_vsyslog(); ret &= test_timegm(); ret &= test_setenv(); ret &= test_strndup(); ret &= test_strnlen(); ret &= test_waitpid(); ret &= test_seteuid(); ret &= test_setegid(); ret &= test_asprintf(); ret &= test_snprintf(); ret &= test_vasprintf(); ret &= test_vsnprintf(); ret &= test_opendir(); ret &= test_readdir(); ret &= test_telldir(); ret &= test_seekdir(); ret &= test_dlopen(); ret &= test_chroot(); ret &= test_bzero(); ret &= test_strerror(); ret &= test_errno(); ret &= test_mkdtemp(); ret &= test_mkstemp(); ret &= test_pread(); ret &= test_pwrite(); ret &= test_getpass(); ret &= test_inet_ntoa(); ret &= test_strtoll(); ret &= test_strtoull(); ret &= test_va_copy(); ret &= test_FUNCTION(); ret &= test_MIN(); ret &= test_MAX(); ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); ret &= test_utime(); ret &= test_utimes(); ret &= test_memmem(); return ret; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_dump(); test_dump_slice(); test_parse_uint32(); test_asprintf(); test_strjoin(); test_strjoin_sep(); test_strsplit(); return 0; }
int main(int argc, char **argv) { grpc_test_init(argc, argv); test_strdup(); test_dump(); test_parse_uint32(); test_asprintf(); test_strjoin(); test_strjoin_sep(); test_ltoa(); test_int64toa(); test_leftpad(); test_stricmp(); return 0; }
int main(void) { ft_puts("\033[33m\n/!\\Change test_is last value from '0' to '1'\ndirectly in main if you want to see tests details./!\\\n\033[00m"); test_is(isdigit, ft_isdigit, "isdigit", 0); test_is(isalnum, ft_isalnum, "isalnum", 0); test_is(isalpha, ft_isalpha, "isalpha", 0); test_is(isascii, ft_isascii, "isascii", 0); test_is(toupper, ft_toupper, "toupper", 0); test_is(tolower, ft_tolower, "tolower", 0); test_bzero(ft_bzero, "bzero", 10); test_strcat(ft_strcat, "strcat"); test_puts(ft_puts, "ft_puts"); test_strlen(ft_strlen, "strlen", 26); test_memset(ft_memset, "memset", 10); test_memcpy("memcpy", 26); test_strdup("strdup", 10); ft_puts(""); return (0); }
int main() { test_isalpha(); test_isdigit(); test_isalnum(); test_isascii(); test_isprint(); test_tolower(); test_toupper(); test_bzero(); test_strcat(); test_strlen(); test_memset(); test_memcpy(); test_puts(); test_strdup(); test_strcmp(); test_cat(); test_isspace(); }
int main ( int argc, char *argv[] ) { int failed = 0; int ntest = 2; int i; newstr s; newstr_init( &s ); /* ...core functions */ for ( i=0; i<ntest; ++i ) failed += test_empty( &s ); /* ...adding functions */ for ( i=0; i<ntest; ++i) failed += test_addchar( &s ); for ( i=0; i<ntest; ++i) failed += test_strcat( &s ); for ( i=0; i<ntest; ++i ) failed += test_newstrcat( &s ); for ( i=0; i<ntest; ++i ) failed += test_segcat( &s ); for ( i=0; i<ntest; ++i ) failed += test_indxcat( &s ); for ( i=0; i<ntest; ++i ) failed += test_cattodelim( &s ); for ( i=0; i<ntest; ++i ) failed += test_prepend( &s ); for ( i=0; i<ntest; ++i ) failed += test_pad( &s ); for ( i=0; i<ntest; ++i ) failed += test_mergestrs( &s ); for ( i=0; i<ntest; ++i ) failed += test_makepath( &s ); /* ...copying functions */ for ( i=0; i<ntest; ++i) failed += test_strcpy( &s ); for ( i=0; i<ntest; ++i) failed += test_newstrcpy( &s ); for ( i=0; i<ntest; ++i ) failed += test_cpytodelim( &s ); for ( i=0; i<ntest; ++i) failed += test_segcpy( &s ); for ( i=0; i<ntest; ++i) failed += test_indxcpy( &s ); for ( i=0; i<ntest; ++i ) failed += test_copyposlen( &s ); for ( i=0; i<ntest; ++i ) failed += test_strdup(); /* ...utility functions */ for ( i=0; i<ntest; ++i) failed += test_findreplace( &s ); for ( i=0; i<ntest; ++i ) failed += test_reverse( &s ); for ( i=0; i<ntest; ++i ) failed += test_toupper( &s ); for ( i=0; i<ntest; ++i ) failed += test_tolower( &s ); for ( i=0; i<ntest; ++i ) failed += test_trimws( &s ); for ( i=0; i<ntest; ++i ) failed += test_trim( &s ); for ( i=0; i<ntest; ++i ) failed += test_case( &s ); for ( i=0; i<ntest; ++i ) failed += test_newstrcmp( &s ); for ( i=0; i<ntest; ++i ) failed += test_char( &s ); for ( i=0; i<ntest; ++i ) failed += test_swapstrings( &s ); for ( i=0; i<ntest; ++i ) failed += test_match( &s ); newstr_free( &s ); if ( !failed ) { printf( "%s: PASSED\n", progname ); return EXIT_SUCCESS; } else { printf( "%s: FAILED\n", progname ); return EXIT_FAILURE; } return EXIT_SUCCESS; }
/* * Take the amount of memory to allocate in bytes as a command-line argument * and call test_malloc with that amount of memory. */ int main(int argc, char *argv[]) { size_t size, max; size_t limit = 0; int willfail = 0; unsigned char code; if (argc < 3) die("Usage error. Type, size, and limit must be given."); errno = 0; size = strtol(argv[2], 0, 10); if (size == 0 && errno != 0) sysdie("Invalid size"); errno = 0; limit = strtol(argv[3], 0, 10); if (limit == 0 && errno != 0) sysdie("Invalid limit"); /* If the code is capitalized, install our customized error handler. */ code = argv[1][0]; if (isupper(code)) { xmalloc_error_handler = test_handler; code = tolower(code); } /* * Decide if the allocation should fail. If it should, set willfail to 2, * so that if it unexpectedly succeeds, we exit with a status indicating * that the test should be skipped. */ max = size; if (code == 's' || code == 'n' || code == 'a' || code == 'v') { max += size; if (limit > 0) limit += size; } if (limit > 0 && max > limit) willfail = 2; /* * If a memory limit was given and we can set memory limits, set it. * Otherwise, exit 2, signalling to the driver that the test should be * skipped. We do this here rather than in the driver due to some * pathological problems with Linux (setting ulimit in the shell caused * the shell to die). */ if (limit > 0) { #if HAVE_SETRLIMIT && defined(RLIMIT_AS) struct rlimit rl; void *tmp; size_t test_size; rl.rlim_cur = limit; rl.rlim_max = limit; if (setrlimit(RLIMIT_AS, &rl) < 0) { syswarn("Can't set data limit to %lu", (unsigned long) limit); exit(2); } if (size < limit || code == 'r') { test_size = code == 'r' ? 10 : size; if (test_size == 0) test_size = 1; tmp = malloc(test_size); if (tmp == NULL) { syswarn("Can't allocate initial memory of %lu (limit %lu)", (unsigned long) test_size, (unsigned long) limit); exit(2); } free(tmp); } #else warn("Data limits aren't supported."); exit(2); #endif } switch (code) { case 'c': exit(test_calloc(size) ? willfail : 1); case 'm': exit(test_malloc(size) ? willfail : 1); case 'r': exit(test_realloc(size) ? willfail : 1); case 's': exit(test_strdup(size) ? willfail : 1); case 'n': exit(test_strndup(size) ? willfail : 1); case 'a': exit(test_asprintf(size) ? willfail : 1); case 'v': exit(test_vasprintf(size) ? willfail : 1); default: die("Unknown mode %c", argv[1][0]); break; } exit(1); }
int main(void) { printf("\n"); printf ("\033[31m1 = Oui / 0 = Non\n\n\033[0m"); printf("\033[33m=== FT_BZERO ===\n\033[0m"); test_bzero(); printf("\n"); printf("\033[33m=== FT_STRCAT ===\n\033[0m"); test_strcat(); printf("\n"); printf("\033[33m=== FT_ISALPHA ===\n\033[0m"); test_isalpha(); printf("\n"); printf("\033[33m=== FT_ISDIGIT ===\n\033[0m"); test_isdigit(); printf("\n"); printf("\033[33m=== FT_ISALNUM ===\n\033[0m"); test_isalnum(); printf("\n"); printf("\033[33m=== FT_ISASCII ===\n\033[0m"); test_isascii(); printf("\n"); printf("\033[33m=== FT_ISPRINT ===\n\033[0m"); test_isprint(); printf("\n"); printf("\033[33m=== FT_TOUPPER ===\n\033[0m"); test_toupper(); printf("\n"); printf("\033[33m=== FT_TOLOWER ===\n\033[0m"); test_tolower(); printf("\n"); printf("\033[33m=== FT_PUTS ===\n\033[0m"); test_puts(); printf("\n"); printf("\033[33m=== FT_STRLEN ===\n\033[0m"); test_strlen(); printf("\n"); printf("\033[33m=== FT_MEMSET ===\n\033[0m"); test_memset(); printf("\n"); printf("\033[33m=== FT_STRDUP ===\n\033[0m"); test_strdup(); printf("\n"); printf("\033[33m=== FT_MEMCPY ===\n\033[0m"); test_memcpy(); printf("\n"); printf("\033[33m=== FT_CAT ===\n\033[0m"); test_cat(); printf("\n"); return (0); }