diff --git a/.gitignore b/.gitignore index 56d5ddf..230c401 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ *.o *.a +*.swp +test + +test_bonus -libasm_unit_tests diff --git a/Makefile b/Makefile index e9b64ce..03b2d85 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,9 @@ all: $(NAME) bonus: $(OBJ) $(OBJBONUS) ar rcs libasm.a $(OBJ) $(OBJBONUS) +test: all + gcc -Wall -Werror -Wextra -pie main.c -L . -lasm -o test + test_bonus: bonus gcc -Wall -Werror -Wextra -pie main_bonus.c -L . -lasm -o test_bonus @@ -39,6 +42,8 @@ clean: fclean: clean rm -fv libasm.a + rm -fv test + rm -fv test_bonus re: fclean all diff --git a/main.c b/main.c new file mode 100644 index 0000000..3907887 --- /dev/null +++ b/main.c @@ -0,0 +1,33 @@ +#include +#include +#include "libasm.h" +#include +#include + +int main(void) { + char *str = ft_strdup("abcdefghi\n"); + char *str2 = ft_strdup("a34\n"); + assert(strcmp(str, "abcdefghi\n") == 0); + assert(ft_strcmp(str, str2) == 47); + assert(strlen(str) == ft_strlen(str)); + assert(strlen(str2) == ft_strlen(str2)); + char *str3 = malloc(sizeof(char) * (1 + ft_strlen(str2))); + ft_strcpy(str3, str2); + assert(strcmp(str3, str2) == 0); + assert(ft_strcmp(str3, str2) == strcmp(str3, str2)); + free(str); + ft_write(1, str2, ft_strlen(str2)); + free(str2); + free(str3); + int fd = open("Makefile", O_RDONLY); + if (fd != -1) { + char *buf = malloc(128 * sizeof(char)); + int ret = ft_read(fd, buf, 128); + ft_write(1, buf, ret); + ft_write(1, "\n", 1); + close(fd); + free(buf); + } + return 0; +} + diff --git a/main_bonus.c b/main_bonus.c index 9830540..c2fa296 100644 --- a/main_bonus.c +++ b/main_bonus.c @@ -21,6 +21,12 @@ void test_ft_list(void) { assert(ft_strcmp(list->data, "zzz") == 0); ft_list_sort(&list, &ft_strcmp); assert(ft_strcmp(list->data, "cdb") == 0); + + ft_list_remove_if(&list, (void *)"cdb", &ft_strcmp, &free); + ft_list_remove_if(&list, (void *)"zzz", &ft_strcmp, &free); + ft_list_remove_if(&list, (void *)"egh", &ft_strcmp, &free); + ft_list_remove_if(&list, (void *)"dgb", &ft_strcmp, &free); + ft_list_remove_if(&list, (void *)"egb", &ft_strcmp, &free); } void test_ft_atoi_base(void) { diff --git a/test_bonus b/test_bonus deleted file mode 100755 index a49c281..0000000 Binary files a/test_bonus and /dev/null differ