├── .github └── ISSUE_TEMPLATE │ └── custom.md ├── Makefile ├── README.md ├── SECURITY.md ├── src └── cat_me └── test ├── Additional_functions ├── calloc │ └── test.c ├── ft_strjoin │ └── test.c ├── ft_strtrim │ └── test.c ├── ft_substr │ └── test.c └── strdup │ └── test.c └── Libc_functions ├── atoi └── test.c ├── bzero └── test.c ├── isalnum └── test.c ├── isalpha └── test.c ├── isascii └── test.c ├── isdigit └── test.c ├── isprint └── test.c ├── memchr └── test.c ├── memcmp └── test.c ├── memcpy └── test.c ├── memmove └── test.c ├── memset └── test.c ├── strchr └── test.c ├── strlcat └── test.c ├── strlcpy └── test.c ├── strlen └── test.c ├── strncmp └── test.c ├── strnstr └── test.c ├── strrchr └── test.c ├── tolower └── test.c └── toupper └── test.c /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DIR_LIB_FUN= test/Libc_functions 2 | DIR_LIB_ADD= test/Additional_functions 3 | DIR_LIB_BON= test/Bonus_functions 4 | 5 | CC=cc 6 | CFLAGS= -Wall -Wextra -Werror 7 | LIB= -L src/ -lft 8 | 9 | $(DIR_LIB_FUN)/%/test: $(DIR_LIB_FUN)/%/test.c 10 | @$(CC) $(CFLAGS) $< $(LIB) -o $@ 11 | @./$@ 12 | @rm -f $@ 13 | 14 | $(DIR_LIB_ADD)/%/test: $(DIR_LIB_ADD)/%/test.c 15 | @$(CC) $(CFLAGS) $< $(LIB) -o $@ 16 | @./$@ 17 | @rm -f $@ 18 | 19 | $(DIR_LIB_BON)/%/test: $(DIR_LIB_BON)/%/test.c 20 | @$(CC) $(CFLAGS) $< $(LIB) -o $@ 21 | @./$@ 22 | @rm -f $@ 23 | 24 | .PHONY: test_all 25 | test_all: $(patsubst %/test.c,%/test,$(wildcard $(DIR_LIB_FUN)/*/test.c $(DIR_LIB_ADD)/*/test.c $(DIR_LIB_BON)/*/test.c)) 26 | 27 | .PHONY: ft_tolower 28 | ft_tolower: $(DIR_LIB_FUN)/tolower/test 29 | 30 | .PHONY: ft_toupper 31 | ft_toupper: $(DIR_LIB_FUN)/toupper/test 32 | 33 | .PHONY: ft_isalpha 34 | ft_isalpha: $(DIR_LIB_FUN)/isalpha/test 35 | 36 | .PHONY: ft_isprint 37 | ft_isprint: $(DIR_LIB_FUN)/isprint/test 38 | 39 | .PHONY: ft_strlcat 40 | ft_strlcat: $(DIR_LIB_FUN)/strlcat/test 41 | 42 | .PHONY: ft_memcpy 43 | ft_memcpy: $(DIR_LIB_FUN)/memcpy/test 44 | 45 | .PHONY: ft_bzero 46 | ft_bzero: $(DIR_LIB_FUN)/bzero/test 47 | 48 | .PHONY: ft_memset 49 | ft_memset: $(DIR_LIB_FUN)/memset/test 50 | 51 | .PHONY: ft_strlcpy 52 | ft_strlcpy: $(DIR_LIB_FUN)/strlcpy/test 53 | 54 | .PHONY: ft_strlen 55 | ft_strlen: $(DIR_LIB_FUN)/strlen/test 56 | 57 | .PHONY: ft_memmove 58 | ft_memmove: $(DIR_LIB_FUN)/memmove/test 59 | 60 | .PHONY: ft_isalnum 61 | ft_isalnum: $(DIR_LIB_FUN)/isalnum/test 62 | 63 | .PHONY: ft_strchr 64 | ft_strchr: $(DIR_LIB_FUN)/strchr/test 65 | 66 | .PHONY: ft_strrchr 67 | ft_strrchr: $(DIR_LIB_FUN)/strrchr/test 68 | 69 | .PHONY: ft_strnstr 70 | ft_strnstr: $(DIR_LIB_FUN)/strnstr/test 71 | 72 | .PHONY: ft_isdigit 73 | ft_isdigit: $(DIR_LIB_FUN)/isdigit/test 74 | 75 | .PHONY: ft_memcmp 76 | ft_memcmp: $(DIR_LIB_FUN)/memcmp/test 77 | 78 | .PHONY: ft_memchr 79 | ft_memchr: $(DIR_LIB_FUN)/memchr/test 80 | 81 | .PHONY: ft_atoi 82 | ft_atoi: $(DIR_LIB_FUN)/atoi/test 83 | 84 | .PHONY: ft_strncmp 85 | ft_strncmp: $(DIR_LIB_FUN)/strncmp/test 86 | 87 | .PHONY: ft_strdup 88 | ft_strdup: $(DIR_LIB_ADD)/strdup/test 89 | 90 | .PHONY: ft_calloc 91 | ft_calloc: $(DIR_LIB_ADD)/calloc/test 92 | 93 | .PHONY: ft_substr 94 | ft_substr: $(DIR_LIB_ADD)/ft_substr/test 95 | 96 | .PHONY: ft_strjoin 97 | ft_strjoin: $(DIR_LIB_ADD)/ft_strjoin/test 98 | 99 | .PHONY: ft_strtrim 100 | ft_strtrim: $(DIR_LIB_ADD)/ft_strtrim/test 101 | 102 | .PHONY: Libc_functions 103 | Libc_functions: $(patsubst %/test.c,%/test,$(wildcard $(DIR_LIB_FUN)/*/test.c)) 104 | 105 | .PHONY: Additional_functions 106 | Additional_functions: $(patsubst %/test.c,%/test,$(wildcard $(DIR_LIB_ADD)/*/test.c)) 107 | 108 | .PHONY: bonus_function 109 | bonus_function: $(patsubst %/test.c,%/test,$(wildcard $(DIR_LIB_BON)/*/test.c)) 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libft_tester 2 | tester for libft 42 project 3 | # HOW TO USE THE PROJECTE: 4 | 5 | 1- first you should copy this in your terminal: 6 | ``` 7 | git clone https://github.com/ayoubediri/libft_tester.git 8 | ``` 9 | 2- after that you should copy your libft.a file and libft.h file in src directory 10 | ``` 11 | cp your_path_libft.a src/. 12 | cp your_path_libft.h src/. 13 | ``` 14 | that all. 15 | 16 | after you do the step 2 you can test all your functions by using this command : 17 | ``` 18 | make test_all 19 | ``` 20 | or you can specify one target function by her name : 21 | - example : 22 | ``` 23 | make ft_tolower 24 | ``` 25 | or you can specific one part of the project by this three command : 26 | - for Libc functions part: 27 | ``` 28 | make Libc_functions 29 | ``` 30 | - for Additional functions part 31 | ``` 32 | make Additional_functions 33 | ``` 34 | - for Bonus functions part 35 | ``` 36 | make Bonus_functions 37 | ``` 38 | # THE Project progress: 39 | - Libc functions: 40 | 🆗isalnum 41 | 🆗isascii 42 | 🆗isdigit 43 | 🆗isprint 44 | 🆗tolower 45 | 🆗toupper 46 | 🆗isalpha 47 | 🆗atoi 48 | 🆗strncmp 49 | 🆗strnstr 50 | 🆗strrchr 51 | 🆗strchr 52 | 🆗strlcat 53 | 🆗strlcpy 54 | 🆗strlen 55 | 🆗memset 56 | 🆗bzero 57 | 🆗memcpy 58 | 🆗memccpy 59 | 🆗memmove 60 | 🆗memchr 61 | 🆗memcmp 62 | 63 | 64 | 65 | - Additional functions: 66 | 🆗calloc 67 | 🆗strdup 68 | 🆗ft_substr 69 | 🆗ft_strjoin 70 | 🆗ft_strtrim 71 | ❎ft_split 72 | ❎ft_itoa 73 | ❎ft_strmapi 74 | ❎ft_putchar_fd 75 | ❎ft_putstr_fd 76 | ❎ft_putendl_fd 77 | ❎ft_putnbr_fd 78 | 79 | - Bonus functions: 80 | ❎ft_lstnew 81 | ❎ft_lstadd_front 82 | ❎ft_lstsize 83 | ❎ft_lstlast 84 | ❎ft_lstadd_back 85 | ❎ft_lstdelone 86 | ❎ft_lstclear 87 | ❎ft_lstiter 88 | ❎ft_lstmap 89 | 90 | ![image](https://github.com/user-attachments/assets/de4abd85-4da6-4837-a9e9-0cd7ad8f1964) 91 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /src/cat_me: -------------------------------------------------------------------------------- 1 | her in this dirctory you sholude put your libft.a and libft.h 2 | 3 | cp your_path_libft.a . 4 | 5 | cp your_path_libft.h . 6 | -------------------------------------------------------------------------------- /test/Additional_functions/calloc/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | int test0() 15 | { 16 | printf(YELLOW "==============================================\n" RESET); 17 | printf(YELLOW "= ft_calloc =\n" RESET); 18 | printf(YELLOW "==============================================\n\n" RESET); 19 | printf("[+] THE TEST NUMBER : 0 !!\n"); 20 | printf("[+] WATH WE HAVE :"); 21 | int size = sizeof(char); 22 | int n = 10; 23 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 24 | char *res = calloc(n, size); 25 | char *y_res = ft_calloc(n, size); 26 | if (memcmp(res, y_res, n * size) == 0) 27 | { 28 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 29 | free(res); 30 | free(y_res); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | free(res); 36 | free(y_res); 37 | return (0); 38 | } 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_calloc =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | printf("[+] WATH WE HAVE :"); 46 | int size = sizeof(char *); 47 | int n = 10; 48 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 49 | char *res = calloc(n, size); 50 | char *y_res = ft_calloc(n, size); 51 | if (memcmp(res, y_res, n * size) == 0) 52 | { 53 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 54 | free(res); 55 | free(y_res); 56 | return (1); 57 | } 58 | else 59 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 60 | free(res); 61 | free(y_res); 62 | return (0); 63 | } 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_calloc =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | printf("[+] WATH WE HAVE :"); 71 | int size = sizeof(int); 72 | int n = 0; 73 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 74 | char *res = calloc(n, size); 75 | char *y_res = ft_calloc(n, size); 76 | if (memcmp(res, y_res, n * size) == 0) 77 | { 78 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 79 | free(res); 80 | free(y_res); 81 | return (1); 82 | } 83 | else 84 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 85 | free(res); 86 | free(y_res); 87 | return (0); 88 | } 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_calloc =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : !!\n"); 95 | printf("[+] WATH WE HAVE :"); 96 | int size = sizeof(char); 97 | int n = 1000; 98 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 99 | char *res = calloc(n, size); 100 | char *y_res = ft_calloc(n, size); 101 | if (memcmp(res, y_res, n * size) == 0) 102 | { 103 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 104 | free(res); 105 | free(y_res); 106 | return (1); 107 | } 108 | else 109 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 110 | free(res); 111 | free(y_res); 112 | return (0); 113 | } 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_calloc =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | printf("[+] WATH WE HAVE :"); 121 | int n = 100; 122 | int size = sizeof(int); 123 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 124 | char *res = calloc(n, size); 125 | char *y_res = ft_calloc(n, size); 126 | if (memcmp(res, y_res, n * size) == 0) 127 | { 128 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 129 | free(res); 130 | free(y_res); 131 | return (1); 132 | } 133 | else 134 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 135 | free(res); 136 | free(y_res); 137 | return (0); 138 | } 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_calloc =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | printf("[+] WATH WE HAVE :"); 146 | int n = 888; 147 | int size = sizeof(short); 148 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 149 | char *res = calloc(n, size); 150 | char *y_res = ft_calloc(n, size); 151 | if (memcmp(res, y_res, n * size) == 0) 152 | { 153 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 154 | free(res); 155 | free(y_res); 156 | return (1); 157 | } 158 | else 159 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 160 | free(res); 161 | free(y_res); 162 | return (0); 163 | } 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_calloc =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | printf("[+] WATH WE HAVE :"); 171 | int n = 99; 172 | int size = sizeof(long); 173 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 174 | char *res = calloc(n, size); 175 | char *y_res = ft_calloc(n, size); 176 | if (memcmp(res, y_res, n * size) == 0) 177 | { 178 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 179 | free(res); 180 | free(y_res); 181 | return (1); 182 | } 183 | else 184 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 185 | free(res); 186 | free(y_res); 187 | return (0); 188 | } 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_calloc =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | printf("[+] WATH WE HAVE :"); 196 | int n = 1; 197 | int size = sizeof(char); 198 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 199 | char *res = calloc(n, size); 200 | char *y_res = ft_calloc(n, size); 201 | if (memcmp(res, y_res, n * size) == 0) 202 | { 203 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 204 | free(res); 205 | free(y_res); 206 | return (1); 207 | } 208 | else 209 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 210 | free(res); 211 | free(y_res); 212 | return (0); 213 | } 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_calloc =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | printf("[+] WATH WE HAVE :"); 221 | int n = 444; 222 | int size = sizeof(int); 223 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 224 | char *res = calloc(n, size); 225 | char *y_res = ft_calloc(n, size); 226 | if (memcmp(res, y_res, n * size) == 0) 227 | { 228 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 229 | free(res); 230 | free(y_res); 231 | return (1); 232 | } 233 | else 234 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 235 | free(res); 236 | free(y_res); 237 | return (0); 238 | } 239 | int test9() 240 | { 241 | printf(YELLOW "==============================================\n" RESET); 242 | printf(YELLOW "= ft_calloc =\n" RESET); 243 | printf(YELLOW "==============================================\n\n" RESET); 244 | printf("[+] THE TEST NUMBER : 9 !!\n"); 245 | printf("[+] WATH WE HAVE :"); 246 | int n = 99; 247 | int size = sizeof(short); 248 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 249 | char *res = calloc(n, size); 250 | char *y_res = ft_calloc(n, size); 251 | if (memcmp(res, y_res, n * size) == 0) 252 | { 253 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 254 | free(res); 255 | free(y_res); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | free(res); 261 | free(y_res); 262 | return (0); 263 | } 264 | int test10() 265 | { 266 | printf(YELLOW "==============================================\n" RESET); 267 | printf(YELLOW "= ft_calloc =\n" RESET); 268 | printf(YELLOW "==============================================\n\n" RESET); 269 | printf("[+] THE TEST NUMBER : 10 !!\n"); 270 | printf("[+] WATH WE HAVE :"); 271 | int n = 5; 272 | int size = sizeof(int); 273 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 274 | char *res = calloc(n, size); 275 | char *y_res = ft_calloc(n, size); 276 | if (memcmp(res, y_res, n * size) == 0) 277 | { 278 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 279 | free(res); 280 | free(y_res); 281 | return (1); 282 | } 283 | else 284 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 285 | free(res); 286 | free(y_res); 287 | return (0); 288 | } 289 | int test11() 290 | { 291 | printf(YELLOW "==============================================\n" RESET); 292 | printf(YELLOW "= ft_calloc =\n" RESET); 293 | printf(YELLOW "==============================================\n\n" RESET); 294 | printf("[+] THE TEST NUMBER : 11 !!\n"); 295 | printf("[+] WATH WE HAVE :"); 296 | int n = 00; 297 | int size = sizeof(long); 298 | printf(HEAVENLY "n : [%d] | sizeof : %d\n\n"RESET ,n, size); 299 | char *res = calloc(n, size); 300 | char *y_res = ft_calloc(n, size); 301 | if (memcmp(res, y_res, n * size) == 0) 302 | { 303 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 304 | free(res); 305 | free(y_res); 306 | return (1); 307 | } 308 | else 309 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 310 | free(res); 311 | free(y_res); 312 | return (0); 313 | } 314 | 315 | int main() 316 | { 317 | int c; 318 | c = 0; 319 | int t0 = test0(); 320 | sleep(1); 321 | int t1 = test1(); 322 | sleep(1); 323 | int t2 = test2(); 324 | sleep(1); 325 | int t3 = test3(); 326 | sleep(1); 327 | int t4 = test4(); 328 | sleep(1); 329 | int t5 = test5(); 330 | sleep(1); 331 | int t6 = test6(); 332 | sleep(1); 333 | int t7 = test7(); 334 | sleep(1); 335 | int t8 = test8(); 336 | sleep(1); 337 | int t9 = test9(); 338 | sleep(1); 339 | int t10 = test10(); 340 | sleep(1); 341 | int t11 = test11(); 342 | sleep(1); 343 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 344 | printf(PERPUL "==============================================\n" RESET); 345 | if (c == 12) 346 | { 347 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 348 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 349 | } 350 | else 351 | { 352 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 353 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 354 | } 355 | printf(HEAVENLY "ALL TEST : " RESET); 356 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 357 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 358 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 359 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 360 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 361 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 362 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 363 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 364 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 365 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 366 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 367 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 368 | printf(PERPUL "==============================================\n\n" RESET); 369 | } 370 | -------------------------------------------------------------------------------- /test/Additional_functions/strdup/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | int test0() 15 | { 16 | printf(YELLOW "==============================================\n" RESET); 17 | printf(YELLOW "= ft_strdup =\n" RESET); 18 | printf(YELLOW "==============================================\n\n" RESET); 19 | printf("[+] THE TEST NUMBER : 0 !!\n"); 20 | char test_a[100] = "this string!!"; 21 | printf("[+] WATH WE HAVE :"); 22 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 23 | char *res = strdup(test_a); 24 | printf("[+] WATH SHOULD WE GET :"); 25 | printf(HEAVENLY " %s\n" RESET, res); 26 | char *y_res = ft_strdup(test_a); 27 | printf("[+] WATH YOURS FUNCTOINS GET :"); 28 | printf(HEAVENLY " %s\n\n" RESET, y_res); 29 | if (strcmp(res, y_res) == 0) 30 | { 31 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 32 | free(res); 33 | free(y_res); 34 | return (1); 35 | } 36 | else 37 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 38 | free(res); 39 | free(y_res); 40 | return (0); 41 | } 42 | int test1() 43 | { 44 | printf(YELLOW "==============================================\n" RESET); 45 | printf(YELLOW "= ft_strdup =\n" RESET); 46 | printf(YELLOW "==============================================\n\n" RESET); 47 | printf("[+] THE TEST NUMBER : 1 !!\n"); 48 | char test_a[100] = "and what about this one!!"; 49 | printf("[+] WATH WE HAVE :"); 50 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 51 | char *res = strdup(test_a); 52 | printf("[+] WATH SHOULD WE GET :"); 53 | printf(HEAVENLY " %s\n" RESET, res); 54 | char *y_res = ft_strdup(test_a); 55 | printf("[+] WATH YOURS FUNCTOINS GET :"); 56 | printf(HEAVENLY " %s\n\n" RESET, y_res); 57 | if (strcmp(res, y_res) == 0) 58 | { 59 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 60 | free(res); 61 | free(y_res); 62 | return (1); 63 | } 64 | else 65 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 66 | free(res); 67 | free(y_res); 68 | return (0); 69 | } 70 | int test2() 71 | { 72 | printf(YELLOW "==============================================\n" RESET); 73 | printf(YELLOW "= ft_strdup =\n" RESET); 74 | printf(YELLOW "==============================================\n\n" RESET); 75 | printf("[+] THE TEST NUMBER : 2 !!\n"); 76 | char test_a[100] = ""; 77 | printf("[+] WATH WE HAVE :"); 78 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 79 | char *res = strdup(test_a); 80 | printf("[+] WATH SHOULD WE GET :"); 81 | printf(HEAVENLY " %s\n" RESET, res); 82 | char *y_res = ft_strdup(test_a); 83 | printf("[+] WATH YOURS FUNCTOINS GET :"); 84 | printf(HEAVENLY " %s\n\n" RESET, y_res); 85 | if (strcmp(res, y_res) == 0) 86 | { 87 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 88 | free(res); 89 | free(y_res); 90 | return (1); 91 | } 92 | else 93 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 94 | free(res); 95 | free(y_res); 96 | return (0); 97 | } 98 | int test3() 99 | { 100 | printf(YELLOW "==============================================\n" RESET); 101 | printf(YELLOW "= ft_strdup =\n" RESET); 102 | printf(YELLOW "==============================================\n\n" RESET); 103 | printf("[+] THE TEST NUMBER : !!\n"); 104 | char test_a[100] = "to long string =_="; 105 | printf("[+] WATH WE HAVE :"); 106 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 107 | char *res = strdup(test_a); 108 | printf("[+] WATH SHOULD WE GET :"); 109 | printf(HEAVENLY " %s\n" RESET, res); 110 | char *y_res = ft_strdup(test_a); 111 | printf("[+] WATH YOURS FUNCTOINS GET :"); 112 | printf(HEAVENLY " %s\n\n" RESET, y_res); 113 | if (strcmp(res, y_res) == 0) 114 | { 115 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 116 | free(res); 117 | free(y_res); 118 | return (1); 119 | } 120 | else 121 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 122 | free(res); 123 | free(y_res); 124 | return (0); 125 | } 126 | int test4() 127 | { 128 | printf(YELLOW "==============================================\n" RESET); 129 | printf(YELLOW "= ft_strdup =\n" RESET); 130 | printf(YELLOW "==============================================\n\n" RESET); 131 | printf("[+] THE TEST NUMBER : 4 !!\n"); 132 | char test_a[100] = "1111111111111111!!"; 133 | printf("[+] WATH WE HAVE :"); 134 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 135 | char *res = strdup(test_a); 136 | printf("[+] WATH SHOULD WE GET :"); 137 | printf(HEAVENLY " %s\n" RESET, res); 138 | char *y_res = ft_strdup(test_a); 139 | printf("[+] WATH YOURS FUNCTOINS GET :"); 140 | printf(HEAVENLY " %s\n\n" RESET, y_res); 141 | if (strcmp(res, y_res) == 0) 142 | { 143 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 144 | free(res); 145 | free(y_res); 146 | return (1); 147 | } 148 | else 149 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 150 | free(res); 151 | free(y_res); 152 | return (0); 153 | } 154 | int test5() 155 | { 156 | printf(YELLOW "==============================================\n" RESET); 157 | printf(YELLOW "= ft_strdup =\n" RESET); 158 | printf(YELLOW "==============================================\n\n" RESET); 159 | printf("[+] THE TEST NUMBER : 5 !!\n"); 160 | char test_a[100] = "111111111111111111111111111111111111111111111111111111111111111111!!"; 161 | printf("[+] WATH WE HAVE :"); 162 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 163 | char *res = strdup(test_a); 164 | printf("[+] WATH SHOULD WE GET :"); 165 | printf(HEAVENLY " %s\n" RESET, res); 166 | char *y_res = ft_strdup(test_a); 167 | printf("[+] WATH YOURS FUNCTOINS GET :"); 168 | printf(HEAVENLY " %s\n\n" RESET, y_res); 169 | if (strcmp(res, y_res) == 0) 170 | { 171 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 172 | free(res); 173 | free(y_res); 174 | return (1); 175 | } 176 | else 177 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 178 | free(res); 179 | free(y_res); 180 | return (0); 181 | } 182 | int test6() 183 | { 184 | printf(YELLOW "==============================================\n" RESET); 185 | printf(YELLOW "= ft_strdup =\n" RESET); 186 | printf(YELLOW "==============================================\n\n" RESET); 187 | printf("[+] THE TEST NUMBER : 6 !!\n"); 188 | char test_a[100] = "this easy one"; 189 | printf("[+] WATH WE HAVE :"); 190 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 191 | char *res = strdup(test_a); 192 | printf("[+] WATH SHOULD WE GET :"); 193 | printf(HEAVENLY " %s\n" RESET, res); 194 | char *y_res = ft_strdup(test_a); 195 | printf("[+] WATH YOURS FUNCTOINS GET :"); 196 | printf(HEAVENLY " %s\n\n" RESET, y_res); 197 | if (strcmp(res, y_res) == 0) 198 | { 199 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 200 | free(res); 201 | free(y_res); 202 | return (1); 203 | } 204 | else 205 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 206 | free(res); 207 | free(y_res); 208 | return (0); 209 | } 210 | int test7() 211 | { 212 | printf(YELLOW "==============================================\n" RESET); 213 | printf(YELLOW "= ft_strdup =\n" RESET); 214 | printf(YELLOW "==============================================\n\n" RESET); 215 | printf("[+] THE TEST NUMBER : 7 !!\n"); 216 | char test_a[100] = "hay hay captine !!!!"; 217 | printf("[+] WATH WE HAVE :"); 218 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 219 | char *res = strdup(test_a); 220 | printf("[+] WATH SHOULD WE GET :"); 221 | printf(HEAVENLY " %s\n" RESET, res); 222 | char *y_res = ft_strdup(test_a); 223 | printf("[+] WATH YOURS FUNCTOINS GET :"); 224 | printf(HEAVENLY " %s\n\n" RESET, y_res); 225 | if (strcmp(res, y_res) == 0) 226 | { 227 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 228 | free(res); 229 | free(y_res); 230 | return (1); 231 | } 232 | else 233 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 234 | free(res); 235 | free(y_res); 236 | return (0); 237 | } 238 | int test8() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_strdup =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 8 !!\n"); 244 | char test_a[100] = "can u see what I see"; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 247 | char *res = strdup(test_a); 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %s\n" RESET, res); 250 | char *y_res = ft_strdup(test_a); 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %s\n\n" RESET, y_res); 253 | if (strcmp(res, y_res) == 0) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | free(res); 257 | free(y_res); 258 | return (1); 259 | } 260 | else 261 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 262 | free(res); 263 | free(y_res); 264 | return (0); 265 | } 266 | int test9() 267 | { 268 | printf(YELLOW "==============================================\n" RESET); 269 | printf(YELLOW "= ft_strdup =\n" RESET); 270 | printf(YELLOW "==============================================\n\n" RESET); 271 | printf("[+] THE TEST NUMBER : 9 !!\n"); 272 | char test_a[100] = "one more left"; 273 | printf("[+] WATH WE HAVE :"); 274 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 275 | char *res = strdup(test_a); 276 | printf("[+] WATH SHOULD WE GET :"); 277 | printf(HEAVENLY " %s\n" RESET, res); 278 | char *y_res = ft_strdup(test_a); 279 | printf("[+] WATH YOURS FUNCTOINS GET :"); 280 | printf(HEAVENLY " %s\n\n" RESET, y_res); 281 | if (strcmp(res, y_res) == 0) 282 | { 283 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 284 | free(res); 285 | free(y_res); 286 | return (1); 287 | } 288 | else 289 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 290 | free(res); 291 | free(y_res); 292 | return (0); 293 | } 294 | int test10() 295 | { 296 | printf(YELLOW "==============================================\n" RESET); 297 | printf(YELLOW "= ft_strdup =\n" RESET); 298 | printf(YELLOW "==============================================\n\n" RESET); 299 | printf("[+] THE TEST NUMBER : 10 !!\n"); 300 | char test_a[100] = "why this tests is to long!!"; 301 | printf("[+] WATH WE HAVE :"); 302 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 303 | char *res = strdup(test_a); 304 | printf("[+] WATH SHOULD WE GET :"); 305 | printf(HEAVENLY " %s\n" RESET, res); 306 | char *y_res = ft_strdup(test_a); 307 | printf("[+] WATH YOURS FUNCTOINS GET :"); 308 | printf(HEAVENLY " %s\n\n" RESET, y_res); 309 | if (strcmp(res, y_res) == 0) 310 | { 311 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 312 | free(res); 313 | free(y_res); 314 | return (1); 315 | } 316 | else 317 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 318 | free(res); 319 | free(y_res); 320 | return (0); 321 | } 322 | int test11() 323 | { 324 | printf(YELLOW "==============================================\n" RESET); 325 | printf(YELLOW "= ft_strdup =\n" RESET); 326 | printf(YELLOW "==============================================\n\n" RESET); 327 | printf("[+] THE TEST NUMBER : 11 !!\n"); 328 | char test_a[100] = "My time has come!!"; 329 | printf("[+] WATH WE HAVE :"); 330 | printf(HEAVENLY "str : [%s]\n" RESET, test_a); 331 | char *res = strdup(test_a); 332 | printf("[+] WATH SHOULD WE GET :"); 333 | printf(HEAVENLY " %s\n" RESET, res); 334 | char *y_res = ft_strdup(test_a); 335 | printf("[+] WATH YOURS FUNCTOINS GET :"); 336 | printf(HEAVENLY " %s\n\n" RESET, y_res); 337 | if (strcmp(res, y_res) == 0) 338 | { 339 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 340 | free(res); 341 | free(y_res); 342 | return (1); 343 | } 344 | else 345 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 346 | free(res); 347 | free(y_res); 348 | return (0); 349 | } 350 | 351 | int main() 352 | { 353 | int c; 354 | c = 0; 355 | int t0 = test0(); 356 | sleep(1); 357 | int t1 = test1(); 358 | sleep(1); 359 | int t2 = test2(); 360 | sleep(1); 361 | int t3 = test3(); 362 | sleep(1); 363 | int t4 = test4(); 364 | sleep(1); 365 | int t5 = test5(); 366 | sleep(1); 367 | int t6 = test6(); 368 | sleep(1); 369 | int t7 = test7(); 370 | sleep(1); 371 | int t8 = test8(); 372 | sleep(1); 373 | int t9 = test9(); 374 | sleep(1); 375 | int t10 = test10(); 376 | sleep(1); 377 | int t11 = test11(); 378 | sleep(1); 379 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 380 | printf(PERPUL "==============================================\n" RESET); 381 | if (c == 12) 382 | { 383 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 384 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 385 | } 386 | else 387 | { 388 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 389 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 390 | } 391 | printf(HEAVENLY "ALL TEST : " RESET); 392 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 393 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 394 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 395 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 396 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 397 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 398 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 399 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 400 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 401 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 402 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 403 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 404 | printf(PERPUL "==============================================\n\n" RESET); 405 | } 406 | -------------------------------------------------------------------------------- /test/Libc_functions/atoi/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_atoi =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | char *test = "1234"; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %s\n" RESET, test); 22 | int res = atoi(test) ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_atoi(test); 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_atoi =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | char *test = "-1234"; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %s \n" RESET, test); 48 | int res = atoi(test); 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_atoi(test); 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_atoi =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | char *test = "-0"; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %s \n" RESET, test); 73 | int res = atoi(test); 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_atoi(test); 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_atoi =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : 3 !!\n"); 95 | char *test = "0"; 96 | printf("[+] WATH WE HAVE :"); 97 | printf(HEAVENLY " %s \n" RESET, test); 98 | int res = atoi(test); 99 | printf("[+] WATH SHOULD WE GET :"); 100 | printf(HEAVENLY " %d\n" RESET, res); 101 | int y_res = ft_atoi(test); 102 | printf("[+] WATH YOURS FUNCTOINS GET :"); 103 | printf(HEAVENLY " %d\n\n" RESET, y_res); 104 | if (y_res == res) 105 | { 106 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 107 | return (1); 108 | } 109 | else 110 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 111 | return (0); 112 | } 113 | 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_atoi =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | char *test = "2147483647"; 121 | printf("[+] WATH WE HAVE :"); 122 | printf(HEAVENLY " %s\n" RESET, test); 123 | int res = atoi(test); 124 | printf("[+] WATH SHOULD WE GET :"); 125 | printf(HEAVENLY " %d\n" RESET, res); 126 | int y_res = ft_atoi(test); 127 | printf("[+] WATH YOURS FUNCTOINS GET :"); 128 | printf(HEAVENLY " %d\n\n" RESET, y_res); 129 | if (y_res == res) 130 | { 131 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 132 | return (1); 133 | } 134 | else 135 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 136 | return (0); 137 | } 138 | 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_atoi =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | char *test = "-2147483648"; 146 | printf("[+] WATH WE HAVE :"); 147 | printf(HEAVENLY " %s\n" RESET, test); 148 | int res = atoi(test); 149 | printf("[+] WATH SHOULD WE GET :"); 150 | printf(HEAVENLY " %d\n" RESET, res); 151 | int y_res = ft_atoi(test); 152 | printf("[+] WATH YOURS FUNCTOINS GET :"); 153 | printf(HEAVENLY " %d\n\n" RESET, y_res); 154 | if (y_res == res) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_atoi =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | char *test = "sfqsfq2147483647"; 171 | printf("[+] WATH WE HAVE :"); 172 | printf(HEAVENLY " %s\n" RESET, test); 173 | int res = atoi(test); 174 | printf("[+] WATH SHOULD WE GET :"); 175 | printf(HEAVENLY " %d\n" RESET, res); 176 | int y_res = ft_atoi(test); 177 | printf("[+] WATH YOURS FUNCTOINS GET :"); 178 | printf(HEAVENLY " %d\n\n" RESET, y_res); 179 | if (y_res == res) 180 | { 181 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 182 | return (1); 183 | } 184 | else 185 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 186 | return (0); 187 | } 188 | 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_atoi =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | char *test = "faefa2147483648"; 196 | printf("[+] WATH WE HAVE :"); 197 | printf(HEAVENLY " %s\n" RESET, test); 198 | int res = atoi(test); 199 | printf("[+] WATH SHOULD WE GET :"); 200 | printf(HEAVENLY " %d\n" RESET, res); 201 | int y_res = ft_atoi(test); 202 | printf("[+] WATH YOURS FUNCTOINS GET :"); 203 | printf(HEAVENLY " %d\n\n" RESET, y_res); 204 | if (y_res == res) 205 | { 206 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 207 | return (1); 208 | } 209 | else 210 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 211 | return (0); 212 | } 213 | 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_atoi =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | char *test = "--2147483647"; 221 | printf("[+] WATH WE HAVE :"); 222 | printf(HEAVENLY " %s\n" RESET, test); 223 | int res = atoi(test); 224 | printf("[+] WATH SHOULD WE GET :"); 225 | printf(HEAVENLY " %d\n" RESET, res); 226 | int y_res = ft_atoi(test); 227 | printf("[+] WATH YOURS FUNCTOINS GET :"); 228 | printf(HEAVENLY " %d\n\n" RESET, y_res); 229 | if (y_res == res) 230 | { 231 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 232 | return (1); 233 | } 234 | else 235 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 236 | return (0); 237 | } 238 | int test9() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_atoi =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 9 !!\n"); 244 | char *test = "' ---1234s545'"; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY " %s\n" RESET, test); 247 | int res = atoi(test); 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %d\n" RESET, res); 250 | int y_res = ft_atoi(test); 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %d\n\n" RESET, y_res); 253 | if (y_res == res) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | return (0); 261 | } 262 | int test10() 263 | { 264 | printf(YELLOW "==============================================\n" RESET); 265 | printf(YELLOW "= ft_atoi =\n" RESET); 266 | printf(YELLOW "==============================================\n\n" RESET); 267 | printf("[+] THE TEST NUMBER : 10 !!\n"); 268 | char *test = "214748364+8"; 269 | printf("[+] WATH WE HAVE :"); 270 | printf(HEAVENLY " %s\n" RESET, test); 271 | int res = atoi(test); 272 | printf("[+] WATH SHOULD WE GET :"); 273 | printf(HEAVENLY " %d\n" RESET, res); 274 | int y_res = ft_atoi(test); 275 | printf("[+] WATH YOURS FUNCTOINS GET :"); 276 | printf(HEAVENLY " %d\n\n" RESET, y_res); 277 | if (y_res == res) 278 | { 279 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 280 | return (1); 281 | } 282 | else 283 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 284 | return (0); 285 | } 286 | 287 | int test11() 288 | { 289 | printf(YELLOW "==============================================\n" RESET); 290 | printf(YELLOW "= ft_atoi =\n" RESET); 291 | printf(YELLOW "==============================================\n\n" RESET); 292 | printf("[+] THE TEST NUMBER : 11 !!\n"); 293 | char *test = "-2 147483648"; 294 | printf("[+] WATH WE HAVE :"); 295 | printf(HEAVENLY " %s\n" RESET, test); 296 | int res = atoi(test); 297 | printf("[+] WATH SHOULD WE GET :"); 298 | printf(HEAVENLY " %d\n" RESET, res); 299 | int y_res = ft_atoi(test); 300 | printf("[+] WATH YOURS FUNCTOINS GET :"); 301 | printf(HEAVENLY " %d\n\n" RESET, y_res); 302 | if (y_res == res) 303 | { 304 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 305 | return (1); 306 | } 307 | else 308 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 309 | return (0); 310 | } 311 | 312 | int main() 313 | { 314 | int c; 315 | c = 0; 316 | int t0 = test0(); 317 | sleep(1); 318 | int t1 = test1(); 319 | sleep(1); 320 | int t2 = test2(); 321 | sleep(1); 322 | int t3 = test3(); 323 | sleep(1); 324 | int t4 = test4(); 325 | sleep(1); 326 | int t5 = test5(); 327 | sleep(1); 328 | int t6 = test6(); 329 | sleep(1); 330 | int t7 = test7(); 331 | sleep(1); 332 | int t8 = test8(); 333 | sleep(1); 334 | int t9 = test9(); 335 | sleep(1); 336 | int t10 = test10(); 337 | sleep(1); 338 | int t11 = test11(); 339 | sleep(1); 340 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 341 | printf(PERPUL "==============================================\n" RESET); 342 | if (c == 12) 343 | { 344 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 345 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 346 | } 347 | else 348 | { 349 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 350 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 351 | } 352 | printf(HEAVENLY "ALL TEST : " RESET); 353 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 354 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 355 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 356 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 357 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 358 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 359 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 360 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 361 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 362 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 363 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 364 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 365 | printf(PERPUL "==============================================\n\n" RESET); 366 | } 367 | -------------------------------------------------------------------------------- /test/Libc_functions/isalnum/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_isalnum =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | int test = '0'; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %c\n" RESET, test); 22 | int res = isalnum(test) != 0 ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_isalnum(test) != 0; 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_isalnum =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | int test = '0' - 1; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %c \n" RESET, test); 48 | int res = isalnum(test) != 0; 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_isalnum(test) != 0; 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_isalnum =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | int test = '9'; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %c \n" RESET, test); 73 | int res = isalnum(test) != 0; 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_isalnum(test) != 0; 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_isalnum =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : 3 !!\n"); 95 | int test = '9' + 1; 96 | printf("[+] WATH WE HAVE :"); 97 | printf(HEAVENLY " %c \n" RESET, test); 98 | int res = isalnum(test) != 0; 99 | printf("[+] WATH SHOULD WE GET :"); 100 | printf(HEAVENLY " %d\n" RESET, res); 101 | int y_res = ft_isalnum(test) != 0; 102 | printf("[+] WATH YOURS FUNCTOINS GET :"); 103 | printf(HEAVENLY " %d\n\n" RESET, y_res); 104 | if (y_res == res) 105 | { 106 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 107 | return (1); 108 | } 109 | else 110 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 111 | return (0); 112 | } 113 | 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_isalnum =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | int test = 'a'; 121 | printf("[+] WATH WE HAVE :"); 122 | printf(HEAVENLY " %c\n" RESET, test); 123 | int res = isalnum(test) != 0; 124 | printf("[+] WATH SHOULD WE GET :"); 125 | printf(HEAVENLY " %d\n" RESET, res); 126 | int y_res = ft_isalnum(test) != 0; 127 | printf("[+] WATH YOURS FUNCTOINS GET :"); 128 | printf(HEAVENLY " %d\n\n" RESET, y_res); 129 | if (y_res == res) 130 | { 131 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 132 | return (1); 133 | } 134 | else 135 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 136 | return (0); 137 | } 138 | 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_isalnum =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | int test = 'a' - 1; 146 | printf("[+] WATH WE HAVE :"); 147 | printf(HEAVENLY " %c\n" RESET, test); 148 | int res = isalnum(test) != 0; 149 | printf("[+] WATH SHOULD WE GET :"); 150 | printf(HEAVENLY " %d\n" RESET, res); 151 | int y_res = ft_isalnum(test) != 0; 152 | printf("[+] WATH YOURS FUNCTOINS GET :"); 153 | printf(HEAVENLY " %d\n\n" RESET, y_res); 154 | if (y_res == res) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_isalnum =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | int test = 'z'; 171 | printf("[+] WATH WE HAVE :"); 172 | printf(HEAVENLY " %c\n" RESET, test); 173 | int res = isalnum(test) != 0; 174 | printf("[+] WATH SHOULD WE GET :"); 175 | printf(HEAVENLY " %d\n" RESET, res); 176 | int y_res = ft_isalnum(test) != 0; 177 | printf("[+] WATH YOURS FUNCTOINS GET :"); 178 | printf(HEAVENLY " %d\n\n" RESET, y_res); 179 | if (y_res == res) 180 | { 181 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 182 | return (1); 183 | } 184 | else 185 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 186 | return (0); 187 | } 188 | 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_isalnum =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | int test = 'z' + 1; 196 | printf("[+] WATH WE HAVE :"); 197 | printf(HEAVENLY " %c\n" RESET, test); 198 | int res = isalnum(test) != 0; 199 | printf("[+] WATH SHOULD WE GET :"); 200 | printf(HEAVENLY " %d\n" RESET, res); 201 | int y_res = ft_isalnum(test) != 0; 202 | printf("[+] WATH YOURS FUNCTOINS GET :"); 203 | printf(HEAVENLY " %d\n\n" RESET, y_res); 204 | if (y_res == res) 205 | { 206 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 207 | return (1); 208 | } 209 | else 210 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 211 | return (0); 212 | } 213 | 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_isalnum =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | int test = 'A'; 221 | printf("[+] WATH WE HAVE :"); 222 | printf(HEAVENLY " %c\n" RESET, test); 223 | int res = isalnum(test) != 0; 224 | printf("[+] WATH SHOULD WE GET :"); 225 | printf(HEAVENLY " %d\n" RESET, res); 226 | int y_res = ft_isalnum(test) != 0; 227 | printf("[+] WATH YOURS FUNCTOINS GET :"); 228 | printf(HEAVENLY " %d\n\n" RESET, y_res); 229 | if (y_res == res) 230 | { 231 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 232 | return (1); 233 | } 234 | else 235 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 236 | return (0); 237 | } 238 | int test9() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_isalnum =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 9 !!\n"); 244 | int test = 'A' - 1; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY " %c\n" RESET, test); 247 | int res = isalnum(test) != 0; 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %d\n" RESET, res); 250 | int y_res = ft_isalnum(test) != 0; 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %d\n\n" RESET, y_res); 253 | if (y_res == res) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | return (0); 261 | } 262 | int test10() 263 | { 264 | printf(YELLOW "==============================================\n" RESET); 265 | printf(YELLOW "= ft_isalnum =\n" RESET); 266 | printf(YELLOW "==============================================\n\n" RESET); 267 | printf("[+] THE TEST NUMBER : 10 !!\n"); 268 | int test = 'Z'; 269 | printf("[+] WATH WE HAVE :"); 270 | printf(HEAVENLY " %c\n" RESET, test); 271 | int res = isalnum(test) != 0; 272 | printf("[+] WATH SHOULD WE GET :"); 273 | printf(HEAVENLY " %d\n" RESET, res); 274 | int y_res = ft_isalnum(test) != 0; 275 | printf("[+] WATH YOURS FUNCTOINS GET :"); 276 | printf(HEAVENLY " %d\n\n" RESET, y_res); 277 | if (y_res == res) 278 | { 279 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 280 | return (1); 281 | } 282 | else 283 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 284 | return (0); 285 | } 286 | 287 | int test11() 288 | { 289 | printf(YELLOW "==============================================\n" RESET); 290 | printf(YELLOW "= ft_isalnum =\n" RESET); 291 | printf(YELLOW "==============================================\n\n" RESET); 292 | printf("[+] THE TEST NUMBER : 11 !!\n"); 293 | int test = 'Z' + 1; 294 | printf("[+] WATH WE HAVE :"); 295 | printf(HEAVENLY " %c\n" RESET, test); 296 | int res = isalnum(test) != 0; 297 | printf("[+] WATH SHOULD WE GET :"); 298 | printf(HEAVENLY " %d\n" RESET, res); 299 | int y_res = ft_isalnum(test) != 0; 300 | printf("[+] WATH YOURS FUNCTOINS GET :"); 301 | printf(HEAVENLY " %d\n\n" RESET, y_res); 302 | if (y_res == res) 303 | { 304 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 305 | return (1); 306 | } 307 | else 308 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 309 | return (0); 310 | } 311 | 312 | int main() 313 | { 314 | int c; 315 | c = 0; 316 | int t0 = test0(); 317 | sleep(1); 318 | int t1 = test1(); 319 | sleep(1); 320 | int t2 = test2(); 321 | sleep(1); 322 | int t3 = test3(); 323 | sleep(1); 324 | int t4 = test4(); 325 | sleep(1); 326 | int t5 = test5(); 327 | sleep(1); 328 | int t6 = test6(); 329 | sleep(1); 330 | int t7 = test7(); 331 | sleep(1); 332 | int t8 = test8(); 333 | sleep(1); 334 | int t9 = test9(); 335 | sleep(1); 336 | int t10 = test10(); 337 | sleep(1); 338 | int t11 = test11(); 339 | sleep(1); 340 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 341 | printf(PERPUL "==============================================\n" RESET); 342 | if (c == 12) 343 | { 344 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 345 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 346 | } 347 | else 348 | { 349 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 350 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 351 | } 352 | printf(HEAVENLY "ALL TEST : " RESET); 353 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 354 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 355 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 356 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 357 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 358 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 359 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 360 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 361 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 362 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 363 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 364 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 365 | printf(PERPUL "==============================================\n\n" RESET); 366 | } 367 | -------------------------------------------------------------------------------- /test/Libc_functions/isalpha/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_isalpha =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | int test = 'A'; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %c\n" RESET, test); 22 | int res = isalpha(test) != 0 ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_isalpha(test) != 0; 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_isalpha =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | int test = 'A' - 1; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %c \n" RESET, test); 48 | int res = isalpha(test) != 0; 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_isalpha(test) != 0; 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_isalpha =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | int test = 'Z'; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %c \n" RESET, test); 73 | int res = isalpha(test) != 0; 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_isalpha(test) != 0; 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_isalpha =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : 3 !!\n"); 95 | int test = 'Z' + 1; 96 | printf("[+] WATH WE HAVE :"); 97 | printf(HEAVENLY " %c \n" RESET, test); 98 | int res = isalpha(test) != 0; 99 | printf("[+] WATH SHOULD WE GET :"); 100 | printf(HEAVENLY " %d\n" RESET, res); 101 | int y_res = ft_isalpha(test) != 0; 102 | printf("[+] WATH YOURS FUNCTOINS GET :"); 103 | printf(HEAVENLY " %d\n\n" RESET, y_res); 104 | if (y_res == res) 105 | { 106 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 107 | return (1); 108 | } 109 | else 110 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 111 | return (0); 112 | } 113 | 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_isalpha =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | int test = 'a'; 121 | printf("[+] WATH WE HAVE :"); 122 | printf(HEAVENLY " %c\n" RESET, test); 123 | int res = isalpha(test) != 0; 124 | printf("[+] WATH SHOULD WE GET :"); 125 | printf(HEAVENLY " %d\n" RESET, res); 126 | int y_res = ft_isalpha(test) != 0; 127 | printf("[+] WATH YOURS FUNCTOINS GET :"); 128 | printf(HEAVENLY " %d\n\n" RESET, y_res); 129 | if (y_res == res) 130 | { 131 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 132 | return (1); 133 | } 134 | else 135 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 136 | return (0); 137 | } 138 | 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_isalpha =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | int test = 'a' - 1; 146 | printf("[+] WATH WE HAVE :"); 147 | printf(HEAVENLY " %c\n" RESET, test); 148 | int res = isalpha(test) != 0; 149 | printf("[+] WATH SHOULD WE GET :"); 150 | printf(HEAVENLY " %d\n" RESET, res); 151 | int y_res = ft_isalpha(test) != 0; 152 | printf("[+] WATH YOURS FUNCTOINS GET :"); 153 | printf(HEAVENLY " %d\n\n" RESET, y_res); 154 | if (y_res == res) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_isalpha =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | int test = 'z'; 171 | printf("[+] WATH WE HAVE :"); 172 | printf(HEAVENLY " %c\n" RESET, test); 173 | int res = isalpha(test) != 0; 174 | printf("[+] WATH SHOULD WE GET :"); 175 | printf(HEAVENLY " %d\n" RESET, res); 176 | int y_res = ft_isalpha(test) != 0; 177 | printf("[+] WATH YOURS FUNCTOINS GET :"); 178 | printf(HEAVENLY " %d\n\n" RESET, y_res); 179 | if (y_res == res) 180 | { 181 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 182 | return (1); 183 | } 184 | else 185 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 186 | return (0); 187 | } 188 | 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_isalpha =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | int test = 'z' + 1; 196 | printf("[+] WATH WE HAVE :"); 197 | printf(HEAVENLY " %c\n" RESET, test); 198 | int res = isalpha(test) != 0; 199 | printf("[+] WATH SHOULD WE GET :"); 200 | printf(HEAVENLY " %d\n" RESET, res); 201 | int y_res = ft_isalpha(test) != 0; 202 | printf("[+] WATH YOURS FUNCTOINS GET :"); 203 | printf(HEAVENLY " %d\n\n" RESET, y_res); 204 | if (y_res == res) 205 | { 206 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 207 | return (1); 208 | } 209 | else 210 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 211 | return (0); 212 | } 213 | 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_isalpha =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | int test = '0'; 221 | printf("[+] WATH WE HAVE :"); 222 | printf(HEAVENLY " %c\n" RESET, test); 223 | int res = isalpha(test) != 0; 224 | printf("[+] WATH SHOULD WE GET :"); 225 | printf(HEAVENLY " %d\n" RESET, res); 226 | int y_res = ft_isalpha(test) != 0; 227 | printf("[+] WATH YOURS FUNCTOINS GET :"); 228 | printf(HEAVENLY " %d\n\n" RESET, y_res); 229 | if (y_res == res) 230 | { 231 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 232 | return (1); 233 | } 234 | else 235 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 236 | return (0); 237 | } 238 | int test9() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_isalpha =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 9 !!\n"); 244 | int test = -1; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY " %d (intger form)\n" RESET, test); 247 | int res = isalpha(test) != 0; 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %d\n" RESET, res); 250 | int y_res = ft_isalpha(test) != 0; 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %d\n\n" RESET, y_res); 253 | if (y_res == res) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | return (0); 261 | } 262 | int test10() 263 | { 264 | printf(YELLOW "==============================================\n" RESET); 265 | printf(YELLOW "= ft_isalpha =\n" RESET); 266 | printf(YELLOW "==============================================\n\n" RESET); 267 | printf("[+] THE TEST NUMBER : 10 !!\n"); 268 | int test = 0; 269 | printf("[+] WATH WE HAVE :"); 270 | printf(HEAVENLY " %d (intger form)\n" RESET, test); 271 | int res = isalpha(test) != 0; 272 | printf("[+] WATH SHOULD WE GET :"); 273 | printf(HEAVENLY " %d\n" RESET, res); 274 | int y_res = ft_isalpha(test) != 0; 275 | printf("[+] WATH YOURS FUNCTOINS GET :"); 276 | printf(HEAVENLY " %d\n\n" RESET, y_res); 277 | if (y_res == res) 278 | { 279 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 280 | return (1); 281 | } 282 | else 283 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 284 | return (0); 285 | } 286 | 287 | int test11() 288 | { 289 | printf(YELLOW "==============================================\n" RESET); 290 | printf(YELLOW "= ft_isalpha =\n" RESET); 291 | printf(YELLOW "==============================================\n\n" RESET); 292 | printf("[+] THE TEST NUMBER : 11 !!\n"); 293 | int test = 'Z' + 1; 294 | printf("[+] WATH WE HAVE :"); 295 | printf(HEAVENLY " %c\n" RESET, test); 296 | int res = isalpha(test) != 0; 297 | printf("[+] WATH SHOULD WE GET :"); 298 | printf(HEAVENLY " %d\n" RESET, res); 299 | int y_res = ft_isalpha(test) != 0; 300 | printf("[+] WATH YOURS FUNCTOINS GET :"); 301 | printf(HEAVENLY " %d\n\n" RESET, y_res); 302 | if (y_res == res) 303 | { 304 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 305 | return (1); 306 | } 307 | else 308 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 309 | return (0); 310 | } 311 | 312 | int main() 313 | { 314 | int c; 315 | c = 0; 316 | int t0 = test0(); 317 | sleep(1); 318 | int t1 = test1(); 319 | sleep(1); 320 | int t2 = test2(); 321 | sleep(1); 322 | int t3 = test3(); 323 | sleep(1); 324 | int t4 = test4(); 325 | sleep(1); 326 | int t5 = test5(); 327 | sleep(1); 328 | int t6 = test6(); 329 | sleep(1); 330 | int t7 = test7(); 331 | sleep(1); 332 | int t8 = test8(); 333 | sleep(1); 334 | int t9 = test9(); 335 | sleep(1); 336 | int t10 = test10(); 337 | sleep(1); 338 | int t11 = test11(); 339 | sleep(1); 340 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 341 | printf(PERPUL "==============================================\n" RESET); 342 | if (c == 12) 343 | { 344 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 345 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 346 | } 347 | else 348 | { 349 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 350 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 351 | } 352 | printf(HEAVENLY "ALL TEST : " RESET); 353 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 354 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 355 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 356 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 357 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 358 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 359 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 360 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 361 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 362 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 363 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 364 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 365 | printf(PERPUL "==============================================\n\n" RESET); 366 | } 367 | -------------------------------------------------------------------------------- /test/Libc_functions/isascii/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_isascii =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | int test = -1; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %d (in intger form)\n" RESET, test); 22 | int res = isascii(test) != 0 ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_isascii(test) != 0; 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_isascii =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | int test = 200; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %d (in intger form) \n" RESET, test); 48 | int res = isascii(test) != 0; 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_isascii(test) != 0; 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_isascii =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | int test = 127; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %d (in intger form) \n" RESET, test); 73 | int res = isascii(test) != 0; 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_isascii(test) != 0; 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | int test3() 89 | { 90 | printf(YELLOW "==============================================\n" RESET); 91 | printf(YELLOW "= ft_isascii =\n" RESET); 92 | printf(YELLOW "==============================================\n\n" RESET); 93 | printf("[+] THE TEST NUMBER : 3 !!\n"); 94 | int test = 128; 95 | printf("[+] WATH WE HAVE :"); 96 | printf(HEAVENLY " %d (in intger form) \n" RESET, test); 97 | int res = isascii(test) != 0; 98 | printf("[+] WATH SHOULD WE GET :"); 99 | printf(HEAVENLY " %d\n" RESET, res); 100 | int y_res = ft_isascii(test) != 0; 101 | printf("[+] WATH YOURS FUNCTOINS GET :"); 102 | printf(HEAVENLY " %d\n\n" RESET, y_res); 103 | if (y_res == res) 104 | { 105 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 106 | return (1); 107 | } 108 | else 109 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 110 | return (0); 111 | } 112 | int test4() 113 | { 114 | printf(YELLOW "==============================================\n" RESET); 115 | printf(YELLOW "= ft_isascii =\n" RESET); 116 | printf(YELLOW "==============================================\n\n" RESET); 117 | printf("[+] THE TEST NUMBER : 4 !!\n"); 118 | int test = 0; 119 | printf("[+] WATH WE HAVE :"); 120 | printf(HEAVENLY " %d (in intger form)\n" RESET, test); 121 | int res = isascii(test) != 0; 122 | printf("[+] WATH SHOULD WE GET :"); 123 | printf(HEAVENLY " %d\n" RESET, res); 124 | int y_res = ft_isascii(test) != 0; 125 | printf("[+] WATH YOURS FUNCTOINS GET :"); 126 | printf(HEAVENLY " %d\n\n" RESET, y_res); 127 | if (y_res == res) 128 | { 129 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 130 | return (1); 131 | } 132 | else 133 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 134 | return (0); 135 | } 136 | int test5() 137 | { 138 | printf(YELLOW "==============================================\n" RESET); 139 | printf(YELLOW "= ft_isascii =\n" RESET); 140 | printf(YELLOW "==============================================\n\n" RESET); 141 | printf("[+] THE TEST NUMBER : 5 !!\n"); 142 | int test = 4000; 143 | printf("[+] WATH WE HAVE :"); 144 | printf(HEAVENLY " %d (in intger form)\n" RESET, test); 145 | int res = isascii(test) != 0; 146 | printf("[+] WATH SHOULD WE GET :"); 147 | printf(HEAVENLY " %d\n" RESET, res); 148 | int y_res = ft_isascii(test) != 0; 149 | printf("[+] WATH YOURS FUNCTOINS GET :"); 150 | printf(HEAVENLY " %d\n\n" RESET, y_res); 151 | if (y_res == res) 152 | { 153 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 154 | return (1); 155 | } 156 | else 157 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 158 | return (0); 159 | } 160 | 161 | int main() 162 | { 163 | int c; 164 | c = 0; 165 | int t0 = test0(); 166 | sleep(1); 167 | int t1 = test1(); 168 | sleep(1); 169 | int t2 = test2(); 170 | sleep(1); 171 | int t3 = test3(); 172 | sleep(1); 173 | int t4 = test4(); 174 | sleep(1); 175 | int t5 = test5(); 176 | sleep(1); 177 | c = t0 + t1 + t2 + t3 + t4 + t5; 178 | printf(PERPUL "==============================================\n" RESET); 179 | if (c == 6) 180 | { 181 | printf(GREEN "THE RESULTE IS : [%d/6]\n",c); 182 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 183 | } 184 | else 185 | { 186 | printf(RED "THE RESULTE IS : [%d/6]\n",c); 187 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 188 | } 189 | printf(HEAVENLY "ALL TEST : " RESET); 190 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 191 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 192 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 193 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 194 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 195 | ((t5 == 0)? printf(RED "TEST5" RESET ".\n") : printf(GREEN "TEST5" RESET ".\n")); 196 | printf(PERPUL "==============================================\n\n" RESET); 197 | } 198 | -------------------------------------------------------------------------------- /test/Libc_functions/isdigit/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_isdigit =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | int test = '0'; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %c\n" RESET, test); 22 | int res = isdigit(test) != 0 ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_isdigit(test) != 0; 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_isdigit =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | int test = '0' - 1; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %c \n" RESET, test); 48 | int res = isdigit(test) != 0; 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_isdigit(test) != 0; 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_isdigit =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | int test = '9'; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %c \n" RESET, test); 73 | int res = isdigit(test) != 0; 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_isdigit(test) != 0; 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_isdigit =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : 3 !!\n"); 95 | int test = '9' + 1; 96 | printf("[+] WATH WE HAVE :"); 97 | printf(HEAVENLY " %c \n" RESET, test); 98 | int res = isdigit(test) != 0; 99 | printf("[+] WATH SHOULD WE GET :"); 100 | printf(HEAVENLY " %d\n" RESET, res); 101 | int y_res = ft_isdigit(test) != 0; 102 | printf("[+] WATH YOURS FUNCTOINS GET :"); 103 | printf(HEAVENLY " %d\n\n" RESET, y_res); 104 | if (y_res == res) 105 | { 106 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 107 | return (1); 108 | } 109 | else 110 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 111 | return (0); 112 | } 113 | 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_isdigit =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | int test = 'a'; 121 | printf("[+] WATH WE HAVE :"); 122 | printf(HEAVENLY " %c\n" RESET, test); 123 | int res = isdigit(test) != 0; 124 | printf("[+] WATH SHOULD WE GET :"); 125 | printf(HEAVENLY " %d\n" RESET, res); 126 | int y_res = ft_isdigit(test) != 0; 127 | printf("[+] WATH YOURS FUNCTOINS GET :"); 128 | printf(HEAVENLY " %d\n\n" RESET, y_res); 129 | if (y_res == res) 130 | { 131 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 132 | return (1); 133 | } 134 | else 135 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 136 | return (0); 137 | } 138 | 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_isdigit =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | int test = '5'; 146 | printf("[+] WATH WE HAVE :"); 147 | printf(HEAVENLY " %c\n" RESET, test); 148 | int res = isdigit(test) != 0; 149 | printf("[+] WATH SHOULD WE GET :"); 150 | printf(HEAVENLY " %d\n" RESET, res); 151 | int y_res = ft_isdigit(test) != 0; 152 | printf("[+] WATH YOURS FUNCTOINS GET :"); 153 | printf(HEAVENLY " %d\n\n" RESET, y_res); 154 | if (y_res == res) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_isdigit =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | int test = 'z'; 171 | printf("[+] WATH WE HAVE :"); 172 | printf(HEAVENLY " %c\n" RESET, test); 173 | int res = isdigit(test) != 0; 174 | printf("[+] WATH SHOULD WE GET :"); 175 | printf(HEAVENLY " %d\n" RESET, res); 176 | int y_res = ft_isdigit(test) != 0; 177 | printf("[+] WATH YOURS FUNCTOINS GET :"); 178 | printf(HEAVENLY " %d\n\n" RESET, y_res); 179 | if (y_res == res) 180 | { 181 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 182 | return (1); 183 | } 184 | else 185 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 186 | return (0); 187 | } 188 | 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_isdigit =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | int test = 'z' + 1; 196 | printf("[+] WATH WE HAVE :"); 197 | printf(HEAVENLY " %c\n" RESET, test); 198 | int res = isdigit(test) != 0; 199 | printf("[+] WATH SHOULD WE GET :"); 200 | printf(HEAVENLY " %d\n" RESET, res); 201 | int y_res = ft_isdigit(test) != 0; 202 | printf("[+] WATH YOURS FUNCTOINS GET :"); 203 | printf(HEAVENLY " %d\n\n" RESET, y_res); 204 | if (y_res == res) 205 | { 206 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 207 | return (1); 208 | } 209 | else 210 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 211 | return (0); 212 | } 213 | 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_isdigit =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | int test = 'A'; 221 | printf("[+] WATH WE HAVE :"); 222 | printf(HEAVENLY " %c\n" RESET, test); 223 | int res = isdigit(test) != 0; 224 | printf("[+] WATH SHOULD WE GET :"); 225 | printf(HEAVENLY " %d\n" RESET, res); 226 | int y_res = ft_isdigit(test) != 0; 227 | printf("[+] WATH YOURS FUNCTOINS GET :"); 228 | printf(HEAVENLY " %d\n\n" RESET, y_res); 229 | if (y_res == res) 230 | { 231 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 232 | return (1); 233 | } 234 | else 235 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 236 | return (0); 237 | } 238 | int test9() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_isdigit =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 9 !!\n"); 244 | int test = '3' - 1; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY " %c\n" RESET, test); 247 | int res = isdigit(test) != 0; 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %d\n" RESET, res); 250 | int y_res = ft_isdigit(test) != 0; 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %d\n\n" RESET, y_res); 253 | if (y_res == res) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | return (0); 261 | } 262 | int test10() 263 | { 264 | printf(YELLOW "==============================================\n" RESET); 265 | printf(YELLOW "= ft_isdigit =\n" RESET); 266 | printf(YELLOW "==============================================\n\n" RESET); 267 | printf("[+] THE TEST NUMBER : 10 !!\n"); 268 | int test = '8'; 269 | printf("[+] WATH WE HAVE :"); 270 | printf(HEAVENLY " %c\n" RESET, test); 271 | int res = isdigit(test) != 0; 272 | printf("[+] WATH SHOULD WE GET :"); 273 | printf(HEAVENLY " %d\n" RESET, res); 274 | int y_res = ft_isdigit(test) != 0; 275 | printf("[+] WATH YOURS FUNCTOINS GET :"); 276 | printf(HEAVENLY " %d\n\n" RESET, y_res); 277 | if (y_res == res) 278 | { 279 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 280 | return (1); 281 | } 282 | else 283 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 284 | return (0); 285 | } 286 | 287 | int test11() 288 | { 289 | printf(YELLOW "==============================================\n" RESET); 290 | printf(YELLOW "= ft_isdigit =\n" RESET); 291 | printf(YELLOW "==============================================\n\n" RESET); 292 | printf("[+] THE TEST NUMBER : 11 !!\n"); 293 | int test = 'Z' + 1; 294 | printf("[+] WATH WE HAVE :"); 295 | printf(HEAVENLY " %c\n" RESET, test); 296 | int res = isdigit(test) != 0; 297 | printf("[+] WATH SHOULD WE GET :"); 298 | printf(HEAVENLY " %d\n" RESET, res); 299 | int y_res = ft_isdigit(test) != 0; 300 | printf("[+] WATH YOURS FUNCTOINS GET :"); 301 | printf(HEAVENLY " %d\n\n" RESET, y_res); 302 | if (y_res == res) 303 | { 304 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 305 | return (1); 306 | } 307 | else 308 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 309 | return (0); 310 | } 311 | 312 | int main() 313 | { 314 | int c; 315 | c = 0; 316 | int t0 = test0(); 317 | sleep(1); 318 | int t1 = test1(); 319 | sleep(1); 320 | int t2 = test2(); 321 | sleep(1); 322 | int t3 = test3(); 323 | sleep(1); 324 | int t4 = test4(); 325 | sleep(1); 326 | int t5 = test5(); 327 | sleep(1); 328 | int t6 = test6(); 329 | sleep(1); 330 | int t7 = test7(); 331 | sleep(1); 332 | int t8 = test8(); 333 | sleep(1); 334 | int t9 = test9(); 335 | sleep(1); 336 | int t10 = test10(); 337 | sleep(1); 338 | int t11 = test11(); 339 | sleep(1); 340 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 341 | printf(PERPUL "==============================================\n" RESET); 342 | if (c == 12) 343 | { 344 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 345 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 346 | } 347 | else 348 | { 349 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 350 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 351 | } 352 | printf(HEAVENLY "ALL TEST : " RESET); 353 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 354 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 355 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 356 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 357 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 358 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 359 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 360 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 361 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 362 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 363 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 364 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 365 | printf(PERPUL "==============================================\n\n" RESET); 366 | } 367 | -------------------------------------------------------------------------------- /test/Libc_functions/isprint/test.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* test.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ayoub +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2024/09/20 20:49:44 by ayoub #+# #+# */ 9 | /* Updated: 2024/09/21 17:02:25 by ayoub ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include "../../../src/libft.h" 17 | 18 | #define RED "\033[0;31m" 19 | #define GREEN "\033[0;32m" 20 | #define RESET "\033[0m" 21 | #define YELLOW "\033[0;33m" 22 | #define HEAVENLY "\033[0;36m" 23 | #define PERPUL "\033[0;35m" 24 | 25 | int test0() 26 | { 27 | printf(YELLOW "==============================================\n" RESET); 28 | printf(YELLOW "= ft_isprint =\n" RESET); 29 | printf(YELLOW "==============================================\n\n" RESET); 30 | printf("[+] THE TEST NUMBER : 0 !!\n"); 31 | int test = 'a'; 32 | printf("[+] WATH WE HAVE :"); 33 | printf(HEAVENLY " %c\n" RESET, test); 34 | int res = isprint(test) != 0; 35 | printf("[+] WATH SHOULD WE GET :"); 36 | printf(HEAVENLY " %d\n" RESET, res); 37 | int y_res = ft_isprint(test) != 0; 38 | printf("[+] WATH YOURS FUNCTOINS GET :"); 39 | printf(HEAVENLY " %d\n\n" RESET, y_res); 40 | if (y_res == res) 41 | { 42 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 43 | return (1); 44 | } 45 | else 46 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 47 | return (0); 48 | } 49 | 50 | 51 | int test1() 52 | { 53 | printf(YELLOW "==============================================\n" RESET); 54 | printf(YELLOW "= ft_isprint =\n" RESET); 55 | printf(YELLOW "==============================================\n\n" RESET); 56 | printf("[+] THE TEST NUMBER : 1 !!\n"); 57 | int test = 31; 58 | printf("[+] WATH WE HAVE :"); 59 | printf(HEAVENLY " %c\n" RESET, test); 60 | int res = isprint(test) != 0; 61 | printf("[+] WATH SHOULD WE GET :"); 62 | printf(HEAVENLY " %d\n" RESET, res); 63 | int y_res = ft_isprint(test) != 0; 64 | printf("[+] WATH YOURS FUNCTOINS GET :"); 65 | printf(HEAVENLY " %d\n\n" RESET, y_res); 66 | if (y_res == res) 67 | { 68 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 69 | return (1); 70 | } 71 | else 72 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 73 | return (0); 74 | } 75 | 76 | int test2() 77 | { 78 | printf(YELLOW "==============================================\n" RESET); 79 | printf(YELLOW "= ft_isprint =\n" RESET); 80 | printf(YELLOW "==============================================\n\n" RESET); 81 | printf("[+] THE TEST NUMBER : 2 !!\n"); 82 | int test = 200; 83 | printf("[+] WATH WE HAVE :"); 84 | printf(HEAVENLY " %c\n" RESET, test); 85 | int res = isprint(test) != 0; 86 | printf("[+] WATH SHOULD WE GET :"); 87 | printf(HEAVENLY " %d\n" RESET, res); 88 | int y_res = ft_isprint(test) != 0; 89 | printf("[+] WATH YOURS FUNCTOINS GET :"); 90 | printf(HEAVENLY " %d\n\n" RESET, y_res); 91 | if (y_res == res) 92 | { 93 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 94 | return (1); 95 | } 96 | else 97 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 98 | return (0); 99 | } 100 | int test3() 101 | { 102 | printf(YELLOW "==============================================\n" RESET); 103 | printf(YELLOW "= ft_isprint =\n" RESET); 104 | printf(YELLOW "==============================================\n\n" RESET); 105 | printf("[+] THE TEST NUMBER : 3 !!\n"); 106 | int test = 127; 107 | printf("[+] WATH WE HAVE :"); 108 | printf(HEAVENLY " %c\n" RESET, test); 109 | int res = isprint(test) != 0; 110 | printf("[+] WATH SHOULD WE GET :"); 111 | printf(HEAVENLY " %d\n" RESET, res); 112 | int y_res = ft_isprint(test) != 0; 113 | printf("[+] WATH YOURS FUNCTOINS GET :"); 114 | printf(HEAVENLY " %d\n\n" RESET, y_res); 115 | if (y_res == res) 116 | { 117 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 118 | return (1); 119 | } 120 | else 121 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 122 | return (0); 123 | } 124 | int test4() 125 | { 126 | printf(YELLOW "==============================================\n" RESET); 127 | printf(YELLOW "= ft_isprint =\n" RESET); 128 | printf(YELLOW "==============================================\n\n" RESET); 129 | printf("[+] THE TEST NUMBER : 4 !!\n"); 130 | int test = 126; 131 | printf("[+] WATH WE HAVE :"); 132 | printf(HEAVENLY " %c\n" RESET, test); 133 | int res = isprint(test) != 0; 134 | printf("[+] WATH SHOULD WE GET :"); 135 | printf(HEAVENLY " %d\n" RESET, res); 136 | int y_res = ft_isprint(test) != 0; 137 | printf("[+] WATH YOURS FUNCTOINS GET :"); 138 | printf(HEAVENLY " %d\n\n" RESET, y_res); 139 | if (y_res == res) 140 | { 141 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 142 | return (1); 143 | } 144 | else 145 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 146 | return (0); 147 | } 148 | int test5() 149 | { 150 | printf(YELLOW "==============================================\n" RESET); 151 | printf(YELLOW "= ft_isprint =\n" RESET); 152 | printf(YELLOW "==============================================\n\n" RESET); 153 | printf("[+] THE TEST NUMBER : 5 !!\n"); 154 | int test = ' '; 155 | printf("[+] WATH WE HAVE :"); 156 | printf(HEAVENLY " %c\n" RESET, test); 157 | int res = isprint(test) != 0; 158 | printf("[+] WATH SHOULD WE GET :"); 159 | printf(HEAVENLY " %d\n" RESET, res); 160 | int y_res = ft_isprint(test) != 0; 161 | printf("[+] WATH YOURS FUNCTOINS GET :"); 162 | printf(HEAVENLY " %d\n\n" RESET, y_res); 163 | if (y_res == res) 164 | { 165 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 166 | return (1); 167 | } 168 | else 169 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 170 | return (0); 171 | } 172 | 173 | int main() 174 | { 175 | int c; 176 | c = 0; 177 | int t0 = test0(); 178 | sleep(1); 179 | int t1 = test1(); 180 | sleep(1); 181 | int t2 = test2(); 182 | sleep(1); 183 | int t3 = test3(); 184 | sleep(1); 185 | int t4 = test4(); 186 | sleep(1); 187 | int t5 = test5(); 188 | sleep(1); 189 | c = t0 + t1 + t2 + t3 + t4 + t5; 190 | printf(PERPUL "==============================================\n" RESET); 191 | if (c == 6) 192 | { 193 | printf(GREEN "THE RESULTE IS : [%d/6]\n",c); 194 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 195 | } 196 | else 197 | { 198 | printf(RED "THE RESULTE IS : [%d/6]\n",c); 199 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 200 | } 201 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 202 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 203 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 204 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 205 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 206 | ((t5 == 0)? printf(RED "TEST5" RESET ".\n") : printf(GREEN "TEST5" RESET ".\n")); 207 | printf(PERPUL "==============================================\n\n" RESET); 208 | } 209 | -------------------------------------------------------------------------------- /test/Libc_functions/memchr/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | int test0() 15 | { 16 | printf(YELLOW "==============================================\n" RESET); 17 | printf(YELLOW "= ft_memchr =\n" RESET); 18 | printf(YELLOW "==============================================\n\n" RESET); 19 | printf("[+] THE TEST NUMBER : 0 !!\n"); 20 | char test_a[] = "145648132148456325615131234"; 21 | unsigned char c = '3'; 22 | unsigned int n = strlen(test_a); 23 | printf("[+] WATH WE HAVE :"); 24 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 25 | char *res = memchr(test_a, c, n) ; 26 | printf("[+] WATH SHOULD WE GET :"); 27 | printf(HEAVENLY " %s\n" RESET, res); 28 | char *y_res = ft_memchr(test_a, c, n); 29 | printf("[+] WATH YOURS FUNCTOINS GET :"); 30 | printf(HEAVENLY " %s\n\n" RESET, y_res); 31 | if (res == y_res) 32 | { 33 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 34 | return (1); 35 | } 36 | else 37 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 38 | return (0); 39 | } 40 | 41 | 42 | int test1() 43 | { 44 | printf(YELLOW "==============================================\n" RESET); 45 | printf(YELLOW "= ft_memchr =\n" RESET); 46 | printf(YELLOW "==============================================\n\n" RESET); 47 | printf("[+] THE TEST NUMBER : 1 !!\n"); 48 | char test_a[] = "hello world !!"; 49 | unsigned char c = 'h'; 50 | unsigned int n = strlen(test_a); 51 | printf("[+] WATH WE HAVE :"); 52 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 53 | char *res = memchr(test_a, c, n); 54 | printf("[+] WATH SHOULD WE GET :"); 55 | printf(HEAVENLY " %s\n" RESET, res); 56 | char *y_res = ft_memchr(test_a, c, n); 57 | printf("[+] WATH YOURS FUNCTOINS GET :"); 58 | printf(HEAVENLY " %s\n\n" RESET, y_res); 59 | if (res == y_res) 60 | { 61 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 62 | return (1); 63 | } 64 | else 65 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 66 | return (0); 67 | } 68 | 69 | int test2() 70 | { 71 | printf(YELLOW "==============================================\n" RESET); 72 | printf(YELLOW "= ft_memchr =\n" RESET); 73 | printf(YELLOW "==============================================\n\n" RESET); 74 | printf("[+] THE TEST NUMBER : 2 !!\n"); 75 | unsigned char c = '1'; 76 | char test_a[] = "your must give us on 'one' charcther 1"; 77 | unsigned int n = strlen(test_a); 78 | printf("[+] WATH WE HAVE :"); 79 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 80 | char *res = memchr(test_a, c, n); 81 | printf("[+] WATH SHOULD WE GET :"); 82 | printf(HEAVENLY " %s\n" RESET, res); 83 | char *y_res = ft_memchr(test_a, c, n); 84 | printf("[+] WATH YOURS FUNCTOINS GET :"); 85 | printf(HEAVENLY " %s\n\n" RESET, y_res); 86 | if (res == y_res) 87 | { 88 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 89 | return (1); 90 | } 91 | else 92 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 93 | return (0); 94 | } 95 | 96 | int test3() 97 | { 98 | printf(YELLOW "==============================================\n" RESET); 99 | printf(YELLOW "= ft_memchr =\n" RESET); 100 | printf(YELLOW "==============================================\n\n" RESET); 101 | printf("[+] THE TEST NUMBER : 3 !!\n"); 102 | char test_a[] = "1234"; 103 | unsigned char c = '3'; 104 | unsigned int n = 0; 105 | printf("[+] WATH WE HAVE :"); 106 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 107 | char *res = memchr(test_a, c, n); 108 | printf("[+] WATH SHOULD WE GET :"); 109 | printf(HEAVENLY " %s\n" RESET, res); 110 | char *y_res = ft_memchr(test_a, c, n); 111 | printf("[+] WATH YOURS FUNCTOINS GET :"); 112 | printf(HEAVENLY " %s\n\n" RESET, y_res); 113 | if (res == y_res) 114 | { 115 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 116 | return (1); 117 | } 118 | else 119 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 120 | return (0); 121 | } 122 | 123 | int test4() 124 | { 125 | printf(YELLOW "==============================================\n" RESET); 126 | printf(YELLOW "= ft_memchr =\n" RESET); 127 | printf(YELLOW "==============================================\n\n" RESET); 128 | printf("[+] THE TEST NUMBER : 4 !!\n"); 129 | unsigned char c = 'c'; 130 | char test_a[] = "abdefg"; 131 | unsigned int n = 6; 132 | printf("[+] WATH WE HAVE :"); 133 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 134 | char *res = memchr(test_a, c, n); 135 | printf("[+] WATH SHOULD WE GET :"); 136 | printf(HEAVENLY " %s\n" RESET, res); 137 | char *y_res = ft_memchr(test_a, c, n); 138 | printf("[+] WATH YOURS FUNCTOINS GET :"); 139 | printf(HEAVENLY " %s\n\n" RESET, y_res); 140 | if (res == y_res) 141 | { 142 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 143 | return (1); 144 | } 145 | else 146 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 147 | return (0); 148 | } 149 | 150 | int test5() 151 | { 152 | printf(YELLOW "==============================================\n" RESET); 153 | printf(YELLOW "= ft_memchr =\n" RESET); 154 | printf(YELLOW "==============================================\n\n" RESET); 155 | printf("[+] THE TEST NUMBER : 5 !!\n"); 156 | char test_a[] = "he what\0are u doing *-*"; 157 | unsigned char c = '\0'; 158 | unsigned int n = strlen(test_a); 159 | printf("[+] WATH WE HAVE :"); 160 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 161 | char *res = memchr(test_a, c, n); 162 | printf("[+] WATH SHOULD WE GET :"); 163 | printf(HEAVENLY " %s\n" RESET, res); 164 | char *y_res = ft_memchr(test_a, c, n); 165 | printf("[+] WATH YOURS FUNCTOINS GET :"); 166 | printf(HEAVENLY " %s\n\n" RESET, y_res); 167 | if (res == y_res) 168 | { 169 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 170 | return (1); 171 | } 172 | else 173 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 174 | return (0); 175 | } 176 | 177 | int test6() 178 | { 179 | printf(YELLOW "==============================================\n" RESET); 180 | printf(YELLOW "= ft_memchr =\n" RESET); 181 | printf(YELLOW "==============================================\n\n" RESET); 182 | printf("[+] THE TEST NUMBER : 6 !!\n"); 183 | char test_a[] = "good work bro !!"; 184 | unsigned char c = 'k'; 185 | unsigned int n = 6; 186 | printf("[+] WATH WE HAVE :"); 187 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 188 | char *res = memchr(test_a, c, n); 189 | printf("[+] WATH SHOULD WE GET :"); 190 | printf(HEAVENLY " %s\n" RESET, res); 191 | char *y_res = ft_memchr(test_a, c, n); 192 | printf("[+] WATH YOURS FUNCTOINS GET :"); 193 | printf(HEAVENLY " %s\n\n" RESET, y_res); 194 | if (res == y_res) 195 | { 196 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 197 | return (1); 198 | } 199 | else 200 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 201 | return (0); 202 | } 203 | 204 | int test7() 205 | { 206 | printf(YELLOW "==============================================\n" RESET); 207 | printf(YELLOW "= ft_memchr =\n" RESET); 208 | printf(YELLOW "==============================================\n\n" RESET); 209 | printf("[+] THE TEST NUMBER : 7 !!\n"); 210 | char test_a[] = "hi good\xf4programmer"; 211 | unsigned char c = '\xf4'; 212 | unsigned int n = strlen(test_a); 213 | printf("[+] WATH WE HAVE :"); 214 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 215 | char *res = memchr(test_a, c, n); 216 | printf("[+] WATH SHOULD WE GET :"); 217 | printf(HEAVENLY " %s\n" RESET, res); 218 | char *y_res = ft_memchr(test_a, c, n); 219 | printf("[+] WATH YOURS FUNCTOINS GET :"); 220 | printf(HEAVENLY " %s\n\n" RESET, y_res); 221 | if (res == y_res) 222 | { 223 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 224 | return (1); 225 | } 226 | else 227 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 228 | return (0); 229 | } 230 | 231 | int test8() 232 | { 233 | printf(YELLOW "==============================================\n" RESET); 234 | printf(YELLOW "= ft_memchr =\n" RESET); 235 | printf(YELLOW "==============================================\n\n" RESET); 236 | printf("[+] THE TEST NUMBER : 8 !!\n"); 237 | char test_a[] = "121314a115a1167da15zad819"; 238 | unsigned char c = 'h'; 239 | unsigned int n = strlen(test_a); 240 | printf("[+] WATH WE HAVE :"); 241 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 242 | char *res = memchr(test_a, c, n); 243 | printf("[+] WATH SHOULD WE GET :"); 244 | printf(HEAVENLY " %s\n" RESET, res); 245 | char *y_res = ft_memchr(test_a, c, n); 246 | printf("[+] WATH YOURS FUNCTOINS GET :"); 247 | printf(HEAVENLY " %s\n\n" RESET, y_res); 248 | if (res == y_res) 249 | { 250 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 251 | return (1); 252 | } 253 | else 254 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 255 | return (0); 256 | } 257 | int test9() 258 | { 259 | printf(YELLOW "==============================================\n" RESET); 260 | printf(YELLOW "= ft_memchr =\n" RESET); 261 | printf(YELLOW "==============================================\n\n" RESET); 262 | printf("[+] THE TEST NUMBER : 9 !!\n"); 263 | char test_a[] = "+-+-+-+-+0-0----"; 264 | unsigned char c = '0'; 265 | unsigned int n = strlen(test_a); 266 | printf("[+] WATH WE HAVE :"); 267 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 268 | char *res = memchr(test_a, c, n); 269 | printf("[+] WATH SHOULD WE GET :"); 270 | printf(HEAVENLY " %s\n" RESET, res); 271 | char *y_res = ft_memchr(test_a, c, n); 272 | printf("[+] WATH YOURS FUNCTOINS GET :"); 273 | printf(HEAVENLY " %s\n\n" RESET, y_res); 274 | if (res == y_res) 275 | { 276 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 277 | return (1); 278 | } 279 | else 280 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 281 | return (0); 282 | } 283 | 284 | int test10() 285 | { 286 | printf(YELLOW "==============================================\n" RESET); 287 | printf(YELLOW "= ft_memchr =\n" RESET); 288 | printf(YELLOW "==============================================\n\n" RESET); 289 | printf("[+] THE TEST NUMBER : 10 !!\n"); 290 | char test_a[] = ""; 291 | unsigned char c = '3'; 292 | unsigned int n = 0; 293 | printf("[+] WATH WE HAVE :"); 294 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 295 | char *res = memchr(test_a, c, n); 296 | printf("[+] WATH SHOULD WE GET :"); 297 | printf(HEAVENLY " %s\n" RESET, res); 298 | char *y_res = ft_memchr(test_a, c, n); 299 | printf("[+] WATH YOURS FUNCTOINS GET :"); 300 | printf(HEAVENLY " %s\n\n" RESET, y_res); 301 | if (res == y_res) 302 | { 303 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 304 | return (1); 305 | } 306 | else 307 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 308 | return (0); 309 | } 310 | 311 | int test11() 312 | { 313 | printf(YELLOW "==============================================\n" RESET); 314 | printf(YELLOW "= ft_memchr =\n" RESET); 315 | printf(YELLOW "==============================================\n\n" RESET); 316 | printf("[+] THE TEST NUMBER : 11 !!\n"); 317 | unsigned char c = '\xa9'; 318 | char test_a[] = "\xf3\xf5\xd4\xff\xe5\xc5\xa4\xa9\x9f"; 319 | unsigned int n = strlen(test_a); 320 | printf("[+] WATH WE HAVE :"); 321 | printf(HEAVENLY "data : [%s] | size : [%u] | char : [%c]\n" RESET, test_a, n, c); 322 | char *res = memchr(test_a, c, n); 323 | printf("[+] WATH SHOULD WE GET :"); 324 | printf(HEAVENLY " %s\n" RESET, res); 325 | char *y_res = ft_memchr(test_a, c, n); 326 | printf("[+] WATH YOURS FUNCTOINS GET :"); 327 | printf(HEAVENLY " %s\n\n" RESET, y_res); 328 | if (res == y_res) 329 | { 330 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 331 | return (1); 332 | } 333 | else 334 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 335 | return (0); 336 | } 337 | 338 | int main() 339 | { 340 | int c; 341 | c = 0; 342 | int t0 = test0(); 343 | sleep(1); 344 | int t1 = test1(); 345 | sleep(1); 346 | int t2 = test2(); 347 | sleep(1); 348 | int t3 = test3(); 349 | sleep(1); 350 | int t4 = test4(); 351 | sleep(1); 352 | int t5 = test5(); 353 | sleep(1); 354 | int t6 = test6(); 355 | sleep(1); 356 | int t7 = test7(); 357 | sleep(1); 358 | int t8 = test8(); 359 | sleep(1); 360 | int t9 = test9(); 361 | sleep(1); 362 | int t10 = test10(); 363 | sleep(1); 364 | int t11 = test11(); 365 | sleep(1); 366 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 367 | printf(PERPUL "==============================================\n" RESET); 368 | if (c == 12) 369 | { 370 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 371 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 372 | } 373 | else 374 | { 375 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 376 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 377 | } 378 | printf(HEAVENLY "ALL TEST : " RESET); 379 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 380 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 381 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 382 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 383 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 384 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 385 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 386 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 387 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 388 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 389 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 390 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 391 | printf(PERPUL "==============================================\n\n" RESET); 392 | } 393 | -------------------------------------------------------------------------------- /test/Libc_functions/memcmp/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_memcmp =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | char test_a[100] = "1234"; 20 | char test_b[100] = "1234"; 21 | unsigned int n = 4; 22 | printf("[+] WATH WE HAVE :"); 23 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 24 | int res = memcmp(test_a, test_b, n) ; 25 | printf("[+] WATH SHOULD WE GET :"); 26 | printf(HEAVENLY " %d\n" RESET, res); 27 | int y_res = ft_memcmp(test_a, test_b, n); 28 | printf("[+] WATH YOURS FUNCTOINS GET :"); 29 | printf(HEAVENLY " %d\n\n" RESET, y_res); 30 | if (y_res == res) 31 | { 32 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 33 | return (1); 34 | } 35 | else 36 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 37 | return (0); 38 | } 39 | 40 | 41 | int test1() 42 | { 43 | printf(YELLOW "==============================================\n" RESET); 44 | printf(YELLOW "= ft_memcmp =\n" RESET); 45 | printf(YELLOW "==============================================\n\n" RESET); 46 | printf("[+] THE TEST NUMBER : 1 !!\n"); 47 | char test_a[100] = "1234"; 48 | char test_b[100] = "4321"; 49 | unsigned int n = 4; 50 | printf("[+] WATH WE HAVE :"); 51 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 52 | int res = memcmp(test_a, test_b, n); 53 | printf("[+] WATH SHOULD WE GET :"); 54 | printf(HEAVENLY " %d\n" RESET, res); 55 | int y_res = ft_memcmp(test_a, test_b, n); 56 | printf("[+] WATH YOURS FUNCTOINS GET :"); 57 | printf(HEAVENLY " %d\n\n" RESET, y_res); 58 | if (y_res == res) 59 | { 60 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 61 | return (1); 62 | } 63 | else 64 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 65 | return (0); 66 | } 67 | 68 | int test2() 69 | { 70 | printf(YELLOW "==============================================\n" RESET); 71 | printf(YELLOW "= ft_memcmp =\n" RESET); 72 | printf(YELLOW "==============================================\n\n" RESET); 73 | printf("[+] THE TEST NUMBER : 2 !!\n"); 74 | char test_a[100] = "1235"; 75 | char test_b[100] = "1234"; 76 | unsigned int n = 3; 77 | printf("[+] WATH WE HAVE :"); 78 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 79 | int res = memcmp(test_a, test_b, n); 80 | printf("[+] WATH SHOULD WE GET :"); 81 | printf(HEAVENLY " %d\n" RESET, res); 82 | int y_res = ft_memcmp(test_a, test_b, n); 83 | printf("[+] WATH YOURS FUNCTOINS GET :"); 84 | printf(HEAVENLY " %d\n\n" RESET, y_res); 85 | if (y_res == res) 86 | { 87 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 88 | return (1); 89 | } 90 | else 91 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 92 | return (0); 93 | } 94 | 95 | int test3() 96 | { 97 | printf(YELLOW "==============================================\n" RESET); 98 | printf(YELLOW "= ft_memcmp =\n" RESET); 99 | printf(YELLOW "==============================================\n\n" RESET); 100 | printf("[+] THE TEST NUMBER : 3 !!\n"); 101 | char test_a[100] = "123"; 102 | char test_b[100] = "1234"; 103 | unsigned int n = 4; 104 | printf("[+] WATH WE HAVE :"); 105 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 106 | int res = memcmp(test_a, test_b, n); 107 | printf("[+] WATH SHOULD WE GET :"); 108 | printf(HEAVENLY " %d\n" RESET, res); 109 | int y_res = ft_memcmp(test_a, test_b, n); 110 | printf("[+] WATH YOURS FUNCTOINS GET :"); 111 | printf(HEAVENLY " %d\n\n" RESET, y_res); 112 | if (y_res == res) 113 | { 114 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 115 | return (1); 116 | } 117 | else 118 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 119 | return (0); 120 | } 121 | 122 | int test4() 123 | { 124 | printf(YELLOW "==============================================\n" RESET); 125 | printf(YELLOW "= ft_memcmp =\n" RESET); 126 | printf(YELLOW "==============================================\n\n" RESET); 127 | printf("[+] THE TEST NUMBER : 4 !!\n"); 128 | char test_a[100] = {-1,10,5,1}; 129 | char test_b[100] = {-1,10,5,0}; 130 | unsigned int n = 10; 131 | printf("[+] WATH WE HAVE :"); 132 | printf(HEAVENLY "n1 : [{-1,10,5,1}] | n2 : [{-1.10.5.0}] | n : [%d]\n" RESET, n); 133 | int res = memcmp(test_a, test_b, n); 134 | printf("[+] WATH SHOULD WE GET :"); 135 | printf(HEAVENLY " %d\n" RESET, res); 136 | int y_res = ft_memcmp(test_a, test_b, n); 137 | printf("[+] WATH YOURS FUNCTOINS GET :"); 138 | printf(HEAVENLY " %d\n\n" RESET, y_res); 139 | if (y_res == res) 140 | { 141 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 142 | return (1); 143 | } 144 | else 145 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 146 | return (0); 147 | } 148 | 149 | int test5() 150 | { 151 | printf(YELLOW "==============================================\n" RESET); 152 | printf(YELLOW "= ft_memcmp =\n" RESET); 153 | printf(YELLOW "==============================================\n\n" RESET); 154 | printf("[+] THE TEST NUMBER : 5 !!\n"); 155 | char test_a[100] = "123\x0,123\x0\0"; 156 | char test_b[100] = "123\x0,123\x0\0"; 157 | unsigned int n = sizeof(test_b); 158 | printf("[+] WATH WE HAVE :"); 159 | printf(HEAVENLY "s1 : [123\\x0,123\\x0\\0] | s2 : [123\\x0,123\\x0\\0] | n : [%d]\n" RESET, n); 160 | int res = memcmp(test_a, test_b, n); 161 | printf("[+] WATH SHOULD WE GET :"); 162 | printf(HEAVENLY " %d\n" RESET, res); 163 | int y_res = ft_memcmp(test_a, test_b, n); 164 | printf("[+] WATH YOURS FUNCTOINS GET :"); 165 | printf(HEAVENLY " %d\n\n" RESET, y_res); 166 | if (y_res == res) 167 | { 168 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 169 | return (1); 170 | } 171 | else 172 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 173 | return (0); 174 | } 175 | 176 | int test6() 177 | { 178 | printf(YELLOW "==============================================\n" RESET); 179 | printf(YELLOW "= ft_memcmp =\n" RESET); 180 | printf(YELLOW "==============================================\n\n" RESET); 181 | printf("[+] THE TEST NUMBER : 6 !!\n"); 182 | char test_a[100] = "good work"; 183 | char test_b[100] = "good work bro !!"; 184 | unsigned int n = sizeof(test_a); 185 | printf("[+] WATH WE HAVE :"); 186 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 187 | int res = memcmp(test_a, test_b, n); 188 | printf("[+] WATH SHOULD WE GET :"); 189 | printf(HEAVENLY " %d\n" RESET, res); 190 | int y_res = ft_memcmp(test_a, test_b, n); 191 | printf("[+] WATH YOURS FUNCTOINS GET :"); 192 | printf(HEAVENLY " %d\n\n" RESET, y_res); 193 | if (y_res == res) 194 | { 195 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 196 | return (1); 197 | } 198 | else 199 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 200 | return (0); 201 | } 202 | 203 | int test7() 204 | { 205 | printf(YELLOW "==============================================\n" RESET); 206 | printf(YELLOW "= ft_memcmp =\n" RESET); 207 | printf(YELLOW "==============================================\n\n" RESET); 208 | printf("[+] THE TEST NUMBER : 7 !!\n"); 209 | char test_a[100] = "hi good\x4programmer"; 210 | char test_b[100] = "hi good\x1programmer"; 211 | unsigned int n = strlen(test_a); 212 | printf("[+] WATH WE HAVE :"); 213 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 214 | int res = memcmp(test_a, test_b, n); 215 | printf("[+] WATH SHOULD WE GET :"); 216 | printf(HEAVENLY " %d\n" RESET, res); 217 | int y_res = ft_memcmp(test_a, test_b, n); 218 | printf("[+] WATH YOURS FUNCTOINS GET :"); 219 | printf(HEAVENLY " %d\n\n" RESET, y_res); 220 | if (y_res == res) 221 | { 222 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 223 | return (1); 224 | } 225 | else 226 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 227 | return (0); 228 | } 229 | 230 | int test8() 231 | { 232 | printf(YELLOW "==============================================\n" RESET); 233 | printf(YELLOW "= ft_memcmp =\n" RESET); 234 | printf(YELLOW "==============================================\n\n" RESET); 235 | printf("[+] THE TEST NUMBER : 8 !!\n"); 236 | char test_a[100] = "123456789"; 237 | char test_b[100] = "123465789"; 238 | unsigned int n = 10; 239 | printf("[+] WATH WE HAVE :"); 240 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 241 | int res = memcmp(test_a, test_b, n); 242 | printf("[+] WATH SHOULD WE GET :"); 243 | printf(HEAVENLY " %d\n" RESET, res); 244 | int y_res = ft_memcmp(test_a, test_b, n); 245 | printf("[+] WATH YOURS FUNCTOINS GET :"); 246 | printf(HEAVENLY " %d\n\n" RESET, y_res); 247 | if (y_res == res) 248 | { 249 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 250 | return (1); 251 | } 252 | else 253 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 254 | return (0); 255 | } 256 | int test9() 257 | { 258 | printf(YELLOW "==============================================\n" RESET); 259 | printf(YELLOW "= ft_memcmp =\n" RESET); 260 | printf(YELLOW "==============================================\n\n" RESET); 261 | printf("[+] THE TEST NUMBER : 9 !!\n"); 262 | char test_a[100] = "123456987"; 263 | char test_b[100] = "12346987"; 264 | unsigned int n = 5; 265 | printf("[+] WATH WE HAVE :"); 266 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 267 | int res = memcmp(test_a, test_b, n); 268 | printf("[+] WATH SHOULD WE GET :"); 269 | printf(HEAVENLY " %d\n" RESET, res); 270 | int y_res = ft_memcmp(test_a, test_b, n); 271 | printf("[+] WATH YOURS FUNCTOINS GET :"); 272 | printf(HEAVENLY " %d\n\n" RESET, y_res); 273 | if (y_res == res) 274 | { 275 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 276 | return (1); 277 | } 278 | else 279 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 280 | return (0); 281 | } 282 | int test10() 283 | { 284 | printf(YELLOW "==============================================\n" RESET); 285 | printf(YELLOW "= ft_memcmp =\n" RESET); 286 | printf(YELLOW "==============================================\n\n" RESET); 287 | printf("[+] THE TEST NUMBER : 10 !!\n"); 288 | char test_a[100] = ""; 289 | char test_b[100] = "1234"; 290 | unsigned int n = 5; 291 | printf("[+] WATH WE HAVE :"); 292 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 293 | int res = memcmp(test_a, test_b, n); 294 | printf("[+] WATH SHOULD WE GET :"); 295 | printf(HEAVENLY " %d\n" RESET, res); 296 | int y_res = ft_memcmp(test_a, test_b, n); 297 | printf("[+] WATH YOURS FUNCTOINS GET :"); 298 | printf(HEAVENLY " %d\n\n" RESET, y_res); 299 | if (y_res == res) 300 | { 301 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 302 | return (1); 303 | } 304 | else 305 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 306 | return (0); 307 | } 308 | 309 | int test11() 310 | { 311 | printf(YELLOW "==============================================\n" RESET); 312 | printf(YELLOW "= ft_memcmp =\n" RESET); 313 | printf(YELLOW "==============================================\n\n" RESET); 314 | printf("[+] THE TEST NUMBER : 11 !!\n"); 315 | char test_a[100] = ""; 316 | char test_b[100] = ""; 317 | unsigned int n = 100; 318 | printf("[+] WATH WE HAVE :"); 319 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 320 | int res = memcmp(test_a, test_b, n); 321 | printf("[+] WATH SHOULD WE GET :"); 322 | printf(HEAVENLY " %d\n" RESET, res); 323 | int y_res = ft_memcmp(test_a, test_b, n); 324 | printf("[+] WATH YOURS FUNCTOINS GET :"); 325 | printf(HEAVENLY " %d\n\n" RESET, y_res); 326 | if (y_res == res) 327 | { 328 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 329 | return (1); 330 | } 331 | else 332 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 333 | return (0); 334 | } 335 | 336 | int main() 337 | { 338 | int c; 339 | c = 0; 340 | int t0 = test0(); 341 | sleep(1); 342 | int t1 = test1(); 343 | sleep(1); 344 | int t2 = test2(); 345 | sleep(1); 346 | int t3 = test3(); 347 | sleep(1); 348 | int t4 = test4(); 349 | sleep(1); 350 | int t5 = test5(); 351 | sleep(1); 352 | int t6 = test6(); 353 | sleep(1); 354 | int t7 = test7(); 355 | sleep(1); 356 | int t8 = test8(); 357 | sleep(1); 358 | int t9 = test9(); 359 | sleep(1); 360 | int t10 = test10(); 361 | sleep(1); 362 | int t11 = test11(); 363 | sleep(1); 364 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 365 | printf(PERPUL "==============================================\n" RESET); 366 | if (c == 12) 367 | { 368 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 369 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 370 | } 371 | else 372 | { 373 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 374 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 375 | } 376 | printf(HEAVENLY "ALL TEST : " RESET); 377 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 378 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 379 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 380 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 381 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 382 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 383 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 384 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 385 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 386 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 387 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 388 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 389 | printf(PERPUL "==============================================\n\n" RESET); 390 | } 391 | -------------------------------------------------------------------------------- /test/Libc_functions/memcpy/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | void n_print(void *arr, size_t n) 15 | { 16 | size_t i = 0; 17 | unsigned char *p = arr; 18 | while (i < n) 19 | printf(HEAVENLY "%c" RESET,p[i++]); 20 | printf("\n"); 21 | } 22 | 23 | int test0() 24 | { 25 | printf(YELLOW "==============================================\n" RESET); 26 | printf(YELLOW "= ft_memcpy =\n" RESET); 27 | printf(YELLOW "==============================================\n\n" RESET); 28 | printf("[+] THE TEST NUMBER : 0 !!\n"); 29 | char test_a[100]; 30 | char test_c[100]; 31 | char test_b[100] = "this is just test!!"; 32 | unsigned int n = 9; 33 | printf("[+] WATH WE HAVE : "); 34 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 35 | memcpy(test_a, test_b, n); 36 | printf("[+] WATH SHOULD WE GET : "); 37 | n_print(test_a, n); 38 | ft_memcpy(test_c, test_b, n); 39 | printf("[+] WATH YOURS FUNCTOINS GET : "); 40 | n_print(test_c, n); 41 | if (memcmp(test_a, test_c, n) == 0) 42 | { 43 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 44 | return (1); 45 | } 46 | else 47 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 48 | return (0); 49 | } 50 | 51 | 52 | int test1() 53 | { 54 | printf(YELLOW "==============================================\n" RESET); 55 | printf(YELLOW "= ft_memcpy =\n" RESET); 56 | printf(YELLOW "==============================================\n\n" RESET); 57 | printf("[+] THE TEST NUMBER : 1 !!\n"); 58 | char test_a[100] = "10234"; 59 | char test_c[100] = "10234"; 60 | char test_b[100] = "hello world!!"; 61 | unsigned int n = strlen(test_b) + 1; 62 | printf("[+] WATH WE HAVE : "); 63 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 64 | memcpy(test_a, test_b, n); 65 | printf("[+] WATH SHOULD WE GET : "); 66 | n_print(test_a, n);; 67 | ft_memcpy(test_c, test_b, n); 68 | printf("[+] WATH YOURS FUNCTOINS GET : "); 69 | n_print(test_c, n); 70 | if (memcmp(test_a, test_c, n) == 0) 71 | { 72 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 73 | return (1); 74 | } 75 | else 76 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 77 | return (0); 78 | } 79 | 80 | int test2() 81 | { 82 | printf(YELLOW "==============================================\n" RESET); 83 | printf(YELLOW "= ft_memcpy =\n" RESET); 84 | printf(YELLOW "==============================================\n\n" RESET); 85 | printf("[+] THE TEST NUMBER : 2 !!\n"); 86 | char test_a[100] = "1234"; 87 | char test_c[100] = "1234"; 88 | char test_b[100] = "0123456789"; 89 | unsigned int n = 50; 90 | printf("[+] WATH WE HAVE : "); 91 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 92 | memcpy(test_a, test_b, n); 93 | printf("[+] WATH SHOULD WE GET : "); 94 | n_print(test_a, n);; 95 | ft_memcpy(test_c, test_b, n); 96 | printf("[+] WATH YOURS FUNCTOINS GET : "); 97 | n_print(test_c, n); 98 | if (memcmp(test_a, test_c, n) == 0) 99 | { 100 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 101 | return (1); 102 | } 103 | else 104 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 105 | return (0); 106 | } 107 | 108 | int test3() 109 | { 110 | printf(YELLOW "==============================================\n" RESET); 111 | printf(YELLOW "= ft_memcpy =\n" RESET); 112 | printf(YELLOW "==============================================\n\n" RESET); 113 | printf("[+] THE TEST NUMBER : 3 !!\n"); 114 | char test_a[100] = "1234555"; 115 | char test_c[100] = "1234555"; 116 | char test_b[100] = "0000"; 117 | unsigned int n = 4; 118 | printf("[+] WATH WE HAVE : "); 119 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 120 | memcpy(test_a, test_b, n); 121 | printf("[+] WATH SHOULD WE GET : "); 122 | n_print(test_a, n);; 123 | ft_memcpy(test_c, test_b, n); 124 | printf("[+] WATH YOURS FUNCTOINS GET : "); 125 | n_print(test_c, n); 126 | if (memcmp(test_a, test_c, n) == 0) 127 | { 128 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 129 | return (1); 130 | } 131 | else 132 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 133 | return (0); 134 | } 135 | 136 | int test4() 137 | { 138 | printf(YELLOW "==============================================\n" RESET); 139 | printf(YELLOW "= ft_memcpy =\n" RESET); 140 | printf(YELLOW "==============================================\n\n" RESET); 141 | printf("[+] THE TEST NUMBER : 4 !!\n"); 142 | char test_a[100] = "abdefg"; 143 | char test_c[100] = "abdefg"; 144 | char test_b[100] = "oh no it don't work any more"; 145 | unsigned int n = 0; 146 | printf("[+] WATH WE HAVE : "); 147 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 148 | memcpy(test_a, test_b, n); 149 | printf("[+] WATH SHOULD WE GET : "); 150 | n_print(test_a, n);; 151 | ft_memcpy(test_c, test_b, n); 152 | printf("[+] WATH YOURS FUNCTOINS GET : "); 153 | n_print(test_c, n); 154 | if (memcmp(test_a, test_c, n) == 0) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test5() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_memcpy =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 5 !!\n"); 170 | char test_a[100] = "he what are u doing *-*"; 171 | char test_c[100] = "he what are u doing *-*"; 172 | char test_b[100] = "good job sir"; 173 | unsigned int n = 7; 174 | printf("[+] WATH WE HAVE : "); 175 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 176 | memcpy(test_a, test_b, n); 177 | printf("[+] WATH SHOULD WE GET : "); 178 | n_print(test_a, n);; 179 | ft_memcpy(test_c, test_b, n); 180 | printf("[+] WATH YOURS FUNCTOINS GET : "); 181 | n_print(test_c, n); 182 | if (memcmp(test_a, test_c, n) == 0) 183 | { 184 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 185 | return (1); 186 | } 187 | else 188 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 189 | return (0); 190 | } 191 | 192 | int test6() 193 | { 194 | printf(YELLOW "==============================================\n" RESET); 195 | printf(YELLOW "= ft_memcpy =\n" RESET); 196 | printf(YELLOW "==============================================\n\n" RESET); 197 | printf("[+] THE TEST NUMBER : 6 !!\n"); 198 | char test_a[100] = "good work bro !!"; 199 | char test_c[100] = "good work bro !!"; 200 | char test_b[100] = "8==(*--*)==3\\_/"; 201 | unsigned int n = 10; 202 | printf("[+] WATH WE HAVE : "); 203 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 204 | memcpy(test_a, test_b, n); 205 | printf("[+] WATH SHOULD WE GET : "); 206 | n_print(test_a, n);; 207 | ft_memcpy(test_c, test_b, n); 208 | printf("[+] WATH YOURS FUNCTOINS GET : "); 209 | n_print(test_c, n); 210 | if (memcmp(test_a, test_c, n) == 0) 211 | { 212 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 213 | return (1); 214 | } 215 | else 216 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 217 | return (0); 218 | } 219 | 220 | int test7() 221 | { 222 | printf(YELLOW "==============================================\n" RESET); 223 | printf(YELLOW "= ft_memcpy =\n" RESET); 224 | printf(YELLOW "==============================================\n\n" RESET); 225 | printf("[+] THE TEST NUMBER : 7 !!\n"); 226 | char test_a[100] = "hi good\xf4programmer"; 227 | char test_c[100] = "hi good\xf4programmer"; 228 | char test_b[100] = "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!"; 229 | unsigned int n = 50; 230 | printf("[+] WATH WE HAVE : "); 231 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 232 | memcpy(test_a, test_b, n); 233 | printf("[+] WATH SHOULD WE GET : "); 234 | n_print(test_a, n);; 235 | ft_memcpy(test_c, test_b, n); 236 | printf("[+] WATH YOURS FUNCTOINS GET : "); 237 | n_print(test_c, n); 238 | if (memcmp(test_a, test_c, n) == 0) 239 | { 240 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 241 | return (1); 242 | } 243 | else 244 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 245 | return (0); 246 | } 247 | 248 | int test8() 249 | { 250 | printf(YELLOW "==============================================\n" RESET); 251 | printf(YELLOW "= ft_memcpy =\n" RESET); 252 | printf(YELLOW "==============================================\n\n" RESET); 253 | printf("[+] THE TEST NUMBER : 8 !!\n"); 254 | char test_a[100] = "1123456789"; 255 | char test_c[100] = "1123456789"; 256 | char test_b[100] = "I DO, AND YOU, DO YOU KNOW WHAT THE ANSWER ?"; 257 | unsigned int n = 4; 258 | printf("[+] WATH WE HAVE : "); 259 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 260 | memcpy(test_a, test_b, n); 261 | printf("[+] WATH SHOULD WE GET : "); 262 | n_print(test_a, n);; 263 | ft_memcpy(test_c, test_b, n); 264 | printf("[+] WATH YOURS FUNCTOINS GET : "); 265 | n_print(test_c, n); 266 | if (memcmp(test_a, test_c, n) == 0) 267 | { 268 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 269 | return (1); 270 | } 271 | else 272 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 273 | return (0); 274 | } 275 | 276 | int test9() 277 | { 278 | printf(YELLOW "==============================================\n" RESET); 279 | printf(YELLOW "= ft_memcpy =\n" RESET); 280 | printf(YELLOW "==============================================\n\n" RESET); 281 | printf("[+] THE TEST NUMBER : 9 !!\n"); 282 | char test_a[100] = "1234569870000000000"; 283 | char test_c[100] = "1234569870000000000"; 284 | char test_b[100] = "9876543210"; 285 | unsigned int n = 15; 286 | printf("[+] WATH WE HAVE : "); 287 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 288 | memcpy(test_a, test_b, n); 289 | printf("[+] WATH SHOULD WE GET : "); 290 | n_print(test_a, n);; 291 | ft_memcpy(test_c, test_b, n); 292 | printf("[+] WATH YOURS FUNCTOINS GET : "); 293 | n_print(test_c, n); 294 | if (memcmp(test_a, test_c, n) == 0) 295 | { 296 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 297 | return (1); 298 | } 299 | else 300 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 301 | return (0); 302 | } 303 | 304 | int test10() 305 | { 306 | printf(YELLOW "==============================================\n" RESET); 307 | printf(YELLOW "= ft_memcpy =\n" RESET); 308 | printf(YELLOW "==============================================\n\n" RESET); 309 | printf("[+] THE TEST NUMBER : 10 !!\n"); 310 | char test_a[100] = ""; 311 | char test_c[100] = ""; 312 | char test_b[100] = ""; 313 | unsigned int n = 5; 314 | printf("[+] WATH WE HAVE : "); 315 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 316 | memcpy(test_a, test_b, n); 317 | printf("[+] WATH SHOULD WE GET : "); 318 | n_print(test_a, n);; 319 | ft_memcpy(test_c, test_b, n); 320 | printf("[+] WATH YOURS FUNCTOINS GET : "); 321 | n_print(test_c, n); 322 | if (memcmp(test_a, test_c, n) == 0) 323 | { 324 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 325 | return (1); 326 | } 327 | else 328 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 329 | return (0); 330 | } 331 | 332 | int test11() 333 | { 334 | printf(YELLOW "==============================================\n" RESET); 335 | printf(YELLOW "= ft_memcpy =\n" RESET); 336 | printf(YELLOW "==============================================\n\n" RESET); 337 | printf("[+] THE TEST NUMBER : 11 !!\n"); 338 | char test_a[100] = ""; 339 | char test_c[100] = ""; 340 | char test_b[100] = ""; 341 | unsigned int n = 0; 342 | printf("[+] WATH WE HAVE : "); 343 | printf(HEAVENLY " str : [%s] | n : [%d]\n" RESET, test_b, n); 344 | memcpy(test_a, test_b, n); 345 | printf("[+] WATH SHOULD WE GET : "); 346 | n_print(test_a, n); 347 | ft_memcpy(test_c, test_b, n); 348 | printf("[+] WATH YOURS FUNCTOINS GET : "); 349 | n_print(test_c, n); 350 | if (memcmp(test_a, test_c, n) == 0) 351 | { 352 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 353 | return (1); 354 | } 355 | else 356 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 357 | return (0); 358 | } 359 | 360 | int main() 361 | { 362 | int c; 363 | c = 0; 364 | int t0 = test0(); 365 | sleep(1); 366 | int t1 = test1(); 367 | sleep(1); 368 | int t2 = test2(); 369 | sleep(1); 370 | int t3 = test3(); 371 | sleep(1); 372 | int t4 = test4(); 373 | sleep(1); 374 | int t5 = test5(); 375 | sleep(1); 376 | int t6 = test6(); 377 | sleep(1); 378 | int t7 = test7(); 379 | sleep(1); 380 | int t8 = test8(); 381 | sleep(1); 382 | int t9 = test9(); 383 | sleep(1); 384 | int t10 = test10(); 385 | sleep(1); 386 | int t11 = test11(); 387 | sleep(1); 388 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 389 | printf(PERPUL "==============================================\n" RESET); 390 | if (c == 12) 391 | { 392 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 393 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 394 | } 395 | else 396 | { 397 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 398 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 399 | } 400 | printf(HEAVENLY "ALL TEST : " RESET); 401 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 402 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 403 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 404 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 405 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 406 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 407 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 408 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 409 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 410 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 411 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 412 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 413 | printf(PERPUL "==============================================\n\n" RESET); 414 | } 415 | -------------------------------------------------------------------------------- /test/Libc_functions/strchr/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | int test0() 15 | { 16 | printf(YELLOW "==============================================\n" RESET); 17 | printf(YELLOW "= ft_strchr =\n" RESET); 18 | printf(YELLOW "==============================================\n\n" RESET); 19 | printf("[+] THE TEST NUMBER : 0 !!\n"); 20 | char test_a[] = "145648132148456325615131234"; 21 | char test_b = '5'; 22 | printf("[+] WATH WE HAVE :"); 23 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 24 | char *res = strchr(test_a, test_b) ; 25 | printf("[+] WATH SHOULD WE GET :"); 26 | printf(HEAVENLY " %s\n" RESET, res); 27 | char *y_res = ft_strchr(test_a, test_b); 28 | printf("[+] WATH YOURS FUNCTOINS GET :"); 29 | printf(HEAVENLY " %s\n\n" RESET, y_res); 30 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 31 | { 32 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 33 | return (1); 34 | } 35 | else 36 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 37 | return (0); 38 | } 39 | 40 | 41 | int test1() 42 | { 43 | printf(YELLOW "==============================================\n" RESET); 44 | printf(YELLOW "= ft_strchr =\n" RESET); 45 | printf(YELLOW "==============================================\n\n" RESET); 46 | printf("[+] THE TEST NUMBER : 1 !!\n"); 47 | char test_a[] = "10234"; 48 | char test_b = '2'; 49 | printf("[+] WATH WE HAVE :"); 50 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 51 | char *res = strchr(test_a, test_b); 52 | printf("[+] WATH SHOULD WE GET :"); 53 | printf(HEAVENLY " %s\n" RESET, res); 54 | char *y_res = ft_strchr(test_a, test_b); 55 | printf("[+] WATH YOURS FUNCTOINS GET :"); 56 | printf(HEAVENLY " %s\n\n" RESET, y_res); 57 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 58 | { 59 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 60 | return (1); 61 | } 62 | else 63 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 64 | return (0); 65 | } 66 | 67 | int test2() 68 | { 69 | printf(YELLOW "==============================================\n" RESET); 70 | printf(YELLOW "= ft_strchr =\n" RESET); 71 | printf(YELLOW "==============================================\n\n" RESET); 72 | printf("[+] THE TEST NUMBER : 2 !!\n"); 73 | char test_a[] = "1234"; 74 | char test_b = '0'; 75 | printf("[+] WATH WE HAVE :"); 76 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 77 | char *res = strchr(test_a, test_b); 78 | printf("[+] WATH SHOULD WE GET :"); 79 | printf(HEAVENLY " %s\n" RESET, res); 80 | char *y_res = ft_strchr(test_a, test_b); 81 | printf("[+] WATH YOURS FUNCTOINS GET :"); 82 | printf(HEAVENLY " %s\n\n" RESET, y_res); 83 | if ((res == y_res) || ((res == y_res) || (strcmp(res, y_res) == 0))) 84 | { 85 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 86 | return (1); 87 | } 88 | else 89 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 90 | return (0); 91 | } 92 | 93 | int test3() 94 | { 95 | printf(YELLOW "==============================================\n" RESET); 96 | printf(YELLOW "= ft_strchr =\n" RESET); 97 | printf(YELLOW "==============================================\n\n" RESET); 98 | printf("[+] THE TEST NUMBER : 3 !!\n"); 99 | char test_a[] = "1234"; 100 | char test_b = '\0'; 101 | printf("[+] WATH WE HAVE :"); 102 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 103 | char *res = strchr(test_a, test_b); 104 | printf("[+] WATH SHOULD WE GET :"); 105 | printf(HEAVENLY " %s\n" RESET, res); 106 | char *y_res = ft_strchr(test_a, test_b); 107 | printf("[+] WATH YOURS FUNCTOINS GET :"); 108 | printf(HEAVENLY " %s\n\n" RESET, y_res); 109 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 110 | { 111 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 112 | return (1); 113 | } 114 | else 115 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 116 | return (0); 117 | } 118 | 119 | int test4() 120 | { 121 | printf(YELLOW "==============================================\n" RESET); 122 | printf(YELLOW "= ft_strchr =\n" RESET); 123 | printf(YELLOW "==============================================\n\n" RESET); 124 | printf("[+] THE TEST NUMBER : 4 !!\n"); 125 | char test_a[] = "abdefg"; 126 | char test_b = '5'; 127 | printf("[+] WATH WE HAVE :"); 128 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 129 | char *res = strchr(test_a, test_b); 130 | printf("[+] WATH SHOULD WE GET :"); 131 | printf(HEAVENLY " %s\n" RESET, res); 132 | char *y_res = ft_strchr(test_a, test_b); 133 | printf("[+] WATH YOURS FUNCTOINS GET :"); 134 | printf(HEAVENLY " %s\n\n" RESET, y_res); 135 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 136 | { 137 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 138 | return (1); 139 | } 140 | else 141 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 142 | return (0); 143 | } 144 | 145 | int test5() 146 | { 147 | printf(YELLOW "==============================================\n" RESET); 148 | printf(YELLOW "= ft_strchr =\n" RESET); 149 | printf(YELLOW "==============================================\n\n" RESET); 150 | printf("[+] THE TEST NUMBER : 5 !!\n"); 151 | char test_a[] = "he what are u doing *-*"; 152 | char test_b = ' '; 153 | printf("[+] WATH WE HAVE :"); 154 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 155 | char *res = strchr(test_a, test_b); 156 | printf("[+] WATH SHOULD WE GET :"); 157 | printf(HEAVENLY " %s\n" RESET, res); 158 | char *y_res = ft_strchr(test_a, test_b); 159 | printf("[+] WATH YOURS FUNCTOINS GET :"); 160 | printf(HEAVENLY " %s\n\n" RESET, y_res); 161 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 162 | { 163 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 164 | return (1); 165 | } 166 | else 167 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 168 | return (0); 169 | } 170 | 171 | int test6() 172 | { 173 | printf(YELLOW "==============================================\n" RESET); 174 | printf(YELLOW "= ft_strchr =\n" RESET); 175 | printf(YELLOW "==============================================\n\n" RESET); 176 | printf("[+] THE TEST NUMBER : 6 !!\n"); 177 | char test_a[] = "good work bro !!"; 178 | char test_b = 'w'; 179 | printf("[+] WATH WE HAVE :"); 180 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 181 | char *res = strchr(test_a, test_b); 182 | printf("[+] WATH SHOULD WE GET :"); 183 | printf(HEAVENLY " %s\n" RESET, res); 184 | char *y_res = ft_strchr(test_a, test_b); 185 | printf("[+] WATH YOURS FUNCTOINS GET :"); 186 | printf(HEAVENLY " %s\n\n" RESET, y_res); 187 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 188 | { 189 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 190 | return (1); 191 | } 192 | else 193 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 194 | return (0); 195 | } 196 | 197 | int test7() 198 | { 199 | printf(YELLOW "==============================================\n" RESET); 200 | printf(YELLOW "= ft_strchr =\n" RESET); 201 | printf(YELLOW "==============================================\n\n" RESET); 202 | printf("[+] THE TEST NUMBER : 7 !!\n"); 203 | char test_a[] = "hi good\x4programmer"; 204 | char test_b = '\x4'; 205 | printf("[+] WATH WE HAVE :"); 206 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 207 | char *res = strchr(test_a, test_b); 208 | printf("[+] WATH SHOULD WE GET :"); 209 | printf(HEAVENLY " %s\n" RESET, res); 210 | char *y_res = ft_strchr(test_a, test_b); 211 | printf("[+] WATH YOURS FUNCTOINS GET :"); 212 | printf(HEAVENLY " %s\n\n" RESET, y_res); 213 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 214 | { 215 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 216 | return (1); 217 | } 218 | else 219 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 220 | return (0); 221 | } 222 | 223 | int test8() 224 | { 225 | printf(YELLOW "==============================================\n" RESET); 226 | printf(YELLOW "= ft_strchr =\n" RESET); 227 | printf(YELLOW "==============================================\n\n" RESET); 228 | printf("[+] THE TEST NUMBER : 8 !!\n"); 229 | char test_a[] = "121314a115a1167da15zad819"; 230 | char test_b = 'a'; 231 | printf("[+] WATH WE HAVE :"); 232 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 233 | char *res = strchr(test_a, test_b); 234 | printf("[+] WATH SHOULD WE GET :"); 235 | printf(HEAVENLY " %s\n" RESET, res); 236 | char *y_res = ft_strchr(test_a, test_b); 237 | printf("[+] WATH YOURS FUNCTOINS GET :"); 238 | printf(HEAVENLY " %s\n\n" RESET, y_res); 239 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 240 | { 241 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 242 | return (1); 243 | } 244 | else 245 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 246 | return (0); 247 | } 248 | int test9() 249 | { 250 | printf(YELLOW "==============================================\n" RESET); 251 | printf(YELLOW "= ft_strchr =\n" RESET); 252 | printf(YELLOW "==============================================\n\n" RESET); 253 | printf("[+] THE TEST NUMBER : 9 !!\n"); 254 | char test_a[] = "+-+-+-+-+0-0----"; 255 | char test_b = '+'; 256 | printf("[+] WATH WE HAVE :"); 257 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 258 | char *res = strchr(test_a, test_b); 259 | printf("[+] WATH SHOULD WE GET :"); 260 | printf(HEAVENLY " %s\n" RESET, res); 261 | char *y_res = ft_strchr(test_a, test_b); 262 | printf("[+] WATH YOURS FUNCTOINS GET :"); 263 | printf(HEAVENLY " %s\n\n" RESET, y_res); 264 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 265 | { 266 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 267 | return (1); 268 | } 269 | else 270 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 271 | return (0); 272 | } 273 | int test10() 274 | { 275 | printf(YELLOW "==============================================\n" RESET); 276 | printf(YELLOW "= ft_strchr =\n" RESET); 277 | printf(YELLOW "==============================================\n\n" RESET); 278 | printf("[+] THE TEST NUMBER : 10 !!\n"); 279 | char test_a[] = ""; 280 | char test_b = '0'; 281 | printf("[+] WATH WE HAVE :"); 282 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 283 | char *res = strchr(test_a, test_b); 284 | printf("[+] WATH SHOULD WE GET :"); 285 | printf(HEAVENLY " %s\n" RESET, res); 286 | char *y_res = ft_strchr(test_a, test_b); 287 | printf("[+] WATH YOURS FUNCTOINS GET :"); 288 | printf(HEAVENLY " %s\n\n" RESET, y_res); 289 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 290 | { 291 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 292 | return (1); 293 | } 294 | else 295 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 296 | return (0); 297 | } 298 | 299 | int test11() 300 | { 301 | printf(YELLOW "==============================================\n" RESET); 302 | printf(YELLOW "= ft_strchr =\n" RESET); 303 | printf(YELLOW "==============================================\n\n" RESET); 304 | printf("[+] THE TEST NUMBER : 11 !!\n"); 305 | char test_a[] = "0"; 306 | char test_b = -1; 307 | printf("[+] WATH WE HAVE :"); 308 | printf(HEAVENLY "str : [%s] | to_find : [%d] (in intger form)\n" RESET, test_a, test_b); 309 | char *res = strchr(test_a, test_b); 310 | printf("[+] WATH SHOULD WE GET :"); 311 | printf(HEAVENLY " %s\n" RESET, res); 312 | char *y_res = ft_strchr(test_a, test_b); 313 | printf("[+] WATH YOURS FUNCTOINS GET :"); 314 | printf(HEAVENLY " %s\n\n" RESET, y_res); 315 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 316 | { 317 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 318 | return (1); 319 | } 320 | else 321 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 322 | return (0); 323 | } 324 | 325 | int main() 326 | { 327 | int c; 328 | c = 0; 329 | int t0 = test0(); 330 | sleep(1); 331 | int t1 = test1(); 332 | sleep(1); 333 | int t2 = test2(); 334 | sleep(1); 335 | int t3 = test3(); 336 | sleep(1); 337 | int t4 = test4(); 338 | sleep(1); 339 | int t5 = test5(); 340 | sleep(1); 341 | int t6 = test6(); 342 | sleep(1); 343 | int t7 = test7(); 344 | sleep(1); 345 | int t8 = test8(); 346 | sleep(1); 347 | int t9 = test9(); 348 | sleep(1); 349 | int t10 = test10(); 350 | sleep(1); 351 | int t11 = test11(); 352 | sleep(1); 353 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 354 | printf(PERPUL "==============================================\n" RESET); 355 | if (c == 12) 356 | { 357 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 358 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 359 | } 360 | else 361 | { 362 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 363 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 364 | } 365 | printf(HEAVENLY "ALL TEST : " RESET); 366 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 367 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 368 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 369 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 370 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 371 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 372 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 373 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 374 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 375 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 376 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 377 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 378 | printf(PERPUL "==============================================\n\n" RESET); 379 | } 380 | -------------------------------------------------------------------------------- /test/Libc_functions/strlen/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_strlen =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | char *test = "12fqdsfdq34"; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %s\n" RESET, test); 22 | int res = strlen(test) ; 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %d\n" RESET, res); 25 | int y_res = ft_strlen(test); 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %d\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_strlen =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | char *test = ""; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %s \n" RESET, test); 48 | int res = strlen(test); 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %d\n" RESET, res); 51 | int y_res = ft_strlen(test); 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %d\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_strlen =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | char *test = "-\x052va0a0"; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %s \n" RESET, test); 73 | int res = strlen(test); 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %d\n" RESET, res); 76 | int y_res = ft_strlen(test); 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %d\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | 89 | int test3() 90 | { 91 | printf(YELLOW "==============================================\n" RESET); 92 | printf(YELLOW "= ft_strlen =\n" RESET); 93 | printf(YELLOW "==============================================\n\n" RESET); 94 | printf("[+] THE TEST NUMBER : 3 !!\n"); 95 | char *test = "0"; 96 | printf("[+] WATH WE HAVE :"); 97 | printf(HEAVENLY " %s \n" RESET, test); 98 | int res = strlen(test); 99 | printf("[+] WATH SHOULD WE GET :"); 100 | printf(HEAVENLY " %d\n" RESET, res); 101 | int y_res = ft_strlen(test); 102 | printf("[+] WATH YOURS FUNCTOINS GET :"); 103 | printf(HEAVENLY " %d\n\n" RESET, y_res); 104 | if (y_res == res) 105 | { 106 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 107 | return (1); 108 | } 109 | else 110 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 111 | return (0); 112 | } 113 | 114 | int test4() 115 | { 116 | printf(YELLOW "==============================================\n" RESET); 117 | printf(YELLOW "= ft_strlen =\n" RESET); 118 | printf(YELLOW "==============================================\n\n" RESET); 119 | printf("[+] THE TEST NUMBER : 4 !!\n"); 120 | char *test = "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!"; 121 | printf("[+] WATH WE HAVE :"); 122 | printf(HEAVENLY " %s\n" RESET, test); 123 | int res = strlen(test); 124 | printf("[+] WATH SHOULD WE GET :"); 125 | printf(HEAVENLY " %d\n" RESET, res); 126 | int y_res = ft_strlen(test); 127 | printf("[+] WATH YOURS FUNCTOINS GET :"); 128 | printf(HEAVENLY " %d\n\n" RESET, y_res); 129 | if (y_res == res) 130 | { 131 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 132 | return (1); 133 | } 134 | else 135 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 136 | return (0); 137 | } 138 | 139 | int test5() 140 | { 141 | printf(YELLOW "==============================================\n" RESET); 142 | printf(YELLOW "= ft_strlen =\n" RESET); 143 | printf(YELLOW "==============================================\n\n" RESET); 144 | printf("[+] THE TEST NUMBER : 5 !!\n"); 145 | char *test = "1234567890123abcd"; 146 | printf("[+] WATH WE HAVE :"); 147 | printf(HEAVENLY " %s\n" RESET, test); 148 | int res = strlen(test); 149 | printf("[+] WATH SHOULD WE GET :"); 150 | printf(HEAVENLY " %d\n" RESET, res); 151 | int y_res = ft_strlen(test); 152 | printf("[+] WATH YOURS FUNCTOINS GET :"); 153 | printf(HEAVENLY " %d\n\n" RESET, y_res); 154 | if (y_res == res) 155 | { 156 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 157 | return (1); 158 | } 159 | else 160 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 161 | return (0); 162 | } 163 | 164 | int test6() 165 | { 166 | printf(YELLOW "==============================================\n" RESET); 167 | printf(YELLOW "= ft_strlen =\n" RESET); 168 | printf(YELLOW "==============================================\n\n" RESET); 169 | printf("[+] THE TEST NUMBER : 6 !!\n"); 170 | char *test = "sfqsfq2147483647"; 171 | printf("[+] WATH WE HAVE :"); 172 | printf(HEAVENLY " %s\n" RESET, test); 173 | int res = strlen(test); 174 | printf("[+] WATH SHOULD WE GET :"); 175 | printf(HEAVENLY " %d\n" RESET, res); 176 | int y_res = ft_strlen(test); 177 | printf("[+] WATH YOURS FUNCTOINS GET :"); 178 | printf(HEAVENLY " %d\n\n" RESET, y_res); 179 | if (y_res == res) 180 | { 181 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 182 | return (1); 183 | } 184 | else 185 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 186 | return (0); 187 | } 188 | 189 | int test7() 190 | { 191 | printf(YELLOW "==============================================\n" RESET); 192 | printf(YELLOW "= ft_strlen =\n" RESET); 193 | printf(YELLOW "==============================================\n\n" RESET); 194 | printf("[+] THE TEST NUMBER : 7 !!\n"); 195 | char *test = "faefa2147483648"; 196 | printf("[+] WATH WE HAVE :"); 197 | printf(HEAVENLY " %s\n" RESET, test); 198 | int res = strlen(test); 199 | printf("[+] WATH SHOULD WE GET :"); 200 | printf(HEAVENLY " %d\n" RESET, res); 201 | int y_res = ft_strlen(test); 202 | printf("[+] WATH YOURS FUNCTOINS GET :"); 203 | printf(HEAVENLY " %d\n\n" RESET, y_res); 204 | if (y_res == res) 205 | { 206 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 207 | return (1); 208 | } 209 | else 210 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 211 | return (0); 212 | } 213 | 214 | int test8() 215 | { 216 | printf(YELLOW "==============================================\n" RESET); 217 | printf(YELLOW "= ft_strlen =\n" RESET); 218 | printf(YELLOW "==============================================\n\n" RESET); 219 | printf("[+] THE TEST NUMBER : 8 !!\n"); 220 | char *test = "thes test is strlen"; 221 | printf("[+] WATH WE HAVE :"); 222 | printf(HEAVENLY " %s\n" RESET, test); 223 | int res = strlen(test); 224 | printf("[+] WATH SHOULD WE GET :"); 225 | printf(HEAVENLY " %d\n" RESET, res); 226 | int y_res = ft_strlen(test); 227 | printf("[+] WATH YOURS FUNCTOINS GET :"); 228 | printf(HEAVENLY " %d\n\n" RESET, y_res); 229 | if (y_res == res) 230 | { 231 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 232 | return (1); 233 | } 234 | else 235 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 236 | return (0); 237 | } 238 | int test9() 239 | { 240 | printf(YELLOW "==============================================\n" RESET); 241 | printf(YELLOW "= ft_strlen =\n" RESET); 242 | printf(YELLOW "==============================================\n\n" RESET); 243 | printf("[+] THE TEST NUMBER : 9 !!\n"); 244 | char *test = "' ---1234s545'"; 245 | printf("[+] WATH WE HAVE :"); 246 | printf(HEAVENLY " %s\n" RESET, test); 247 | int res = strlen(test); 248 | printf("[+] WATH SHOULD WE GET :"); 249 | printf(HEAVENLY " %d\n" RESET, res); 250 | int y_res = ft_strlen(test); 251 | printf("[+] WATH YOURS FUNCTOINS GET :"); 252 | printf(HEAVENLY " %d\n\n" RESET, y_res); 253 | if (y_res == res) 254 | { 255 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 256 | return (1); 257 | } 258 | else 259 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 260 | return (0); 261 | } 262 | int test10() 263 | { 264 | printf(YELLOW "==============================================\n" RESET); 265 | printf(YELLOW "= ft_strlen =\n" RESET); 266 | printf(YELLOW "==============================================\n\n" RESET); 267 | printf("[+] THE TEST NUMBER : 10 !!\n"); 268 | char *test = "214748364+8"; 269 | printf("[+] WATH WE HAVE :"); 270 | printf(HEAVENLY " %s\n" RESET, test); 271 | int res = strlen(test); 272 | printf("[+] WATH SHOULD WE GET :"); 273 | printf(HEAVENLY " %d\n" RESET, res); 274 | int y_res = ft_strlen(test); 275 | printf("[+] WATH YOURS FUNCTOINS GET :"); 276 | printf(HEAVENLY " %d\n\n" RESET, y_res); 277 | if (y_res == res) 278 | { 279 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 280 | return (1); 281 | } 282 | else 283 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 284 | return (0); 285 | } 286 | 287 | int test11() 288 | { 289 | printf(YELLOW "==============================================\n" RESET); 290 | printf(YELLOW "= ft_strlen =\n" RESET); 291 | printf(YELLOW "==============================================\n\n" RESET); 292 | printf("[+] THE TEST NUMBER : 11 !!\n"); 293 | char *test = ". ."; 294 | printf("[+] WATH WE HAVE :"); 295 | printf(HEAVENLY " %s\n" RESET, test); 296 | int res = strlen(test); 297 | printf("[+] WATH SHOULD WE GET :"); 298 | printf(HEAVENLY " %d\n" RESET, res); 299 | int y_res = ft_strlen(test); 300 | printf("[+] WATH YOURS FUNCTOINS GET :"); 301 | printf(HEAVENLY " %d\n\n" RESET, y_res); 302 | if (y_res == res) 303 | { 304 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 305 | return (1); 306 | } 307 | else 308 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 309 | return (0); 310 | } 311 | 312 | int main() 313 | { 314 | int c; 315 | c = 0; 316 | int t0 = test0(); 317 | sleep(1); 318 | int t1 = test1(); 319 | sleep(1); 320 | int t2 = test2(); 321 | sleep(1); 322 | int t3 = test3(); 323 | sleep(1); 324 | int t4 = test4(); 325 | sleep(1); 326 | int t5 = test5(); 327 | sleep(1); 328 | int t6 = test6(); 329 | sleep(1); 330 | int t7 = test7(); 331 | sleep(1); 332 | int t8 = test8(); 333 | sleep(1); 334 | int t9 = test9(); 335 | sleep(1); 336 | int t10 = test10(); 337 | sleep(1); 338 | int t11 = test11(); 339 | sleep(1); 340 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 341 | printf(PERPUL "==============================================\n" RESET); 342 | if (c == 12) 343 | { 344 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 345 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 346 | } 347 | else 348 | { 349 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 350 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 351 | } 352 | printf(HEAVENLY "ALL TEST : " RESET); 353 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 354 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 355 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 356 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 357 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 358 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 359 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 360 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 361 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 362 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 363 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 364 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 365 | printf(PERPUL "==============================================\n\n" RESET); 366 | } 367 | -------------------------------------------------------------------------------- /test/Libc_functions/strncmp/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_strncmp =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | char *test_a = "1234"; 20 | char *test_b = "1234"; 21 | unsigned int n = 4; 22 | printf("[+] WATH WE HAVE :"); 23 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 24 | int res = strncmp(test_a, test_b, n) ; 25 | printf("[+] WATH SHOULD WE GET :"); 26 | printf(HEAVENLY " %d\n" RESET, res); 27 | int y_res = ft_strncmp(test_a, test_b, n); 28 | printf("[+] WATH YOURS FUNCTOINS GET :"); 29 | printf(HEAVENLY " %d\n\n" RESET, y_res); 30 | if (y_res == res) 31 | { 32 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 33 | return (1); 34 | } 35 | else 36 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 37 | return (0); 38 | } 39 | 40 | 41 | int test1() 42 | { 43 | printf(YELLOW "==============================================\n" RESET); 44 | printf(YELLOW "= ft_strncmp =\n" RESET); 45 | printf(YELLOW "==============================================\n\n" RESET); 46 | printf("[+] THE TEST NUMBER : 1 !!\n"); 47 | char *test_a = "1234"; 48 | char *test_b = "1234"; 49 | unsigned int n = 3; 50 | printf("[+] WATH WE HAVE :"); 51 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 52 | int res = strncmp(test_a, test_b, n); 53 | printf("[+] WATH SHOULD WE GET :"); 54 | printf(HEAVENLY " %d\n" RESET, res); 55 | int y_res = ft_strncmp(test_a, test_b, n); 56 | printf("[+] WATH YOURS FUNCTOINS GET :"); 57 | printf(HEAVENLY " %d\n\n" RESET, y_res); 58 | if (y_res == res) 59 | { 60 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 61 | return (1); 62 | } 63 | else 64 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 65 | return (0); 66 | } 67 | 68 | int test2() 69 | { 70 | printf(YELLOW "==============================================\n" RESET); 71 | printf(YELLOW "= ft_strncmp =\n" RESET); 72 | printf(YELLOW "==============================================\n\n" RESET); 73 | printf("[+] THE TEST NUMBER : 2 !!\n"); 74 | char *test_a = "1234"; 75 | char *test_b = "1234"; 76 | unsigned int n = 5; 77 | printf("[+] WATH WE HAVE :"); 78 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 79 | int res = strncmp(test_a, test_b, n); 80 | printf("[+] WATH SHOULD WE GET :"); 81 | printf(HEAVENLY " %d\n" RESET, res); 82 | int y_res = ft_strncmp(test_a, test_b, n); 83 | printf("[+] WATH YOURS FUNCTOINS GET :"); 84 | printf(HEAVENLY " %d\n\n" RESET, y_res); 85 | if (y_res == res) 86 | { 87 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 88 | return (1); 89 | } 90 | else 91 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 92 | return (0); 93 | } 94 | 95 | int test3() 96 | { 97 | printf(YELLOW "==============================================\n" RESET); 98 | printf(YELLOW "= ft_strncmp =\n" RESET); 99 | printf(YELLOW "==============================================\n\n" RESET); 100 | printf("[+] THE TEST NUMBER : 3 !!\n"); 101 | char *test_a = "1234"; 102 | char *test_b = "1234"; 103 | unsigned int n = 6; 104 | printf("[+] WATH WE HAVE :"); 105 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 106 | int res = strncmp(test_a, test_b, n); 107 | printf("[+] WATH SHOULD WE GET :"); 108 | printf(HEAVENLY " %d\n" RESET, res); 109 | int y_res = ft_strncmp(test_a, test_b, n); 110 | printf("[+] WATH YOURS FUNCTOINS GET :"); 111 | printf(HEAVENLY " %d\n\n" RESET, y_res); 112 | if (y_res == res) 113 | { 114 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 115 | return (1); 116 | } 117 | else 118 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 119 | return (0); 120 | } 121 | 122 | int test4() 123 | { 124 | printf(YELLOW "==============================================\n" RESET); 125 | printf(YELLOW "= ft_strncmp =\n" RESET); 126 | printf(YELLOW "==============================================\n\n" RESET); 127 | printf("[+] THE TEST NUMBER : 4 !!\n"); 128 | char *test_a = "abdefg"; 129 | char *test_b = "1234"; 130 | unsigned int n = 10; 131 | printf("[+] WATH WE HAVE :"); 132 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 133 | int res = strncmp(test_a, test_b, n); 134 | printf("[+] WATH SHOULD WE GET :"); 135 | printf(HEAVENLY " %d\n" RESET, res); 136 | int y_res = ft_strncmp(test_a, test_b, n); 137 | printf("[+] WATH YOURS FUNCTOINS GET :"); 138 | printf(HEAVENLY " %d\n\n" RESET, y_res); 139 | if (y_res == res) 140 | { 141 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 142 | return (1); 143 | } 144 | else 145 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 146 | return (0); 147 | } 148 | 149 | int test5() 150 | { 151 | printf(YELLOW "==============================================\n" RESET); 152 | printf(YELLOW "= ft_strncmp =\n" RESET); 153 | printf(YELLOW "==============================================\n\n" RESET); 154 | printf("[+] THE TEST NUMBER : 5 !!\n"); 155 | char *test_a = "he what are u doing *-*"; 156 | char *test_b = "he what are you doing *-*"; 157 | unsigned int n = strlen(test_a); 158 | printf("[+] WATH WE HAVE :"); 159 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 160 | int res = strncmp(test_a, test_b, n); 161 | printf("[+] WATH SHOULD WE GET :"); 162 | printf(HEAVENLY " %d\n" RESET, res); 163 | int y_res = ft_strncmp(test_a, test_b, n); 164 | printf("[+] WATH YOURS FUNCTOINS GET :"); 165 | printf(HEAVENLY " %d\n\n" RESET, y_res); 166 | if (y_res == res) 167 | { 168 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 169 | return (1); 170 | } 171 | else 172 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 173 | return (0); 174 | } 175 | 176 | int test6() 177 | { 178 | printf(YELLOW "==============================================\n" RESET); 179 | printf(YELLOW "= ft_strncmp =\n" RESET); 180 | printf(YELLOW "==============================================\n\n" RESET); 181 | printf("[+] THE TEST NUMBER : 6 !!\n"); 182 | char *test_a = "good work bro !!"; 183 | char *test_b = "good work bro !!"; 184 | unsigned int n = 0; 185 | printf("[+] WATH WE HAVE :"); 186 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 187 | int res = strncmp(test_a, test_b, n); 188 | printf("[+] WATH SHOULD WE GET :"); 189 | printf(HEAVENLY " %d\n" RESET, res); 190 | int y_res = ft_strncmp(test_a, test_b, n); 191 | printf("[+] WATH YOURS FUNCTOINS GET :"); 192 | printf(HEAVENLY " %d\n\n" RESET, y_res); 193 | if (y_res == res) 194 | { 195 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 196 | return (1); 197 | } 198 | else 199 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 200 | return (0); 201 | } 202 | 203 | int test7() 204 | { 205 | printf(YELLOW "==============================================\n" RESET); 206 | printf(YELLOW "= ft_strncmp =\n" RESET); 207 | printf(YELLOW "==============================================\n\n" RESET); 208 | printf("[+] THE TEST NUMBER : 7 !!\n"); 209 | char *test_a = "hi good\x4programmer"; 210 | char *test_b = "hi good\x1programmer"; 211 | unsigned int n = strlen(test_a); 212 | printf("[+] WATH WE HAVE :"); 213 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 214 | int res = strncmp(test_a, test_b, n); 215 | printf("[+] WATH SHOULD WE GET :"); 216 | printf(HEAVENLY " %d\n" RESET, res); 217 | int y_res = ft_strncmp(test_a, test_b, n); 218 | printf("[+] WATH YOURS FUNCTOINS GET :"); 219 | printf(HEAVENLY " %d\n\n" RESET, y_res); 220 | if (y_res == res) 221 | { 222 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 223 | return (1); 224 | } 225 | else 226 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 227 | return (0); 228 | } 229 | 230 | int test8() 231 | { 232 | printf(YELLOW "==============================================\n" RESET); 233 | printf(YELLOW "= ft_strncmp =\n" RESET); 234 | printf(YELLOW "==============================================\n\n" RESET); 235 | printf("[+] THE TEST NUMBER : 8 !!\n"); 236 | char *test_a = "123456789"; 237 | char *test_b = "123465789"; 238 | unsigned int n = 10; 239 | printf("[+] WATH WE HAVE :"); 240 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 241 | int res = strncmp(test_a, test_b, n); 242 | printf("[+] WATH SHOULD WE GET :"); 243 | printf(HEAVENLY " %d\n" RESET, res); 244 | int y_res = ft_strncmp(test_a, test_b, n); 245 | printf("[+] WATH YOURS FUNCTOINS GET :"); 246 | printf(HEAVENLY " %d\n\n" RESET, y_res); 247 | if (y_res == res) 248 | { 249 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 250 | return (1); 251 | } 252 | else 253 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 254 | return (0); 255 | } 256 | int test9() 257 | { 258 | printf(YELLOW "==============================================\n" RESET); 259 | printf(YELLOW "= ft_strncmp =\n" RESET); 260 | printf(YELLOW "==============================================\n\n" RESET); 261 | printf("[+] THE TEST NUMBER : 9 !!\n"); 262 | char *test_a = "123456987"; 263 | char *test_b = "12346987"; 264 | unsigned int n = 5; 265 | printf("[+] WATH WE HAVE :"); 266 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 267 | int res = strncmp(test_a, test_b, n); 268 | printf("[+] WATH SHOULD WE GET :"); 269 | printf(HEAVENLY " %d\n" RESET, res); 270 | int y_res = ft_strncmp(test_a, test_b, n); 271 | printf("[+] WATH YOURS FUNCTOINS GET :"); 272 | printf(HEAVENLY " %d\n\n" RESET, y_res); 273 | if (y_res == res) 274 | { 275 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 276 | return (1); 277 | } 278 | else 279 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 280 | return (0); 281 | } 282 | int test10() 283 | { 284 | printf(YELLOW "==============================================\n" RESET); 285 | printf(YELLOW "= ft_strncmp =\n" RESET); 286 | printf(YELLOW "==============================================\n\n" RESET); 287 | printf("[+] THE TEST NUMBER : 10 !!\n"); 288 | char *test_a = ""; 289 | char *test_b = "1234"; 290 | unsigned int n = 5; 291 | printf("[+] WATH WE HAVE :"); 292 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 293 | int res = strncmp(test_a, test_b, n); 294 | printf("[+] WATH SHOULD WE GET :"); 295 | printf(HEAVENLY " %d\n" RESET, res); 296 | int y_res = ft_strncmp(test_a, test_b, n); 297 | printf("[+] WATH YOURS FUNCTOINS GET :"); 298 | printf(HEAVENLY " %d\n\n" RESET, y_res); 299 | if (y_res == res) 300 | { 301 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 302 | return (1); 303 | } 304 | else 305 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 306 | return (0); 307 | } 308 | 309 | int test11() 310 | { 311 | printf(YELLOW "==============================================\n" RESET); 312 | printf(YELLOW "= ft_strncmp =\n" RESET); 313 | printf(YELLOW "==============================================\n\n" RESET); 314 | printf("[+] THE TEST NUMBER : 11 !!\n"); 315 | char *test_a = ""; 316 | char *test_b = ""; 317 | unsigned int n = 100; 318 | printf("[+] WATH WE HAVE :"); 319 | printf(HEAVENLY "s1 : [%s] | s2 : [%s] | n : [%d]\n" RESET, test_a, test_b, n); 320 | int res = strncmp(test_a, test_b, n); 321 | printf("[+] WATH SHOULD WE GET :"); 322 | printf(HEAVENLY " %d\n" RESET, res); 323 | int y_res = ft_strncmp(test_a, test_b, n); 324 | printf("[+] WATH YOURS FUNCTOINS GET :"); 325 | printf(HEAVENLY " %d\n\n" RESET, y_res); 326 | if (y_res == res) 327 | { 328 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 329 | return (1); 330 | } 331 | else 332 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 333 | return (0); 334 | } 335 | 336 | int main() 337 | { 338 | int c; 339 | c = 0; 340 | int t0 = test0(); 341 | sleep(1); 342 | int t1 = test1(); 343 | sleep(1); 344 | int t2 = test2(); 345 | sleep(1); 346 | int t3 = test3(); 347 | sleep(1); 348 | int t4 = test4(); 349 | sleep(1); 350 | int t5 = test5(); 351 | sleep(1); 352 | int t6 = test6(); 353 | sleep(1); 354 | int t7 = test7(); 355 | sleep(1); 356 | int t8 = test8(); 357 | sleep(1); 358 | int t9 = test9(); 359 | sleep(1); 360 | int t10 = test10(); 361 | sleep(1); 362 | int t11 = test11(); 363 | sleep(1); 364 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 365 | printf(PERPUL "==============================================\n" RESET); 366 | if (c == 12) 367 | { 368 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 369 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 370 | } 371 | else 372 | { 373 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 374 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 375 | } 376 | printf(HEAVENLY "ALL TEST : " RESET); 377 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 378 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 379 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 380 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 381 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 382 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 383 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 384 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 385 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 386 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 387 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 388 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 389 | printf(PERPUL "==============================================\n\n" RESET); 390 | } 391 | -------------------------------------------------------------------------------- /test/Libc_functions/strrchr/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../../src/libft.h" 6 | 7 | #define RED "\033[0;31m" 8 | #define GREEN "\033[0;32m" 9 | #define RESET "\033[0m" 10 | #define YELLOW "\033[0;33m" 11 | #define HEAVENLY "\033[0;36m" 12 | #define PERPUL "\033[0;35m" 13 | 14 | int test0() 15 | { 16 | printf(YELLOW "==============================================\n" RESET); 17 | printf(YELLOW "= ft_strrchr =\n" RESET); 18 | printf(YELLOW "==============================================\n\n" RESET); 19 | printf("[+] THE TEST NUMBER : 0 !!\n"); 20 | char *test_a = "145648132148456325615131234"; 21 | char test_b = '5'; 22 | printf("[+] WATH WE HAVE :"); 23 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 24 | char *res = strrchr(test_a, test_b) ; 25 | printf("[+] WATH SHOULD WE GET :"); 26 | printf(HEAVENLY " %s\n" RESET, res); 27 | char *y_res = ft_strrchr(test_a, test_b); 28 | printf("[+] WATH YOURS FUNCTOINS GET :"); 29 | printf(HEAVENLY " %s\n\n" RESET, y_res); 30 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 31 | { 32 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 33 | return (1); 34 | } 35 | else 36 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 37 | return (0); 38 | } 39 | 40 | 41 | int test1() 42 | { 43 | printf(YELLOW "==============================================\n" RESET); 44 | printf(YELLOW "= ft_strrchr =\n" RESET); 45 | printf(YELLOW "==============================================\n\n" RESET); 46 | printf("[+] THE TEST NUMBER : 1 !!\n"); 47 | char *test_a = "10234"; 48 | char test_b = '1'; 49 | printf("[+] WATH WE HAVE :"); 50 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 51 | char *res = strrchr(test_a, test_b); 52 | printf("[+] WATH SHOULD WE GET :"); 53 | printf(HEAVENLY " %s\n" RESET, res); 54 | char *y_res = ft_strrchr(test_a, test_b); 55 | printf("[+] WATH YOURS FUNCTOINS GET :"); 56 | printf(HEAVENLY " %s\n\n" RESET, y_res); 57 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 58 | { 59 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 60 | return (1); 61 | } 62 | else 63 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 64 | return (0); 65 | } 66 | 67 | int test2() 68 | { 69 | printf(YELLOW "==============================================\n" RESET); 70 | printf(YELLOW "= ft_strrchr =\n" RESET); 71 | printf(YELLOW "==============================================\n\n" RESET); 72 | printf("[+] THE TEST NUMBER : 2 !!\n"); 73 | char *test_a = "1234"; 74 | char test_b = '0'; 75 | printf("[+] WATH WE HAVE :"); 76 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 77 | char *res = strrchr(test_a, test_b); 78 | printf("[+] WATH SHOULD WE GET :"); 79 | printf(HEAVENLY " %s\n" RESET, res); 80 | char *y_res = ft_strrchr(test_a, test_b); 81 | printf("[+] WATH YOURS FUNCTOINS GET :"); 82 | printf(HEAVENLY " %s\n\n" RESET, y_res); 83 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 84 | { 85 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 86 | return (1); 87 | } 88 | else 89 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 90 | return (0); 91 | } 92 | 93 | int test3() 94 | { 95 | printf(YELLOW "==============================================\n" RESET); 96 | printf(YELLOW "= ft_strrchr =\n" RESET); 97 | printf(YELLOW "==============================================\n\n" RESET); 98 | printf("[+] THE TEST NUMBER : 3 !!\n"); 99 | char *test_a = "1234"; 100 | char test_b = '\0'; 101 | printf("[+] WATH WE HAVE :"); 102 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 103 | char *res = strrchr(test_a, test_b); 104 | printf("[+] WATH SHOULD WE GET :"); 105 | printf(HEAVENLY " %s\n" RESET, res); 106 | char *y_res = ft_strrchr(test_a, test_b); 107 | printf("[+] WATH YOURS FUNCTOINS GET :"); 108 | printf(HEAVENLY " %s\n\n" RESET, y_res); 109 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 110 | { 111 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 112 | return (1); 113 | } 114 | else 115 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 116 | return (0); 117 | } 118 | 119 | int test4() 120 | { 121 | printf(YELLOW "==============================================\n" RESET); 122 | printf(YELLOW "= ft_strrchr =\n" RESET); 123 | printf(YELLOW "==============================================\n\n" RESET); 124 | printf("[+] THE TEST NUMBER : 4 !!\n"); 125 | char *test_a = "abdefg"; 126 | char test_b = '5'; 127 | printf("[+] WATH WE HAVE :"); 128 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 129 | char *res = strrchr(test_a, test_b); 130 | printf("[+] WATH SHOULD WE GET :"); 131 | printf(HEAVENLY " %s\n" RESET, res); 132 | char *y_res = ft_strrchr(test_a, test_b); 133 | printf("[+] WATH YOURS FUNCTOINS GET :"); 134 | printf(HEAVENLY " %s\n\n" RESET, y_res); 135 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 136 | { 137 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 138 | return (1); 139 | } 140 | else 141 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 142 | return (0); 143 | } 144 | 145 | int test5() 146 | { 147 | printf(YELLOW "==============================================\n" RESET); 148 | printf(YELLOW "= ft_strrchr =\n" RESET); 149 | printf(YELLOW "==============================================\n\n" RESET); 150 | printf("[+] THE TEST NUMBER : 5 !!\n"); 151 | char *test_a = "he what are u doing *-*"; 152 | char test_b = ' '; 153 | printf("[+] WATH WE HAVE :"); 154 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 155 | char *res = strrchr(test_a, test_b); 156 | printf("[+] WATH SHOULD WE GET :"); 157 | printf(HEAVENLY " %s\n" RESET, res); 158 | char *y_res = ft_strrchr(test_a, test_b); 159 | printf("[+] WATH YOURS FUNCTOINS GET :"); 160 | printf(HEAVENLY " %s\n\n" RESET, y_res); 161 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 162 | { 163 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 164 | return (1); 165 | } 166 | else 167 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 168 | return (0); 169 | } 170 | 171 | int test6() 172 | { 173 | printf(YELLOW "==============================================\n" RESET); 174 | printf(YELLOW "= ft_strrchr =\n" RESET); 175 | printf(YELLOW "==============================================\n\n" RESET); 176 | printf("[+] THE TEST NUMBER : 6 !!\n"); 177 | char *test_a = "good work bro !!"; 178 | char test_b = 'w'; 179 | printf("[+] WATH WE HAVE :"); 180 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 181 | char *res = strrchr(test_a, test_b); 182 | printf("[+] WATH SHOULD WE GET :"); 183 | printf(HEAVENLY " %s\n" RESET, res); 184 | char *y_res = ft_strrchr(test_a, test_b); 185 | printf("[+] WATH YOURS FUNCTOINS GET :"); 186 | printf(HEAVENLY " %s\n\n" RESET, y_res); 187 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 188 | { 189 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 190 | return (1); 191 | } 192 | else 193 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 194 | return (0); 195 | } 196 | 197 | int test7() 198 | { 199 | printf(YELLOW "==============================================\n" RESET); 200 | printf(YELLOW "= ft_strrchr =\n" RESET); 201 | printf(YELLOW "==============================================\n\n" RESET); 202 | printf("[+] THE TEST NUMBER : 7 !!\n"); 203 | char *test_a = "hi good\x4programmer"; 204 | char test_b = '\x4'; 205 | printf("[+] WATH WE HAVE :"); 206 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 207 | char *res = strrchr(test_a, test_b); 208 | printf("[+] WATH SHOULD WE GET :"); 209 | printf(HEAVENLY " %s\n" RESET, res); 210 | char *y_res = ft_strrchr(test_a, test_b); 211 | printf("[+] WATH YOURS FUNCTOINS GET :"); 212 | printf(HEAVENLY " %s\n\n" RESET, y_res); 213 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 214 | { 215 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 216 | return (1); 217 | } 218 | else 219 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 220 | return (0); 221 | } 222 | 223 | int test8() 224 | { 225 | printf(YELLOW "==============================================\n" RESET); 226 | printf(YELLOW "= ft_strrchr =\n" RESET); 227 | printf(YELLOW "==============================================\n\n" RESET); 228 | printf("[+] THE TEST NUMBER : 8 !!\n"); 229 | char *test_a = "121314a115a1167da15zad819"; 230 | char test_b = 'a'; 231 | printf("[+] WATH WE HAVE :"); 232 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 233 | char *res = strrchr(test_a, test_b); 234 | printf("[+] WATH SHOULD WE GET :"); 235 | printf(HEAVENLY " %s\n" RESET, res); 236 | char *y_res = ft_strrchr(test_a, test_b); 237 | printf("[+] WATH YOURS FUNCTOINS GET :"); 238 | printf(HEAVENLY " %s\n\n" RESET, y_res); 239 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 240 | { 241 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 242 | return (1); 243 | } 244 | else 245 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 246 | return (0); 247 | } 248 | int test9() 249 | { 250 | printf(YELLOW "==============================================\n" RESET); 251 | printf(YELLOW "= ft_strrchr =\n" RESET); 252 | printf(YELLOW "==============================================\n\n" RESET); 253 | printf("[+] THE TEST NUMBER : 9 !!\n"); 254 | char *test_a = "+-+-+-+-+0-0----"; 255 | char test_b = '+'; 256 | printf("[+] WATH WE HAVE :"); 257 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 258 | char *res = strrchr(test_a, test_b); 259 | printf("[+] WATH SHOULD WE GET :"); 260 | printf(HEAVENLY " %s\n" RESET, res); 261 | char *y_res = ft_strrchr(test_a, test_b); 262 | printf("[+] WATH YOURS FUNCTOINS GET :"); 263 | printf(HEAVENLY " %s\n\n" RESET, y_res); 264 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 265 | { 266 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 267 | return (1); 268 | } 269 | else 270 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 271 | return (0); 272 | } 273 | int test10() 274 | { 275 | printf(YELLOW "==============================================\n" RESET); 276 | printf(YELLOW "= ft_strrchr =\n" RESET); 277 | printf(YELLOW "==============================================\n\n" RESET); 278 | printf("[+] THE TEST NUMBER : 10 !!\n"); 279 | char *test_a = ""; 280 | char test_b = '0'; 281 | printf("[+] WATH WE HAVE :"); 282 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 283 | char *res = strrchr(test_a, test_b); 284 | printf("[+] WATH SHOULD WE GET :"); 285 | printf(HEAVENLY " %s\n" RESET, res); 286 | char *y_res = ft_strrchr(test_a, test_b); 287 | printf("[+] WATH YOURS FUNCTOINS GET :"); 288 | printf(HEAVENLY " %s\n\n" RESET, y_res); 289 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 290 | { 291 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 292 | return (1); 293 | } 294 | else 295 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 296 | return (0); 297 | } 298 | 299 | int test11() 300 | { 301 | printf(YELLOW "==============================================\n" RESET); 302 | printf(YELLOW "= ft_strrchr =\n" RESET); 303 | printf(YELLOW "==============================================\n\n" RESET); 304 | printf("[+] THE TEST NUMBER : 11 !!\n"); 305 | char *test_a = "0"; 306 | char test_b = -1; 307 | printf("[+] WATH WE HAVE :"); 308 | printf(HEAVENLY "str : [%s] | to_find : [%c]\n" RESET, test_a, test_b); 309 | char *res = strrchr(test_a, test_b); 310 | printf("[+] WATH SHOULD WE GET :"); 311 | printf(HEAVENLY " %s\n" RESET, res); 312 | char *y_res = ft_strrchr(test_a, test_b); 313 | printf("[+] WATH YOURS FUNCTOINS GET :"); 314 | printf(HEAVENLY " %s\n\n" RESET, y_res); 315 | if ((res == y_res) || (strcmp(res, y_res) == 0)) 316 | { 317 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 318 | return (1); 319 | } 320 | else 321 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 322 | return (0); 323 | } 324 | 325 | int main() 326 | { 327 | int c; 328 | c = 0; 329 | int t0 = test0(); 330 | sleep(1); 331 | int t1 = test1(); 332 | sleep(1); 333 | int t2 = test2(); 334 | sleep(1); 335 | int t3 = test3(); 336 | sleep(1); 337 | int t4 = test4(); 338 | sleep(1); 339 | int t5 = test5(); 340 | sleep(1); 341 | int t6 = test6(); 342 | sleep(1); 343 | int t7 = test7(); 344 | sleep(1); 345 | int t8 = test8(); 346 | sleep(1); 347 | int t9 = test9(); 348 | sleep(1); 349 | int t10 = test10(); 350 | sleep(1); 351 | int t11 = test11(); 352 | sleep(1); 353 | c = t0 + t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11; 354 | printf(PERPUL "==============================================\n" RESET); 355 | if (c == 12) 356 | { 357 | printf(GREEN "THE RESULTE IS : [%d/12]\n",c); 358 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 359 | } 360 | else 361 | { 362 | printf(RED "THE RESULTE IS : [%d/12]\n",c); 363 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 364 | } 365 | printf(HEAVENLY "ALL TEST : " RESET); 366 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 367 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 368 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 369 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 370 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 371 | ((t5 == 0)? printf(RED "TEST5" RESET " , ") : printf(GREEN "TEST5" RESET " , ")); 372 | ((t6 == 0)? printf(RED "TEST6" RESET " , ") : printf(GREEN "TEST6" RESET " , ")); 373 | ((t7 == 0)? printf(RED "TEST7" RESET " , ") : printf(GREEN "TEST7" RESET " , ")); 374 | ((t8 == 0)? printf(RED "TEST8" RESET " , ") : printf(GREEN "TEST8" RESET " , ")); 375 | ((t9 == 0)? printf(RED "TEST9" RESET " , ") : printf(GREEN "TEST9" RESET " , ")); 376 | ((t10 == 0)? printf(RED "TEST10" RESET " , ") : printf(GREEN "TEST10" RESET " , ")); 377 | ((t11 == 0)? printf(RED "TEST11" RESET ".\n") : printf(GREEN "TEST11" RESET ".\n")); 378 | printf(PERPUL "==============================================\n\n" RESET); 379 | } 380 | -------------------------------------------------------------------------------- /test/Libc_functions/tolower/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | 13 | int test0() 14 | { 15 | printf(YELLOW "==============================================\n" RESET); 16 | printf(YELLOW "= ft_tolower =\n" RESET); 17 | printf(YELLOW "==============================================\n\n" RESET); 18 | printf("[+] THE TEST NUMBER : 0 !!\n"); 19 | char test = 'A'; 20 | printf("[+] WATH WE HAVE :"); 21 | printf(HEAVENLY " %c\n" RESET, test); 22 | char res = tolower(test); 23 | printf("[+] WATH SHOULD WE GET :"); 24 | printf(HEAVENLY " %c\n" RESET, res); 25 | char y_res = ft_tolower(test); 26 | printf("[+] WATH YOURS FUNCTOINS GET :"); 27 | printf(HEAVENLY " %c\n\n" RESET, y_res); 28 | if (y_res == res) 29 | { 30 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 31 | return (1); 32 | } 33 | else 34 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 35 | return (0); 36 | } 37 | 38 | 39 | int test1() 40 | { 41 | printf(YELLOW "==============================================\n" RESET); 42 | printf(YELLOW "= ft_tolower =\n" RESET); 43 | printf(YELLOW "==============================================\n\n" RESET); 44 | printf("[+] THE TEST NUMBER : 1 !!\n"); 45 | char test = 'Z'; 46 | printf("[+] WATH WE HAVE :"); 47 | printf(HEAVENLY " %c\n" RESET, test); 48 | char res = tolower(test); 49 | printf("[+] WATH SHOULD WE GET :"); 50 | printf(HEAVENLY " %c\n" RESET, res); 51 | char y_res = ft_tolower(test); 52 | printf("[+] WATH YOURS FUNCTOINS GET :"); 53 | printf(HEAVENLY " %c\n\n" RESET, y_res); 54 | if (y_res == res) 55 | { 56 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 57 | return (1); 58 | } 59 | else 60 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 61 | return (0); 62 | } 63 | 64 | int test2() 65 | { 66 | printf(YELLOW "==============================================\n" RESET); 67 | printf(YELLOW "= ft_tolower =\n" RESET); 68 | printf(YELLOW "==============================================\n\n" RESET); 69 | printf("[+] THE TEST NUMBER : 2 !!\n"); 70 | char test = 'c'; 71 | printf("[+] WATH WE HAVE :"); 72 | printf(HEAVENLY " %c\n" RESET, test); 73 | char res = tolower(test); 74 | printf("[+] WATH SHOULD WE GET :"); 75 | printf(HEAVENLY " %c\n" RESET, res); 76 | char y_res = ft_tolower(test); 77 | printf("[+] WATH YOURS FUNCTOINS GET :"); 78 | printf(HEAVENLY " %c\n\n" RESET, y_res); 79 | if (y_res == res) 80 | { 81 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 82 | return (1); 83 | } 84 | else 85 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 86 | return (0); 87 | } 88 | int test3() 89 | { 90 | printf(YELLOW "==============================================\n" RESET); 91 | printf(YELLOW "= ft_tolower =\n" RESET); 92 | printf(YELLOW "==============================================\n\n" RESET); 93 | printf("[+] THE TEST NUMBER : 3 !!\n"); 94 | char test = '5'; 95 | printf("[+] WATH WE HAVE :"); 96 | printf(HEAVENLY " %c\n" RESET, test); 97 | char res = tolower(test); 98 | printf("[+] WATH SHOULD WE GET :"); 99 | printf(HEAVENLY " %c\n" RESET, res); 100 | char y_res = ft_tolower(test); 101 | printf("[+] WATH YOURS FUNCTOINS GET :"); 102 | printf(HEAVENLY " %c\n\n" RESET, y_res); 103 | if (y_res == res) 104 | { 105 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 106 | return (1); 107 | } 108 | else 109 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 110 | return (0); 111 | } 112 | int test4() 113 | { 114 | printf(YELLOW "==============================================\n" RESET); 115 | printf(YELLOW "= ft_tolower =\n" RESET); 116 | printf(YELLOW "==============================================\n\n" RESET); 117 | printf("[+] THE TEST NUMBER : 4 !!\n"); 118 | char test = '@'; 119 | printf("[+] WATH WE HAVE :"); 120 | printf(HEAVENLY " %c\n" RESET, test); 121 | char res = tolower(test); 122 | printf("[+] WATH SHOULD WE GET :"); 123 | printf(HEAVENLY " %c\n" RESET, res); 124 | char y_res = ft_tolower(test); 125 | printf("[+] WATH YOURS FUNCTOINS GET :"); 126 | printf(HEAVENLY " %c\n\n" RESET, y_res); 127 | if (y_res == res) 128 | { 129 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 130 | return (1); 131 | } 132 | else 133 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 134 | return (0); 135 | } 136 | int test5() 137 | { 138 | printf(YELLOW "==============================================\n" RESET); 139 | printf(YELLOW "= ft_tolower =\n" RESET); 140 | printf(YELLOW "==============================================\n\n" RESET); 141 | printf("[+] THE TEST NUMBER : 5 !!\n"); 142 | char test = 'Z' + 1; 143 | printf("[+] WATH WE HAVE :"); 144 | printf(HEAVENLY " %c\n" RESET, test); 145 | char res = tolower(test); 146 | printf("[+] WATH SHOULD WE GET :"); 147 | printf(HEAVENLY " %c\n" RESET, res); 148 | char y_res = ft_tolower(test); 149 | printf("[+] WATH YOURS FUNCTOINS GET :"); 150 | printf(HEAVENLY " %c\n\n" RESET, y_res); 151 | if (y_res == res) 152 | { 153 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 154 | return (1); 155 | } 156 | else 157 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 158 | return (0); 159 | } 160 | 161 | int main() 162 | { 163 | int c; 164 | c = 0; 165 | int t0 = test0(); 166 | sleep(1); 167 | int t1 = test1(); 168 | sleep(1); 169 | int t2 = test2(); 170 | sleep(1); 171 | int t3 = test3(); 172 | sleep(1); 173 | int t4 = test4(); 174 | sleep(1); 175 | int t5 = test5(); 176 | sleep(1); 177 | c = t0 + t1 + t2 + t3 + t4 + t5; 178 | printf(PERPUL "==============================================\n" RESET); 179 | if (c == 6) 180 | { 181 | printf(GREEN "THE RESULTE IS : [%d/6]\n",c); 182 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 183 | } 184 | else 185 | { 186 | printf(RED "THE RESULTE IS : [%d/6]\n",c); 187 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 188 | } 189 | printf(HEAVENLY "ALL TEST : " RESET); 190 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 191 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 192 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 193 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 194 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 195 | ((t5 == 0)? printf(RED "TEST5" RESET ".\n") : printf(GREEN "TEST5" RESET ".\n")); 196 | printf(PERPUL "==============================================\n\n" RESET); 197 | } 198 | -------------------------------------------------------------------------------- /test/Libc_functions/toupper/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "../../../src/libft.h" 5 | 6 | #define RED "\033[0;31m" 7 | #define GREEN "\033[0;32m" 8 | #define RESET "\033[0m" 9 | #define YELLOW "\033[0;33m" 10 | #define HEAVENLY "\033[0;36m" 11 | #define PERPUL "\033[0;35m" 12 | int test0() 13 | { 14 | printf(YELLOW "==============================================\n" RESET); 15 | printf(YELLOW "= ft_toupper =\n" RESET); 16 | printf(YELLOW "==============================================\n\n" RESET); 17 | printf("[+] THE TEST NUMBER : 0 !!\n"); 18 | char test = 'a'; 19 | printf("[+] WATH WE HAVE :"); 20 | printf(HEAVENLY " %c\n" RESET, test); 21 | char res = toupper(test); 22 | printf("[+] WATH SHOULD WE GET :"); 23 | printf(HEAVENLY " %c\n" RESET, res); 24 | char y_res = ft_toupper(test); 25 | printf("[+] WATH YOURS FUNCTOINS GET :"); 26 | printf(HEAVENLY " %c\n\n" RESET, y_res); 27 | if (y_res == res) 28 | { 29 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 30 | return (1); 31 | } 32 | else 33 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 34 | return (0); 35 | } 36 | 37 | 38 | int test1() 39 | { 40 | printf(YELLOW "==============================================\n" RESET); 41 | printf(YELLOW "= ft_toupper =\n" RESET); 42 | printf(YELLOW "==============================================\n\n" RESET); 43 | printf("[+] THE TEST NUMBER : 1 !!\n"); 44 | char test = 'z'; 45 | printf("[+] WATH WE HAVE :"); 46 | printf(HEAVENLY " %c\n" RESET, test); 47 | char res = toupper(test); 48 | printf("[+] WATH SHOULD WE GET :"); 49 | printf(HEAVENLY " %c\n" RESET, res); 50 | char y_res = ft_toupper(test); 51 | printf("[+] WATH YOURS FUNCTOINS GET :"); 52 | printf(HEAVENLY " %c\n\n" RESET, y_res); 53 | if (y_res == res) 54 | { 55 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 56 | return (1); 57 | } 58 | else 59 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 60 | return (0); 61 | } 62 | 63 | int test2() 64 | { 65 | printf(YELLOW "==============================================\n" RESET); 66 | printf(YELLOW "= ft_toupper =\n" RESET); 67 | printf(YELLOW "==============================================\n\n" RESET); 68 | printf("[+] THE TEST NUMBER : 2 !!\n"); 69 | char test = 'C'; 70 | printf("[+] WATH WE HAVE :"); 71 | printf(HEAVENLY " %c\n" RESET, test); 72 | char res = toupper(test); 73 | printf("[+] WATH SHOULD WE GET :"); 74 | printf(HEAVENLY " %c\n" RESET, res); 75 | char y_res = ft_toupper(test); 76 | printf("[+] WATH YOURS FUNCTOINS GET :"); 77 | printf(HEAVENLY " %c\n\n" RESET, y_res); 78 | if (y_res == res) 79 | { 80 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 81 | return (1); 82 | } 83 | else 84 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 85 | return (0); 86 | } 87 | int test3() 88 | { 89 | printf(YELLOW "==============================================\n" RESET); 90 | printf(YELLOW "= ft_toupper =\n" RESET); 91 | printf(YELLOW "==============================================\n\n" RESET); 92 | printf("[+] THE TEST NUMBER : 3 !!\n"); 93 | char test = '5'; 94 | printf("[+] WATH WE HAVE :"); 95 | printf(HEAVENLY " %c\n" RESET, test); 96 | char res = toupper(test); 97 | printf("[+] WATH SHOULD WE GET :"); 98 | printf(HEAVENLY " %c\n" RESET, res); 99 | char y_res = ft_toupper(test); 100 | printf("[+] WATH YOURS FUNCTOINS GET :"); 101 | printf(HEAVENLY " %c\n\n" RESET, y_res); 102 | if (y_res == res) 103 | { 104 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 105 | return (1); 106 | } 107 | else 108 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 109 | return (0); 110 | } 111 | int test4() 112 | { 113 | printf(YELLOW "==============================================\n" RESET); 114 | printf(YELLOW "= ft_toupper =\n" RESET); 115 | printf(YELLOW "==============================================\n\n" RESET); 116 | printf("[+] THE TEST NUMBER : 4 !!\n"); 117 | char test = 'a' - 1; 118 | printf("[+] WATH WE HAVE :"); 119 | printf(HEAVENLY " %c\n" RESET, test); 120 | char res = toupper(test); 121 | printf("[+] WATH SHOULD WE GET :"); 122 | printf(HEAVENLY " %c\n" RESET, res); 123 | char y_res = ft_toupper(test); 124 | printf("[+] WATH YOURS FUNCTOINS GET :"); 125 | printf(HEAVENLY " %c\n\n" RESET, y_res); 126 | if (y_res == res) 127 | { 128 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 129 | return (1); 130 | } 131 | else 132 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 133 | return (0); 134 | } 135 | int test5() 136 | { 137 | printf(YELLOW "==============================================\n" RESET); 138 | printf(YELLOW "= ft_toupper =\n" RESET); 139 | printf(YELLOW "==============================================\n\n" RESET); 140 | printf("[+] THE TEST NUMBER : 5 !!\n"); 141 | char test = 'z' + 1; 142 | printf("[+] WATH WE HAVE :"); 143 | printf(HEAVENLY " %c\n" RESET, test); 144 | char res = toupper(test); 145 | printf("[+] WATH SHOULD WE GET :"); 146 | printf(HEAVENLY " %c\n" RESET, res); 147 | char y_res = ft_toupper(test); 148 | printf("[+] WATH YOURS FUNCTOINS GET :"); 149 | printf(HEAVENLY " %c\n\n" RESET, y_res); 150 | if (y_res == res) 151 | { 152 | printf(GREEN "THE TEST [ PASS ] ╰(*-*)╯ GOOD JOB !!\n\n" RESET); 153 | return (1); 154 | } 155 | else 156 | printf(RED "THE TEST [ NOT PASS ] ╭(╥_╥)╮ TRY AGINE AND GOOD LUCK !!\n\n" RESET); 157 | return (0); 158 | } 159 | int main() 160 | { 161 | int c; 162 | c = 0; 163 | int t0 = test0(); 164 | sleep(1); 165 | int t1 = test1(); 166 | sleep(1); 167 | int t2 = test2(); 168 | sleep(1); 169 | int t3 = test3(); 170 | sleep(1); 171 | int t4 = test4(); 172 | sleep(1); 173 | int t5 = test5(); 174 | sleep(1); 175 | c = t0 + t1 + t2 + t3 + t4 + t5; 176 | printf(PERPUL "==============================================\n" RESET); 177 | if (c == 6) 178 | { 179 | printf(GREEN "THE RESULTE IS : [%d/6]\n",c); 180 | printf("CONGRATULATIONS, YOU HAVE PASSED ALL THE TESTS.\n" RESET); 181 | } 182 | else 183 | { 184 | printf(RED "THE RESULTE IS : [%d/6]\n",c); 185 | printf("UNFORTUNATELY, YOUR FUNCTION DID NOT MEET ALL THE TESTS. TRY AGAIN.\n" RESET); 186 | } 187 | printf(HEAVENLY "ALL TEST : " RESET); 188 | ((t0 == 0)? printf(RED "TEST0" RESET " , ") : printf(GREEN "TEST0" RESET " , ")); 189 | ((t1 == 0)? printf(RED "TEST1" RESET " , ") : printf(GREEN "TEST1" RESET " , ")); 190 | ((t2 == 0)? printf(RED "TEST2" RESET " , ") : printf(GREEN "TEST2" RESET " , ")); 191 | ((t3 == 0)? printf(RED "TEST3" RESET " , ") : printf(GREEN "TEST3" RESET " , ")); 192 | ((t4 == 0)? printf(RED "TEST4" RESET " , ") : printf(GREEN "TEST4" RESET " , ")); 193 | ((t5 == 0)? printf(RED "TEST5" RESET ".\n") : printf(GREEN "TEST5" RESET ".\n")); 194 | printf(PERPUL "==============================================\n\n" RESET); 195 | } 196 | --------------------------------------------------------------------------------