/* 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[]) { char * s1 = "BeiJing"; char * s2 = "BeiHai"; assert(strncmp(s1, s2, 3) == 0); test_change_string(); test_string_copy(); test_string_contain_zero(); test_memset(); 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(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); }
/** * lib_memset() - unit test for memset() * * Test memset() with varied alignment and length of the changed buffer. * * @uts: unit test state * Return: 0 = success, 1 = failure */ static int lib_memset(struct unit_test_state *uts) { u8 buf[BUFLEN]; int offset, len; void *ptr; for (offset = 0; offset <= SWEEP; ++offset) { for (len = 1; len < BUFLEN - SWEEP; ++len) { init_buffer(buf, 0); ptr = memset(buf + offset, MASK, len); ut_asserteq_ptr(buf + offset, (u8 *)ptr); if (test_memset(uts, buf, MASK, offset, len)) { debug("%s: failure %d, %d\n", __func__, offset, len); return CMD_RET_FAILURE; } } } 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(); }
void kmain( void* mbd, unsigned int magic ) { if ( magic != 0x2BADB002 ) { /* Something went not according to specs. Print an error */ /* message and halt, but do *not* rely on the multiboot */ /* data structure. */ kputs("magic number failed, a-bloo a-bloo :("); return; } /* You could either use multiboot.h */ /* (http://www.gnu.org/software/grub/manual/multiboot/multiboot.html#multiboot_002eh) */ /* or do your offsets yourself. The following is merely an example. */ char * boot_loader_name =(char*) ((long*)mbd)[16]; clear(); kputs("Welcome to BonzOS"); kputs("~ My OS is a POS ~"); kputs(boot_loader_name); kputs(""); kputs("Testing memcpy, memset, and memcmp:"); test_memcpy(); test_memset(); test_memcmp(); if (bochs_vga_available()) { kputs("Bochs VGA is available."); bochs_vga_set_resolution(800, 600); clear_screen(0xFF); clear_screen(0xEE); clear_screen(0x77); clear_screen(0x0); draw_box(30, 30, 100, 100, 0x00FFFF00); } }
int main(int argc, char **argv) { int ret; struct starpu_conf conf; starpu_conf_init(&conf); conf.sched_policy_name = "eager"; conf.calibrate = 2; ret = starpu_initialize(&conf, &argc, &argv); if (ret == -ENODEV) return STARPU_TEST_SKIPPED; STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); #ifdef STARPU_USE_OPENCL ret = starpu_opencl_load_opencl_from_file("tests/perfmodels/opencl_memset_kernel.cl", &opencl_program, NULL); STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file"); #endif int slog; for (slog = START_LOG; slog < END_LOG; slog++) { int size = 1 << slog; test_memset(size); } #ifdef STARPU_USE_OPENCL ret = starpu_opencl_unload_opencl(&opencl_program); STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_unload_opencl"); #endif starpu_shutdown(); return EXIT_SUCCESS; }
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; }
int main(void) { char *buf; char *buf2; buf = malloc(100); assert(test_memset(buf, 0x42, 100) == 0); free(buf); buf = malloc(128); assert(test_memset(buf, 0, 128) == 0); assert(test_memset(buf+1, 0, 127) == 0); free(buf); buf = malloc(1024); assert(test_memset(buf, 0, 1024) == 0); free(buf); buf = malloc(20); strncpy(buf, "Hello World!", 20); assert(test_memchr(buf, 'o', strlen(buf), buf+4)); assert(test_memchr(buf, 'a', strlen(buf), NULL)); assert(test_memcmp(buf, "Hello World!", strlen(buf), 0)); assert(test_memcmp(buf, "Hfllow World", strlen(buf), -1)); assert(test_strcmp(buf, "Hello World!", 0)); assert(test_strcmp(buf, "Hfllow World", -1)); assert(test_strchr(buf, 'H', buf)); assert(test_strchr(buf, 'e', buf+1)); assert(test_strchr(buf, 'a', NULL)); assert(test_strchr(buf, '!', buf+11)); assert(test_strrchr(buf, 'H', buf)); assert(test_strrchr(buf, 'o', buf+7)); assert(test_strrchr(buf, 'a', NULL)); assert(test_strrchr(buf, 'l', buf+9)); assert(test_strrchr(buf, '!', buf+11)); assert(test_strcasecmp(buf, "Hello World!", 0)); assert(test_strcasecmp(buf, "HELLO WORLD!", 0)); assert(test_strcasecmp(buf, "IELLO world!", -1)); assert(test_strcasecmp(buf, "HeLLo WOrlc!", 1)); assert(test_strncasecmp(buf, "Hello World!", strlen(buf), 0)); assert(test_strncasecmp(buf, "HELLO WORLD!", strlen(buf), 0)); assert(test_strncasecmp(buf, "IELLO world!", strlen(buf), -1)); assert(test_strncasecmp(buf, "HeLLo WOrlc!", strlen(buf), 1)); assert(test_strncasecmp(buf, "HeLLo WOrlc!", 0, 0)); assert(test_strncasecmp(buf, "HeLLo WOrlc!", 1, 0)); assert(test_strncasecmp(buf, "HeLLo WOrlc!", 2, 0)); assert(test_strncasecmp(buf, "HeLLp WOrlc!", 5, -1)); free(buf); buf = malloc(20); buf2 = malloc(20); strncpy(buf, "Hello", 20); strncpy(buf2, " World!", 20); assert(test_memmove(buf + 5, buf2, strlen(buf2), buf, "Hello World!", strlen("Hello World!"))); strncpy(buf, "HHello World!", 20); assert(test_memmove(buf, buf+1, strlen("Hello World!"), buf, "Hello World!", strlen("Hello World!"))); strncpy(buf, "0123456789", 20); assert(test_memmove(buf+1, buf , strlen("0123456789"), buf, "00123456789", strlen("00123456789"))); free(buf); free(buf2); return 0; }
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); }