void test_isascii(void) { write(1, "\033[38;5;1m", 9); write(1, "tests ft_isascii: \n", 20); write(1, "\033[0m", 4); write(1, "tests char = '+'\n", 17); write(1, "ret = ", 6); ft_putnbr(ft_isascii('+')); write(1, "\n", 1); write(1, "tests int = 197 \n", 18); write(1, "ret = ", 6); ft_putnbr(ft_isascii(197)); write(1, "\n", 1); write(1, "\033[38;5;1m", 9); write(1, "tests isascii: \n", 17); write(1, "\033[0m", 4); write(1, "tests char = '+'\n", 17); write(1, "ret = ", 6); ft_putnbr(isascii('+')); write(1, "\n", 1); write(1, "tests int = 197 \n", 18); write(1, "ret = ", 6); ft_putnbr(isascii(197)); write(1, "\n\n", 2); }
int main() { char t1[2]; int fd = open("main.c", O_RDONLY); char buf[9]; ft_bzero(buf, 9); ft_strcat(buf, "Ba"); ft_strcat(buf, "j"); ft_strcat(buf, "our."); printf("%s\n", buf); t1[0] = '1'; t1[1] = '\0'; printf("bzero test : %s\n", t1); printf("strlen test : %zu\n", ft_strlen("asd")); printf("strcat test : %s\n", ft_strcat(t1, "ab")); printf("isalpha test : yes %d no %d yes %d no %d\n", ft_isalpha('z'), ft_isalpha('`'), ft_isalpha('A'), ft_isalpha(125)); printf("isdigit test : yes %d no %d yes %d no %d\n", ft_isdigit('1'), ft_isdigit('/'), ft_isdigit('9'), ft_isdigit(':')); printf("isalnum test : yes %d no %d\n", ft_isalnum('1'), ft_isalnum('~')); printf("isascii test : yes %d no %d yes %d no %d\n", ft_isascii('\0'), ft_isascii(-12), ft_isascii(127), ft_isascii(200)); printf("isprint test : yes %d no %d\n", ft_isprint(32), ft_isprint(127)); printf("tolower test : A %c Z %c a %c ~ %c\n", ft_tolower('A'), ft_tolower('Z'), ft_tolower('a'), ft_tolower('~')); printf("toupper test : a %c z %c A %c ~ %c\n", ft_toupper('a'), ft_toupper('z'), ft_toupper('A'), ft_toupper('~')); ft_puts("Hello World"); ft_puts("aaa\n(null)\n"); ft_puts("aaa"); ft_puts(NULL); ft_cat(fd); return (0); }
void test_isascii(void) { int c = 0; printf("\n\n ==========[is_ascii]==========\n"); while (c < 127) { if (ft_isascii(c)) printf("'%c' : %d\n", c, ft_isascii(c)); c++; } }
void check_isAscii() { int i = 0; printf( "--------\nTest ft_isascii:\n" ); for ( i = MIN; i < MAX; i++ ) { if ( ft_isascii( i ) != isascii( i ) ) { printf("[%d] -> result: %d, expected result: %d\n", i, ft_isascii( i ), isascii( i ) ); exit( 0 ); } } printf("\033[32mOk\n\033[0m"); }
void test_ft_isascii(void) { int i = -50; int res = 0; int ft_res = 0; while (++i < 200) { res += isascii(i); ft_res += ft_isascii(i); if (res != ft_res) break; } if (i == 200) { ft_putstr("\033[32mAll test OK \033[m"); ft_putstr("\n"); } else { ft_putstr("\033[31mFAIL test "); printf("%d\n", i); ft_putstr("\033[m"); } }
void test_isascii(void) { char *str="ISASCII"; printf("\033[1;33m%s\033[0m\n", str); printf("Mon isascii pour '-1' ->%d\n", ft_isascii(-1)); printf("Le isascii pour '-1' ->%d\n\n", isascii(-1)); printf("Mon isascii pour '0' ->%d\n", ft_isascii(0)); printf("Le isascii pour '0' ->%d\n\n", isascii(0)); printf("Mon isascii pour '42' ->%d\n", ft_isascii(42)); printf("Le isascii pour '42' ->%d\n\n", isascii(42)); printf("Mon isascii pour '127' ->%d\n", ft_isascii(127)); printf("Le isascii pour '127' ->%d\n\n", isascii(127)); printf("Mon isascii pour '128' ->%d\n", ft_isascii(128)); printf("Le isascii pour '128' ->%d\n", isascii(128)); printf("\033[1;32m%s passed.\033[0m\n\n", str); }
static void ft_check_isascii(void) { int i; i = -10; while (++i < 135) printf("Value: %d, Ret: %d\n", i, ft_isascii(i)); }
int test_isascii(void) { int test; int diff; int val; test = -24; diff = 0; printf("---Function #05 : ft_isascii---\n\n"); printf("For this function, in case of a non-null expected result, "); printf("any non-null result is admited\n\n"); while (test < 150) { printf("Input : \\%d\n", test); printf("[R] : %d\n[E] : %d\n\n", ft_isascii(test), isascii(test)); val = ((ft_isascii(test)) ? 1 : 0); diff = ((val != isascii(test))); test++; } return (diff); }
int ft_isprint(int c) { if (ft_isascii(c)) { if (c <= 31 || c == 127) return (0); else return (1); } else return (0); }
int ft_strisascii(const char *str) { int i; i = 0; while (str[i] != '\0') { if (!ft_isascii(str[i])) return (0); } return (1); }
int main() { int a; a = 0; while (a <= 127) { if(isascii(a) != ft_isascii(a)) return(printf("grosse merde")); a++; } return (printf("good")); }
char *ft_strchr(const char *s, int c) { const char *str; str = s; while (*str != (const char)c && ft_isascii(c)) { if (!*str) return (NULL); str++; } s = str; return ((char*)s); }
int is_ascii(char *key) { if (ft_isascii(key[0]) && key[1] == 0 && key[2] == 0 && key[3] == 0) { if (ft_isprint(key[0])) { ascii(key[0]); if (data()->cur == NONE) data()->cur = CURRENT; return (1); } } return (0); }
static int ft_test_isascii2(const char c) { int res; int res2; int res3; res = 0; res2 = ft_isascii(c); res3 = isascii(c) || 0; if (res2 != res3) ++res; printf("Test : \'%c\' (%d) { %d - %d }", c, c, res2, res3); ft_print_status(res); return (res); }
static void test_isascii(void) { int i, test[1024], ctrl[1024]; print_test_name("------------ISACII------------"); i = 0; while (i < 1024) { ctrl[i] = isascii(i); test[i] = ft_isascii(i); ++i; } test_hard(); print_test_results_summary(test, ctrl, 1024); printf("\n"); }
void save_char(t_env *env, int cs, int ret) { char c[2]; int i; i = 0; ft_bzero(c, 2); while (i <= ret) { if (ft_isascii(env->fds[cs].buff_read[i])) { c[0] = env->fds[cs].buff_read[i]; env->fds[cs].save = ft_joinfree(env->fds[cs].save, (char *)c, 1); } i++; } }
int recover_arg(const char *format, t_dbllist *lst_arg, t_dbllist *lst_str, int *i) { int ret; while (format && *i < (int)ft_strlen(format)) { if (format[*i] == '%') { ret = percent(format, lst_arg, lst_str, i); if (ret == -1) return (-1); } else if (*i < (int)ft_strlen(format) && ft_isascii(format[*i])) *i = stock_str(format, *i, lst_str); *i = *i + 1; } return (1); }
void test_isascii() { int t; int a; t = 0; a = -1; while (a <= 129) { if (isascii(a) == ft_isascii(a)) a++; else { print(0); return; } } print(1); }
void test_isascii(void) { printf("\n"); printf("[True tests]\n"); printf("\n"); printf("%s %d\n", "0 est un ASCII ? -", ft_isascii(0)); printf("%s %d\n", "127 est un ASCII ? -", ft_isascii(127)); printf("%s %d\n", "67 est un ASCII ? -", ft_isascii(67)); printf("\n"); printf("[False tests]\n"); printf("\n"); printf("%s %d\n", "-1 est un ASCII ? -", ft_isascii(-1)); printf("%s %d\n", "128 est un ASCII ? -", ft_isascii(128)); printf("%s %d\n", "250 est un ASCII ? -", ft_isascii(250)); }
int ft_atoi(const char *str) { int res; int i; int s; res = 0; i = 0; s = 0; while (str[s] == ' ' || ft_isprint(str[s]) == FALSE) s++; if (str[s] == '+' || str[s] == '-') i++; if (ft_isascii(str[s]) == FALSE) return (0); while (ft_isdigit(str[i + s])) { res = res * 10 + str[i + s] - '0'; i++; } if (str[s] == '-') res = -res; return (res); }
int main() { char *atoistr, *alnum; int atoi_actual, atoi_expected; int actual, expected; char c; // atoi atoistr = "129723"; atoi_actual = ft_atoi(atoistr); atoi_expected = atoi(atoistr); if (atoi_actual == atoi_expected) printf("OK\n"); else printf("atoi ERROR! Expected: %d, actual: %d\n", (int) atoi_expected, (int) atoi_actual); // isalpha c = '1'; actual = ft_isalpha(c); expected = isalpha(c); if (actual == expected) printf("OK\n"); else printf("isalpha ERROR! Expected: %d, actual: %d\n", expected, actual); // isdigit c = 49; actual = ft_isdigit(c); expected = isdigit(c); if (actual == expected) printf("OK\n"); else printf("isdigit ERROR! Expected: %d, actual: %d\n", expected, actual); // isalnum alnum = "lol123rofl90"; for (int i = 0; i < (int) ft_strlen(alnum); i++) { if (ft_isalnum(alnum[i]) != 1) { printf("isalnum ERROR! %c is not alphanumeric!\n", alnum[i]); break ; } } printf("OK\n"); // isascii c = '\n'; actual = ft_isascii(c); expected = isascii(c); if (actual == expected) printf("OK\n"); else printf("isascii ERROR! Expected: %d, actual: %d\n", expected, actual); // isprint c = 'a'; actual = ft_isprint(c); expected = isprint(c); if (expected > 0 && actual > 0) printf("OK\n"); else printf("isprint ERROR! Expected: %d, actual: %d\n", expected, actual); // toupper alnum = "lol123rofl90"; for (int i = 0; i < (int) ft_strlen(alnum); i++) { if (ft_toupper(alnum[i]) != toupper(alnum[i])) { printf("toupper ERROR! at %c\n", alnum[i]); break ; } } printf("OK\n"); // tolower alnum = "LOL123ROFL90"; for (int i = 0; i < (int) ft_strlen(alnum); i++) { if (ft_tolower(alnum[i]) != tolower(alnum[i])) { printf("tolower ERROR! at %c\n", alnum[i]); break ; } } printf("OK\n"); return 0; }
void ft_putchar_fd(char c, int fd) { if (ft_isascii(c)) write(fd, &c, 1); }
int main(void) { int i; i = Lboundary; while (++i < Hboundary) { if (ft_isalnum(i) != isalnum(i)) { printf("ft_isalnum KO for : %d\n", i); printf("Original : %d\n", isalnum(i)); printf("Copy : %d\n", ft_isalnum(i)); break ; } if (i == Hboundary - 1) printf("ft_isalnum OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_isalpha(i) != isalpha(i)) { printf("ft_isalpha KO for : %d\n", i); printf("Original : %d\n", isalpha(i)); printf("Copy : %d\n", ft_isalpha(i)); break ; } if (i == Hboundary - 1) printf("ft_isalpha OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_isascii(i) != isascii(i)) { printf("ft_isascii KO for : %d\n", i); printf("Original : %d\n", isascii(i)); printf("Copy : %d\n", ft_isascii(i)); break ; } if (i == Hboundary - 1) printf("ft_isascii OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_isdigit(i) != isdigit(i)) { printf("ft_isdigit KO for : %d\n", i); printf("Original : %d\n", isdigit(i)); printf("Copy : %d\n", ft_isdigit(i)); break ; } if (i == Hboundary - 1) printf("ft_isdigit OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_isprint(i) != isprint(i)) { printf("KO for : %d\n", i); printf("Original : %d\n", isprint(i)); printf("Copy : %d\n", ft_isprint(i)); break ; } if (i == Hboundary - 1) printf("ft_isprint OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_tolower(i) != tolower(i)) { printf("KO for : %d\n", i); printf("Original : %d\n", tolower(i)); printf("Copy : %d\n", ft_tolower(i)); break ; } if (i == Hboundary - 1) printf("ft_tolower OK\n"); } i = Lboundary; while (++i < Hboundary) { if (ft_toupper(i) != toupper(i)) { printf("KO for : %d\n", i); printf("Original : %d\n", toupper(i)); printf("Copy : %d\n", ft_toupper(i)); break ; } if (i == Hboundary - 1) printf("ft_toupper OK\n"); } }
int main() { int fd; int a = 0; int b = 0; char c = 0; char src[] = "The unterzee does not forgive"; char dst1[100] = {0}; char dst2[100] = {0}; char strputs[] = "Hello"; const char *srcdup = "Hello"; char *dstdup1 = NULL; char *dstdup2 = NULL; strcat(dst1, ""); strcat(dst2, ""); strcat(dst1, src); ft_strcat(dst2, src); printf("strcat : %s\n", dst1); printf("ft_strcat : %s\n", dst2); dstdup1 = strdup(srcdup); printf("strdup : %s\n", dst1); free(dstdup1); dstdup1 = NULL; dstdup2 = ft_strdup(srcdup); printf("ft_strdup : %s\n", dst2); free(dstdup2); dstdup2 = NULL; memset((void*)dst1, 'a', 0); ft_memset((void*)dst2, 'a', 0); printf("memset : %s\n", dst1); printf("ft_memset : %s\n", dst2); bzero((void*)dst1, 15); ft_bzero((void*)dst2, 15); printf("bzero : "); write(1, dst1, 20); printf("\n"); printf("ft_bzero : "); write(1, dst2, 20); printf("\n"); memcpy((void*)dst1, (void*)src, 0); ft_memcpy((void*)dst2, (void*)src, 0); printf("memcpy : %s\n", dst1); printf("ft_memcpy : %s\n", dst2); a = ft_isalpha('p'); printf("ft_isalpha: "); printf("%d\n", a); a = ft_isascii(127); printf("ft_isascii: "); printf("%d\n", a); a = ft_isdigit('p'); printf("ft_isdigit: "); printf("%d\n", a); a = ft_isprint(' '); printf("ft_isprint: "); printf("%d\n", a); a = ft_isalnum('P'); printf("ft_isalnum: "); printf("%d\n", a); c = ft_tolower('A'); printf("ft_tolower: "); printf("%c\n", c); c = ft_toupper('P'); printf("ft_toupper: "); printf("%c\n", c); fd = open("test1.txt", O_RDONLY); ft_cat(fd); a = puts(strputs); b = ft_puts(strputs); printf("puts : "); printf("%d\n", a); printf("ft_puts : "); printf("%d\n", b); return (0); }
int main(int argc, char **argv) { int i; char *str; char *str2; printf("\n-------------------- PART 1 ----------------------------\n"); printf("ft_bzero(str, 2):\n"); str = strdup("coucou"); printf("str avant : %s\n", str); ft_bzero(str, 2); printf("str apres : %s\n", str); printf("\nft_strcat(str1, str2) :\n"); str = malloc(50); ft_bzero(str, 50); ft_strcat(str, "123456789"); printf("str1 : %s\n", str); printf("str2 : coucou \n"); ft_strcat(str, strdup("coucou")); printf("str1 : %s\n", str); printf("\nft_isalpha :\n"); i = ft_isalpha('a'); printf("a : %d\n", i); i = ft_isalpha('^'); printf("^ : %d\n", i); printf("\nft_isdigit :\n"); i = ft_isdigit('2'); printf("2 : %d\n", i); i = ft_isdigit('a'); printf("a : %d\n", i); printf("\nft_isalnum :\n"); i = ft_isalnum('2'); printf("2 : %d\n", i); i = ft_isalnum('a'); printf("a : %d\n", i); i = ft_isalnum(32); printf("' ' : %d\n", i); i = ft_isalnum(59); printf("';' : %d\n", i); i = ft_isalnum(93); printf("']' : %d\n", i); printf("\nft_isascii :\n"); i = ft_isascii('a'); printf("a : %d\n", i); i = ft_isascii(130); printf("%c : %d\n", 130, i); printf("\nft_isprint :\n"); i = ft_isprint(' '); printf("' ' : %d\n", i); i = ft_isprint('\t'); printf("'\t' : %d\n", i); printf("\nft_toupper : \n"); i = ft_toupper('a'); printf("a : %c\n", i); i = ft_toupper('S'); printf("S : %c\n", i); printf("\nft_tolower : \n"); i = ft_tolower('Y'); printf("Y : %c\n", i); i = ft_tolower('b'); printf("b : %c\n", i); printf("\nft_puts : \n"); str = strdup("coucou"); ft_putstr("coucou : "); ft_puts(str); ft_putstr("J'aime bien les chats. : "); str = strdup("J'aime bien les chats."); ft_puts(str); ft_putstr("NULL : "); ft_puts(NULL); printf("\n-------------------- PART 2 ----------------------------\n"); printf("\nft_strlen : \n"); str = strdup("coucou"); i = ft_strlen(str); printf("coucou : %d\n", i); str = strdup("La vie est belle."); i = ft_strlen(str); printf("La vie est belle. : %d\n", i); i = ft_strlen(NULL); printf("NULL : %d\n", i); printf("\nft_memset(str, x, 3) : \n"); str = strdup("coucou"); printf("str avant: %s\n", str); str = ft_memset(str, 'x', 3); printf("str apres: %s\n", str); printf("\nft_memcpy(dest, src, size) :\n"); str = strdup("chatschats chats"); printf("dest : %s\n",str); str2 = strdup("j'aime les frites."); printf("src : %s\n", str2); i = 10; printf("size : %d\n", i); str = ft_memcpy(str, str2, i); printf("dest : %s\n", str); printf("\nft_strdup :\n"); str = ft_strdup("424242"); printf("424242 : %s\n", str); printf("\n-------------------- Bonus ----------------------------\n"); printf("\nft_strndup :\n"); str = ft_strndup("424242", 2); printf("424242, size = 2 : %s\n", str); printf("\nft_isspace :\n"); i = ft_isspace(' '); printf("' ' : %d\n", i); i = ft_isspace('a'); printf("a : %d\n", i); printf("\nft_strncat(str1, str2, size) :\n"); str = malloc(50); ft_bzero(str, 50); ft_strcat(str, "123456789"); printf("str1 : %s\n", str); printf("str2 : coucou \n"); ft_strncat(str, strdup("coucou"), 3); printf("str1 : %s\n", str); printf("\n-------------------- ft_cat(fd) ------------------------\n"); if (argc == 2) i = open(argv[1], O_RDONLY); else i = 0; ft_cat(i); return (0); }
int main(int ac, char **av) { /* * Test ft_puts */ (void)ac; ft_putchar(10); puts("hello"); ft_putchar(10); puts(NULL); ft_putchar(10); ft_puts("hello"); ft_putchar(10); ft_puts(NULL); ft_putchar(10); /* * Test ft_puts */ /* * Test ft_bzero */ char str[] = "hello"; char str2[] = "hello"; printf("\n ft_bzero \n"); printf("Test 1 \n ft_bzero et bzero n = 1 et str : %s\n",str); bzero(str, 1); printf("Avec bzero et str[0] : %c\n",str[0]); ft_bzero(str2, 1); printf("Avec ft_bzero et str2[0] : %c\n",str2[0]); printf("Avec bzero et str[3] : %c\n",str[3]); printf("Avec ft_bzero et str[3] : %c\n\n",str[3]); char str3[] = "hello"; char str4[] = "hello"; printf("Test 2 \n ft_bzero et bzero n = 4 et str : %s\n",str3); bzero(str3, 4); printf("Avec bzero et str[0] : %c\n",str3[0]); ft_bzero(str4, 4); printf("Avec ft_bzero et str2[0] : %c\n",str4[0]); printf("Avec bzero et str[3] : %c\n",str3[3]); printf("Avec ft_bzero et str[3] : %c\n",str4[3]); printf("Avec bzero et str[4] : %c\n",str3[4]); printf("Avec ft_bzero et str[4] : %c\n\n",str4[4]); char str5[] = "hello"; char str6[] = "hello"; printf("Test 3 \n ft_bzero et bzero n = 9 et str : %s\n",str5); bzero(str5, 9); printf("Avec bzero et str[4] : %c\n",str5[4]); ft_bzero(str6, 9); printf("Avec ft_bzero et str2[4] : %c\n",str6[4]); /* * Fin ft_bzero */ /* * ft_strcat */ char *src; char *src2; char *src3; char *src4; char dest[40] = "Please Cat"; char dest2[40] = "Please Cat"; src = "_meEeeeEeeE"; src2 = "_meEeeeEeeE"; printf("\n Test 1 ft_strcat\n"); printf("Dest : %s\nSize Dest: 40\nSrc : %s .\n", dest, src); src3 = strcat(dest, src); printf("strcat Dest : %s\n", src3); src4 = ft_strcat(dest2, src2); printf("ft_strcat Dest : %s\n", src4); printf("\n And Re - ft_strcat\n"); strcat(dest, src); printf("strcat Dest : %s\n", dest); src3 = ft_strcat(dest2, src2); printf("ft_strcat Dest : %s\n", src3); /* * Fin ft_strcat */ /* * ft_isascii */ int a; int z; int nbr; int weird; int neg; neg = -500; a = 'a'; z = 'Z'; nbr = 57; weird = 173; printf("\n\nTest ascii\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",a ,z, nbr, weird, neg); printf("ft_isascii isascii\n"); printf("%d %d\n",ft_isascii(a), isascii(a)); printf("%d %d\n",ft_isascii(z), isascii(z)); printf("%d %d\n",ft_isascii(nbr), isascii(nbr)); printf("%d %d\n",ft_isascii(weird), isascii(weird)); printf("%d %d\n",ft_isascii(neg), isascii(neg)); /*while (neg < 500) { neg++; ft_putchar(ft_isascii(neg) + 48); }*/ /* * Fin ft_isascii */ /* * ft_isalpha */ int b; int y; int nb; int weir; b = 'a'; y = 94; nb = 'Z'; weir = 173; neg = -1; printf("\n\nTest isalpha\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",b ,y, nb, weir,neg); printf("ft_isalpha isalpha\n"); printf("%d %d\n",ft_isalpha(b), isalpha(b)); printf("%d %d\n",ft_isalpha(y), isalpha(y)); printf("%d %d\n",ft_isalpha(nb), isalpha(nb)); printf("%d %d\n",ft_isalpha(weir), isalpha(weir)); printf("%d %d\n",ft_isalpha(neg), isalpha(neg)); /* * Fin ft_isalpha */ /* * ft_isdigit */ int c; int x; int nbt; int weira; c = 47; x = 48; nbt = 57; weira = 58; printf("\n\nTest isdigit\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",c ,x, nbt, weira, neg); printf("ft_isdigit isdigit\n"); printf("%d %d\n",ft_isdigit(c), isdigit(c)); printf("%d %d\n",ft_isdigit(x), isdigit(x)); printf("%d %d\n",ft_isdigit(nbt), isdigit(nbt)); printf("%d %d\n",ft_isdigit(weira), isdigit(weira)); printf("%d %d\n",ft_isdigit(neg), isdigit(neg)); /* * Fin ft_isdigit */ /* * ft_isalnum */ int d; int w; int nbq; int weirb; d = 69; w = 48; nbq = 57; weirb = 92; printf("\n\nTest isalnum\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",d ,w, nbq, weirb, neg); printf("ft_isalnum isalnum\n"); printf("%d %d\n",ft_isalnum(d), isalnum(d)); printf("%d %d\n",ft_isalnum(w), isalnum(w)); printf("%d %d\n",ft_isalnum(nbq), isalnum(nbq)); printf("%d %d\n",ft_isalnum(weirb), isalnum(weirb)); printf("%d %d\n",ft_isalnum(neg), isalnum(neg)); /* * Fin ft_isalnum */ /* * ft_isprint */ int e; int v; int nbs; int weirc; e = 32; v = 126; nbs = 12; weirc = 380; printf("\n\nTest isprint\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg); printf("ft_isprint isprint\n"); printf("%d %d\n",ft_isprint(e), isprint(e)); printf("%d %d\n",ft_isprint(v), isprint(v)); printf("%d %d\n",ft_isprint(nbs), isprint(nbs)); printf("%d %d\n",ft_isprint(weirc), isprint(weirc)); printf("%d %d\n",ft_isprint(neg), isdigit(neg)); /* * Fin ft_isprint */ /* * ft_touppper */ e = 97; v = 122; nbs = 69; weirc = 36; printf("\n\nTest ft_toupper\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg); printf("ft_toupper toupper\n"); printf("%c %c\n",ft_toupper((UC)e), toupper((UC)e)); printf("%c %c\n",ft_toupper(v), toupper(v)); printf("%c %c\n",ft_toupper(nbs), toupper(nbs)); printf("%c %c\n",ft_toupper(weirc), toupper(weirc)); printf("%c %c\n",ft_toupper(neg), toupper(neg)); /* * Fin ft_toupper */ /* * ft_tolower */ e = 65; v = 90; nbs = 122; weirc = 36; printf("\n\nTest ft_tolower\n"); printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg); printf("ft_tolower tolower\n"); printf("%c %c\n",ft_tolower((UC)e), tolower((UC)e)); printf("%c %c\n",ft_tolower(v), tolower(v)); printf("%c %c\n",ft_tolower(nbs), tolower(nbs)); printf("%c %c\n",ft_tolower(weirc), tolower(weirc)); printf("%c %c\n",ft_tolower(neg), tolower(neg)); /* * Fin ft_tolower */ ft_putchar('\n'); int l1; int l2; /* * ft_strlen */ l1 = ft_strlen("yo Mamaa"); ft_putstr("yo Mamaa ft_strlen: "); ft_putchar(l1 + 48); ft_putchar('\n'); l2 = strlen("yo Mamaa"); ft_putstr("yo Mamaa strlen: "); ft_putchar(l2 + 48); ft_putchar('\n'); // l2 = strlen(NULL); // ft_putchar(l2 + 48); // ft_putchar('\n'); l1 = ft_strlen("\n"); ft_putstr(" ft_strlen: "); ft_putchar(l1 + 48); ft_putchar('\n'); l2 = strlen("\n"); ft_putstr(" strlen: "); ft_putchar(l2 + 48); ft_putchar('\n'); /* * Fin ft_strlen */ /* * debut ft_memset */ char *memtmp; char *memtmporg; char *vide; char *videe; printf("\nTEST ft_memset\n"); vide = malloc(sizeof(char *) * 5); memtmporg = malloc(sizeof(char *) * 5); videe = malloc(sizeof(char *) * 5); memtmp = malloc(sizeof(char *) * 5); ft_putstr(memtmporg); ft_putchar('\n'); memset(memtmporg, 'A', 4); ft_putstr(memtmporg); ft_putchar('\n'); ft_memset(memtmp, 'B', 4); ft_putstr(memtmp); ft_putchar('\n'); /* * Fin ft_memset */ /* * debut ft_memcpy */ printf("\nTEST ft_memcpy\n"); memcpy(vide, memtmporg, 2); ft_putstr(vide); ft_putchar('\n'); ft_memcpy(videe, memtmp, 2); ft_putstr(videe); ft_putchar('\n'); /* * fin ft_memcpy */ /* debut ft_strdup * */ char *isdup; char *todup; char *mydup; printf("\nTEST ft_strdup\n"); todup = "Dupme"; isdup = strdup(todup); ft_putstr(isdup); ft_putchar('\n'); mydup = ft_strdup(todup); ft_putstr(mydup); ft_putchar('\n'); /* [M@ft_putchar: debut ft_strdup * */ /* debut ft_cat * */ int fd; printf("\nTEST ft_cat\n"); printf("\n sur 0\n"); ft_cat(0); printf("\n sur ./src/ft_cat.s\n"); fd = open("./src/ft_cat.s", O_RDONLY); ft_cat(fd); close(fd); printf("\n sur -42\n"); ft_cat(-42); printf("\n sur __FILE__\n"); ft_cat(open(__FILE__, O_RDONLY)); printf("\n sur av[0]\n"); ft_cat(open(av[0], O_RDONLY)); /* fin ft_cat * */ return (0); }
void t_isascii(void) { printf("\n----- FT_ISASCII -----\n"); printf("a : %d > %d\n", ft_isascii('a'), isascii('a')); printf("/ : %d > %d\n", ft_isascii('/'), isascii('/')); printf("'4' : %d > %d\n", ft_isascii('4'), isascii('4')); printf("22 : %d > %d\n", ft_isascii(22), isascii(22)); printf("/n : %d > %d\n", ft_isascii('\n'), isascii('\n')); printf("null : %d > %d\n", ft_isascii(0), isascii(0)); printf("10 : %d > %d\n", ft_isascii(10), isascii(10)); printf("127 : %d > %d\n", ft_isascii(127), isascii(127)); printf("130 : %d > %d\n", ft_isascii(130), isascii(130)); printf("-10 : %d > %d\n", ft_isascii(-10), isascii(-10)); printf("%c : %d > %d\n\n", '\200', ft_isascii('\200'), isascii('\200')); }