From 05e32c3ab596f88da3a0fa8cd8ca01b93392cc92 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Dec 2024 10:06:42 +0100 Subject: [PATCH] feat: changing the textures style: removing test libft --- .c | 0 libft/Makefile | 744 ------------------ libft/include/ft_list_types.h | 46 -- libft/include/ft_math.h | 187 ----- libft/tests/ft_args/args_tests.c | 33 - libft/tests/ft_args/tests_custom_checker.c | 30 - libft/tests/ft_args/tests_optlist.c | 37 - libft/tests/ft_args/tests_progname.c | 30 - libft/tests/ft_args/tests_setup_prog.c | 26 - libft/tests/ft_args/tests_version.c | 31 - libft/tests/ft_list/dl_tests/dl_list_tests.c | 52 -- libft/tests/ft_list/dl_tests/dl_tests_utils.c | 26 - .../tests/ft_list/dl_tests/tests_dlist_add.c | 73 -- .../ft_list/dl_tests/tests_dlist_apply.c | 72 -- .../ft_list/dl_tests/tests_dlist_clear.c | 68 -- .../tests/ft_list/dl_tests/tests_dlist_copy.c | 65 -- .../ft_list/dl_tests/tests_dlist_create.c | 34 - .../ft_list/dl_tests/tests_dlist_delete.c | 110 --- .../tests/ft_list/dl_tests/tests_dlist_find.c | 45 -- .../tests/ft_list/dl_tests/tests_dlist_get.c | 60 -- .../ft_list/dl_tests/tests_dlist_iterators.c | 81 -- .../tests/ft_list/dl_tests/tests_dlist_map.c | 46 -- .../tests/ft_list/dl_tests/tests_dlist_new.c | 26 - .../tests/ft_list/dl_tests/tests_dlist_push.c | 115 --- .../tests/ft_list/dl_tests/tests_dlist_rev.c | 41 - .../ft_list/dl_tests/tests_dlist_sizers.c | 59 -- .../ft_list/dl_tests/tests_dlist_subrange.c | 44 -- libft/tests/ft_list/ll_tests/ll_list_tests.c | 43 - libft/tests/ft_list/ll_tests/ll_tests_utils.c | 26 - libft/tests/ft_list/ll_tests/tests_list_add.c | 65 -- .../tests/ft_list/ll_tests/tests_list_apply.c | 92 --- .../tests/ft_list/ll_tests/tests_list_clear.c | 30 - .../tests/ft_list/ll_tests/tests_list_copy.c | 62 -- .../ft_list/ll_tests/tests_list_create.c | 34 - .../ft_list/ll_tests/tests_list_deletors.c | 81 -- .../tests/ft_list/ll_tests/tests_list_find.c | 46 -- libft/tests/ft_list/ll_tests/tests_list_get.c | 54 -- .../ft_list/ll_tests/tests_list_iterators.c | 59 -- libft/tests/ft_list/ll_tests/tests_list_map.c | 43 - libft/tests/ft_list/ll_tests/tests_list_new.c | 26 - .../tests/ft_list/ll_tests/tests_list_push.c | 134 ---- libft/tests/ft_list/ll_tests/tests_list_rev.c | 39 - .../ft_list/ll_tests/tests_list_sizers.c | 59 -- .../ft_list/ll_tests/tests_list_subrange.c | 53 -- libft/tests/ft_map/map_tests.c | 39 - libft/tests/ft_map/tests_map_cappacity.c | 27 - libft/tests/ft_map/tests_map_clear.c | 32 - libft/tests/ft_map/tests_map_create.c | 25 - libft/tests/ft_map/tests_map_destroy.c | 48 -- libft/tests/ft_map/tests_map_get.c | 84 -- libft/tests/ft_map/tests_map_hash.c | 42 - libft/tests/ft_map/tests_map_remove.c | 80 -- libft/tests/ft_map/tests_map_set.c | 34 - libft/tests/ft_map/tests_map_set_cmphash.c | 38 - libft/tests/ft_map/tests_map_size.c | 33 - libft/tests/ft_math/math_tests.c | 37 - libft/tests/ft_math/tests_abs.c | 29 - libft/tests/ft_math/tests_align.c | 57 -- libft/tests/ft_math/tests_clamp.c | 85 -- libft/tests/ft_math/tests_complex.c | 78 -- libft/tests/ft_math/tests_intrange.c | 134 ---- libft/tests/ft_math/tests_log.c | 74 -- libft/tests/ft_math/tests_minmax.c | 39 - libft/tests/ft_math/tests_pow.c | 33 - libft/tests/ft_math/tests_round.c | 32 - libft/tests/ft_math/tests_sqrt.c | 33 - libft/tests/ft_optional/optional_tests.c | 43 - .../tests/ft_optional/tests_optional_chain.c | 41 - libft/tests/ft_optional/tests_optional_copy.c | 34 - .../ft_optional/tests_optional_destroy.c | 35 - libft/tests/ft_optional/tests_optional_dup.c | 33 - .../ft_optional/tests_optional_from_val.c | 35 - libft/tests/ft_optional/tests_optional_map.c | 34 - libft/tests/ft_optional/tests_optional_new.c | 29 - .../tests/ft_optional/tests_optional_unwrap.c | 37 - libft/tests/ft_pair/pair_tests.c | 34 - libft/tests/ft_pair/tests_pair_cmp.c | 74 -- libft/tests/ft_pair/tests_pair_cmp_first.c | 74 -- libft/tests/ft_pair/tests_pair_cmp_second.c | 73 -- libft/tests/ft_pair/tests_pair_destroy.c | 34 - libft/tests/ft_pair/tests_pair_get_first.c | 31 - libft/tests/ft_pair/tests_pair_get_second.c | 31 - libft/tests/ft_pair/tests_pair_new.c | 35 - libft/tests/ft_pair/tests_pair_set.c | 35 - libft/tests/ft_string/ft_char/ft_char_tests.c | 31 - libft/tests/ft_string/ft_char/tests_isalnum.c | 28 - libft/tests/ft_string/ft_char/tests_isalpha.c | 27 - libft/tests/ft_string/ft_char/tests_isascii.c | 27 - libft/tests/ft_string/ft_char/tests_isdigit.c | 27 - .../ft_string/ft_char/tests_ishexdigit.c | 35 - .../ft_string/ft_char/tests_isoctdigit.c | 34 - libft/tests/ft_string/ft_char/tests_isprint.c | 27 - libft/tests/ft_string/ft_char/tests_isspace.c | 35 - libft/tests/ft_string/ft_char/tests_puchar.c | 46 -- libft/tests/ft_string/ft_char/tests_tolower.c | 34 - libft/tests/ft_string/ft_char/tests_toupper.c | 34 - libft/tests/ft_string/ft_mem/mem_tests.c | 32 - libft/tests/ft_string/ft_mem/tests_apply_2d.c | 41 - libft/tests/ft_string/ft_mem/tests_bzero.c | 25 - libft/tests/ft_string/ft_mem/tests_calloc.c | 33 - .../tests/ft_string/ft_mem/tests_fd_to_buff.c | 71 -- libft/tests/ft_string/ft_mem/tests_free.c | 26 - libft/tests/ft_string/ft_mem/tests_free_2d.c | 24 - libft/tests/ft_string/ft_mem/tests_len_2d.c | 26 - libft/tests/ft_string/ft_mem/tests_memchr.c | 32 - libft/tests/ft_string/ft_mem/tests_memcmp.c | 35 - libft/tests/ft_string/ft_mem/tests_memcpy.c | 31 - libft/tests/ft_string/ft_mem/tests_memmap.c | 40 - libft/tests/ft_string/ft_mem/tests_memmove.c | 37 - libft/tests/ft_string/ft_mem/tests_memset.c | 37 - libft/tests/ft_string/ft_mem/tests_qsort.c | 31 - libft/tests/ft_string/ft_mem/tests_realloc.c | 31 - libft/tests/ft_string/ft_mem/tests_swap.c | 32 - libft/tests/ft_string/ft_str/str_tests.c | 53 -- libft/tests/ft_string/ft_str/test_atof.c | 39 - libft/tests/ft_string/ft_str/test_atoi.c | 42 - libft/tests/ft_string/ft_str/test_atoi_base.c | 99 --- libft/tests/ft_string/ft_str/test_gnl.c | 75 -- libft/tests/ft_string/ft_str/test_itoa.c | 32 - libft/tests/ft_string/ft_str/test_itoa_base.c | 67 -- libft/tests/ft_string/ft_str/test_putendl.c | 43 - libft/tests/ft_string/ft_str/test_putnbr.c | 81 -- libft/tests/ft_string/ft_str/test_putstr.c | 41 - .../tests/ft_string/ft_str/test_shift_args.c | 41 - libft/tests/ft_string/ft_str/test_split.c | 38 - libft/tests/ft_string/ft_str/test_splits.c | 35 - .../tests/ft_string/ft_str/test_str_isalnum.c | 32 - .../tests/ft_string/ft_str/test_str_isalpha.c | 32 - .../tests/ft_string/ft_str/test_str_isbool.c | 36 - .../tests/ft_string/ft_str/test_str_isdigit.c | 32 - .../ft_string/ft_str/test_str_isdouble.c | 36 - .../tests/ft_string/ft_str/test_str_isfloat.c | 30 - libft/tests/ft_string/ft_str/test_str_ishex.c | 38 - libft/tests/ft_string/ft_str/test_str_isint.c | 33 - .../tests/ft_string/ft_str/test_str_islong.c | 39 - libft/tests/ft_string/ft_str/test_str_isnum.c | 32 - libft/tests/ft_string/ft_str/test_str_isoct.c | 28 - .../tests/ft_string/ft_str/test_str_isvalid.c | 34 - .../tests/ft_string/ft_str/test_str_replace.c | 35 - .../ft_string/ft_str/test_str_replace_chr.c | 32 - .../tests/ft_string/ft_str/test_strappend_c.c | 40 - libft/tests/ft_string/ft_str/test_strchr.c | 35 - libft/tests/ft_string/ft_str/test_strclen.c | 28 - libft/tests/ft_string/ft_str/test_strcmp.c | 35 - libft/tests/ft_string/ft_str/test_strcnb.c | 33 - libft/tests/ft_string/ft_str/test_strcspn.c | 28 - libft/tests/ft_string/ft_str/test_strdup.c | 26 - .../tests/ft_string/ft_str/test_strend_with.c | 28 - libft/tests/ft_string/ft_str/test_striteri.c | 33 - libft/tests/ft_string/ft_str/test_strjoin.c | 75 -- libft/tests/ft_string/ft_str/test_strlcat.c | 44 -- libft/tests/ft_string/ft_str/test_strlcpy.c | 74 -- libft/tests/ft_string/ft_str/test_strlen.c | 31 - libft/tests/ft_string/ft_str/test_strmapi.c | 43 - libft/tests/ft_string/ft_str/test_strncmp.c | 38 - libft/tests/ft_string/ft_str/test_strndup.c | 38 - libft/tests/ft_string/ft_str/test_strnstr.c | 37 - libft/tests/ft_string/ft_str/test_strrchr.c | 36 - libft/tests/ft_string/ft_str/test_strspn.c | 28 - .../ft_string/ft_str/test_strstart_with.c | 28 - libft/tests/ft_string/ft_str/test_strtok.c | 39 - libft/tests/ft_string/ft_str/test_strtrim.c | 35 - libft/tests/ft_string/ft_str/test_substr.c | 35 - libft/tests/ft_string/ft_str/test_utoa.c | 33 - .../ft_string/ft_string/t_string_tests.c | 60 -- libft/tests/ft_string/ft_string/test_append.c | 35 - .../tests/ft_string/ft_string/test_append_c.c | 37 - .../tests/ft_string/ft_string/test_append_n.c | 37 - .../tests/ft_string/ft_string/test_append_s.c | 40 - .../ft_string/ft_string/test_append_sn.c | 38 - libft/tests/ft_string/ft_string/test_cap.c | 25 - libft/tests/ft_string/ft_string/test_chr.c | 34 - libft/tests/ft_string/ft_string/test_clear.c | 32 - libft/tests/ft_string/ft_string/test_cmp.c | 33 - .../tests/ft_string/ft_string/test_cmp_str.c | 36 - .../tests/ft_string/ft_string/test_destroy.c | 31 - libft/tests/ft_string/ft_string/test_from.c | 31 - libft/tests/ft_string/ft_string/test_from_c.c | 29 - libft/tests/ft_string/ft_string/test_from_n.c | 34 - libft/tests/ft_string/ft_string/test_from_s.c | 32 - .../tests/ft_string/ft_string/test_from_sn.c | 38 - libft/tests/ft_string/ft_string/test_get.c | 27 - libft/tests/ft_string/ft_string/test_insert.c | 33 - .../tests/ft_string/ft_string/test_insert_c.c | 33 - .../tests/ft_string/ft_string/test_insert_n.c | 33 - .../tests/ft_string/ft_string/test_insert_s.c | 36 - .../ft_string/ft_string/test_insert_sn.c | 36 - libft/tests/ft_string/ft_string/test_len.c | 25 - libft/tests/ft_string/ft_string/test_ncmp.c | 29 - .../tests/ft_string/ft_string/test_ncmp_str.c | 39 - libft/tests/ft_string/ft_string/test_new.c | 29 - libft/tests/ft_string/ft_string/test_offset.c | 35 - libft/tests/ft_string/ft_string/test_put.c | 72 -- libft/tests/ft_string/ft_string/test_rchr.c | 34 - .../tests/ft_string/ft_string/test_replace.c | 30 - .../ft_string/ft_string/test_replace_chr.c | 26 - .../tests/ft_string/ft_string/test_reserve.c | 33 - libft/tests/ft_string/ft_string/test_resize.c | 30 - .../tests/ft_string/ft_string/test_roffset.c | 35 - libft/tests/ft_string/ft_string/test_set.c | 35 - .../ft_string/ft_string/test_set_inplace.c | 35 - libft/tests/ft_string/ft_string/test_set_n.c | 29 - libft/tests/ft_string/ft_string/test_shrink.c | 41 - libft/tests/ft_string/ft_string/test_substr.c | 35 - libft/tests/ft_string/ft_string/test_to_str.c | 28 - libft/tests/ft_string/ft_string/test_trim.c | 30 - .../tests/ft_string/ft_string/test_trim_chr.c | 30 - .../tests/ft_string/ft_string/test_trimstr.c | 30 - libft/tests/ft_string/string_tests.c | 57 -- libft/tests/ft_vector/tests_vec_add.c | 39 - libft/tests/ft_vector/tests_vec_apply.c | 30 - libft/tests/ft_vector/tests_vec_at.c | 40 - libft/tests/ft_vector/tests_vec_cat.c | 70 -- libft/tests/ft_vector/tests_vec_clear.c | 39 - .../ft_vector/tests_vec_convert_alloc_array.c | 43 - libft/tests/ft_vector/tests_vec_destroy.c | 34 - libft/tests/ft_vector/tests_vec_filter.c | 45 -- libft/tests/ft_vector/tests_vec_from_array.c | 61 -- libft/tests/ft_vector/tests_vec_from_size.c | 29 - libft/tests/ft_vector/tests_vec_get.c | 43 - libft/tests/ft_vector/tests_vec_map.c | 36 - libft/tests/ft_vector/tests_vec_new.c | 29 - libft/tests/ft_vector/tests_vec_pop.c | 39 - libft/tests/ft_vector/tests_vec_remove.c | 71 -- libft/tests/ft_vector/tests_vec_remove_if.c | 40 - libft/tests/ft_vector/tests_vec_reserve.c | 35 - libft/tests/ft_vector/tests_vec_reverse.c | 42 - libft/tests/ft_vector/tests_vec_shift.c | 42 - libft/tests/ft_vector/tests_vec_shrink.c | 46 -- libft/tests/ft_vector/tests_vec_sort.c | 40 - libft/tests/ft_vector/tests_vec_swap.c | 40 - libft/tests/ft_vector/tests_vec_to_array.c | 40 - libft/tests/ft_vector/vector_tests.c | 37 - libft/tests/lambdas_for_tests.c | 60 -- libft/tests/main_tests.c | 67 -- libft/tests/tests_utils.c | 111 --- maps/valid_01.cub | 8 +- textures/a.xpm | 154 ---- textures/b.xpm | 49 -- textures/chiseled_stone_bricks.xpm | 45 ++ textures/chiseled_tuff.xpm | 47 ++ textures/chiseled_tuff_bricks.xpm | 47 ++ textures/chiseled_tuff_bricks_top.xpm | 46 ++ textures/chiseled_tuff_top.xpm | 45 ++ textures/cobblestone_32.xpm | 154 ---- textures/sandy_32.xpm | 45 -- textures/wasteland_32.xpm | 45 -- 247 files changed, 234 insertions(+), 11272 deletions(-) create mode 100644 .c delete mode 100644 libft/Makefile delete mode 100644 libft/include/ft_list_types.h delete mode 100644 libft/include/ft_math.h delete mode 100644 libft/tests/ft_args/args_tests.c delete mode 100644 libft/tests/ft_args/tests_custom_checker.c delete mode 100644 libft/tests/ft_args/tests_optlist.c delete mode 100644 libft/tests/ft_args/tests_progname.c delete mode 100644 libft/tests/ft_args/tests_setup_prog.c delete mode 100644 libft/tests/ft_args/tests_version.c delete mode 100644 libft/tests/ft_list/dl_tests/dl_list_tests.c delete mode 100644 libft/tests/ft_list/dl_tests/dl_tests_utils.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_add.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_apply.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_clear.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_copy.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_create.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_delete.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_find.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_get.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_iterators.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_map.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_new.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_push.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_rev.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_sizers.c delete mode 100644 libft/tests/ft_list/dl_tests/tests_dlist_subrange.c delete mode 100644 libft/tests/ft_list/ll_tests/ll_list_tests.c delete mode 100644 libft/tests/ft_list/ll_tests/ll_tests_utils.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_add.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_apply.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_clear.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_copy.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_create.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_deletors.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_find.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_get.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_iterators.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_map.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_new.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_push.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_rev.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_sizers.c delete mode 100644 libft/tests/ft_list/ll_tests/tests_list_subrange.c delete mode 100644 libft/tests/ft_map/map_tests.c delete mode 100644 libft/tests/ft_map/tests_map_cappacity.c delete mode 100644 libft/tests/ft_map/tests_map_clear.c delete mode 100644 libft/tests/ft_map/tests_map_create.c delete mode 100644 libft/tests/ft_map/tests_map_destroy.c delete mode 100644 libft/tests/ft_map/tests_map_get.c delete mode 100644 libft/tests/ft_map/tests_map_hash.c delete mode 100644 libft/tests/ft_map/tests_map_remove.c delete mode 100644 libft/tests/ft_map/tests_map_set.c delete mode 100644 libft/tests/ft_map/tests_map_set_cmphash.c delete mode 100644 libft/tests/ft_map/tests_map_size.c delete mode 100644 libft/tests/ft_math/math_tests.c delete mode 100644 libft/tests/ft_math/tests_abs.c delete mode 100644 libft/tests/ft_math/tests_align.c delete mode 100644 libft/tests/ft_math/tests_clamp.c delete mode 100644 libft/tests/ft_math/tests_complex.c delete mode 100644 libft/tests/ft_math/tests_intrange.c delete mode 100644 libft/tests/ft_math/tests_log.c delete mode 100644 libft/tests/ft_math/tests_minmax.c delete mode 100644 libft/tests/ft_math/tests_pow.c delete mode 100644 libft/tests/ft_math/tests_round.c delete mode 100644 libft/tests/ft_math/tests_sqrt.c delete mode 100644 libft/tests/ft_optional/optional_tests.c delete mode 100644 libft/tests/ft_optional/tests_optional_chain.c delete mode 100644 libft/tests/ft_optional/tests_optional_copy.c delete mode 100644 libft/tests/ft_optional/tests_optional_destroy.c delete mode 100644 libft/tests/ft_optional/tests_optional_dup.c delete mode 100644 libft/tests/ft_optional/tests_optional_from_val.c delete mode 100644 libft/tests/ft_optional/tests_optional_map.c delete mode 100644 libft/tests/ft_optional/tests_optional_new.c delete mode 100644 libft/tests/ft_optional/tests_optional_unwrap.c delete mode 100644 libft/tests/ft_pair/pair_tests.c delete mode 100644 libft/tests/ft_pair/tests_pair_cmp.c delete mode 100644 libft/tests/ft_pair/tests_pair_cmp_first.c delete mode 100644 libft/tests/ft_pair/tests_pair_cmp_second.c delete mode 100644 libft/tests/ft_pair/tests_pair_destroy.c delete mode 100644 libft/tests/ft_pair/tests_pair_get_first.c delete mode 100644 libft/tests/ft_pair/tests_pair_get_second.c delete mode 100644 libft/tests/ft_pair/tests_pair_new.c delete mode 100644 libft/tests/ft_pair/tests_pair_set.c delete mode 100644 libft/tests/ft_string/ft_char/ft_char_tests.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isalnum.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isalpha.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isascii.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isdigit.c delete mode 100644 libft/tests/ft_string/ft_char/tests_ishexdigit.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isoctdigit.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isprint.c delete mode 100644 libft/tests/ft_string/ft_char/tests_isspace.c delete mode 100644 libft/tests/ft_string/ft_char/tests_puchar.c delete mode 100644 libft/tests/ft_string/ft_char/tests_tolower.c delete mode 100644 libft/tests/ft_string/ft_char/tests_toupper.c delete mode 100644 libft/tests/ft_string/ft_mem/mem_tests.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_apply_2d.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_bzero.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_calloc.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_fd_to_buff.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_free.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_free_2d.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_len_2d.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memchr.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memcmp.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memcpy.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memmap.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memmove.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_memset.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_qsort.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_realloc.c delete mode 100644 libft/tests/ft_string/ft_mem/tests_swap.c delete mode 100644 libft/tests/ft_string/ft_str/str_tests.c delete mode 100644 libft/tests/ft_string/ft_str/test_atof.c delete mode 100644 libft/tests/ft_string/ft_str/test_atoi.c delete mode 100644 libft/tests/ft_string/ft_str/test_atoi_base.c delete mode 100644 libft/tests/ft_string/ft_str/test_gnl.c delete mode 100644 libft/tests/ft_string/ft_str/test_itoa.c delete mode 100644 libft/tests/ft_string/ft_str/test_itoa_base.c delete mode 100644 libft/tests/ft_string/ft_str/test_putendl.c delete mode 100644 libft/tests/ft_string/ft_str/test_putnbr.c delete mode 100644 libft/tests/ft_string/ft_str/test_putstr.c delete mode 100644 libft/tests/ft_string/ft_str/test_shift_args.c delete mode 100644 libft/tests/ft_string/ft_str/test_split.c delete mode 100644 libft/tests/ft_string/ft_str/test_splits.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isalnum.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isalpha.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isbool.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isdigit.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isdouble.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isfloat.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_ishex.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isint.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_islong.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isnum.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isoct.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_isvalid.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_replace.c delete mode 100644 libft/tests/ft_string/ft_str/test_str_replace_chr.c delete mode 100644 libft/tests/ft_string/ft_str/test_strappend_c.c delete mode 100644 libft/tests/ft_string/ft_str/test_strchr.c delete mode 100644 libft/tests/ft_string/ft_str/test_strclen.c delete mode 100644 libft/tests/ft_string/ft_str/test_strcmp.c delete mode 100644 libft/tests/ft_string/ft_str/test_strcnb.c delete mode 100644 libft/tests/ft_string/ft_str/test_strcspn.c delete mode 100644 libft/tests/ft_string/ft_str/test_strdup.c delete mode 100644 libft/tests/ft_string/ft_str/test_strend_with.c delete mode 100644 libft/tests/ft_string/ft_str/test_striteri.c delete mode 100644 libft/tests/ft_string/ft_str/test_strjoin.c delete mode 100644 libft/tests/ft_string/ft_str/test_strlcat.c delete mode 100644 libft/tests/ft_string/ft_str/test_strlcpy.c delete mode 100644 libft/tests/ft_string/ft_str/test_strlen.c delete mode 100644 libft/tests/ft_string/ft_str/test_strmapi.c delete mode 100644 libft/tests/ft_string/ft_str/test_strncmp.c delete mode 100644 libft/tests/ft_string/ft_str/test_strndup.c delete mode 100644 libft/tests/ft_string/ft_str/test_strnstr.c delete mode 100644 libft/tests/ft_string/ft_str/test_strrchr.c delete mode 100644 libft/tests/ft_string/ft_str/test_strspn.c delete mode 100644 libft/tests/ft_string/ft_str/test_strstart_with.c delete mode 100644 libft/tests/ft_string/ft_str/test_strtok.c delete mode 100644 libft/tests/ft_string/ft_str/test_strtrim.c delete mode 100644 libft/tests/ft_string/ft_str/test_substr.c delete mode 100644 libft/tests/ft_string/ft_str/test_utoa.c delete mode 100644 libft/tests/ft_string/ft_string/t_string_tests.c delete mode 100644 libft/tests/ft_string/ft_string/test_append.c delete mode 100644 libft/tests/ft_string/ft_string/test_append_c.c delete mode 100644 libft/tests/ft_string/ft_string/test_append_n.c delete mode 100644 libft/tests/ft_string/ft_string/test_append_s.c delete mode 100644 libft/tests/ft_string/ft_string/test_append_sn.c delete mode 100644 libft/tests/ft_string/ft_string/test_cap.c delete mode 100644 libft/tests/ft_string/ft_string/test_chr.c delete mode 100644 libft/tests/ft_string/ft_string/test_clear.c delete mode 100644 libft/tests/ft_string/ft_string/test_cmp.c delete mode 100644 libft/tests/ft_string/ft_string/test_cmp_str.c delete mode 100644 libft/tests/ft_string/ft_string/test_destroy.c delete mode 100644 libft/tests/ft_string/ft_string/test_from.c delete mode 100644 libft/tests/ft_string/ft_string/test_from_c.c delete mode 100644 libft/tests/ft_string/ft_string/test_from_n.c delete mode 100644 libft/tests/ft_string/ft_string/test_from_s.c delete mode 100644 libft/tests/ft_string/ft_string/test_from_sn.c delete mode 100644 libft/tests/ft_string/ft_string/test_get.c delete mode 100644 libft/tests/ft_string/ft_string/test_insert.c delete mode 100644 libft/tests/ft_string/ft_string/test_insert_c.c delete mode 100644 libft/tests/ft_string/ft_string/test_insert_n.c delete mode 100644 libft/tests/ft_string/ft_string/test_insert_s.c delete mode 100644 libft/tests/ft_string/ft_string/test_insert_sn.c delete mode 100644 libft/tests/ft_string/ft_string/test_len.c delete mode 100644 libft/tests/ft_string/ft_string/test_ncmp.c delete mode 100644 libft/tests/ft_string/ft_string/test_ncmp_str.c delete mode 100644 libft/tests/ft_string/ft_string/test_new.c delete mode 100644 libft/tests/ft_string/ft_string/test_offset.c delete mode 100644 libft/tests/ft_string/ft_string/test_put.c delete mode 100644 libft/tests/ft_string/ft_string/test_rchr.c delete mode 100644 libft/tests/ft_string/ft_string/test_replace.c delete mode 100644 libft/tests/ft_string/ft_string/test_replace_chr.c delete mode 100644 libft/tests/ft_string/ft_string/test_reserve.c delete mode 100644 libft/tests/ft_string/ft_string/test_resize.c delete mode 100644 libft/tests/ft_string/ft_string/test_roffset.c delete mode 100644 libft/tests/ft_string/ft_string/test_set.c delete mode 100644 libft/tests/ft_string/ft_string/test_set_inplace.c delete mode 100644 libft/tests/ft_string/ft_string/test_set_n.c delete mode 100644 libft/tests/ft_string/ft_string/test_shrink.c delete mode 100644 libft/tests/ft_string/ft_string/test_substr.c delete mode 100644 libft/tests/ft_string/ft_string/test_to_str.c delete mode 100644 libft/tests/ft_string/ft_string/test_trim.c delete mode 100644 libft/tests/ft_string/ft_string/test_trim_chr.c delete mode 100644 libft/tests/ft_string/ft_string/test_trimstr.c delete mode 100644 libft/tests/ft_string/string_tests.c delete mode 100644 libft/tests/ft_vector/tests_vec_add.c delete mode 100644 libft/tests/ft_vector/tests_vec_apply.c delete mode 100644 libft/tests/ft_vector/tests_vec_at.c delete mode 100644 libft/tests/ft_vector/tests_vec_cat.c delete mode 100644 libft/tests/ft_vector/tests_vec_clear.c delete mode 100644 libft/tests/ft_vector/tests_vec_convert_alloc_array.c delete mode 100644 libft/tests/ft_vector/tests_vec_destroy.c delete mode 100644 libft/tests/ft_vector/tests_vec_filter.c delete mode 100644 libft/tests/ft_vector/tests_vec_from_array.c delete mode 100644 libft/tests/ft_vector/tests_vec_from_size.c delete mode 100644 libft/tests/ft_vector/tests_vec_get.c delete mode 100644 libft/tests/ft_vector/tests_vec_map.c delete mode 100644 libft/tests/ft_vector/tests_vec_new.c delete mode 100644 libft/tests/ft_vector/tests_vec_pop.c delete mode 100644 libft/tests/ft_vector/tests_vec_remove.c delete mode 100644 libft/tests/ft_vector/tests_vec_remove_if.c delete mode 100644 libft/tests/ft_vector/tests_vec_reserve.c delete mode 100644 libft/tests/ft_vector/tests_vec_reverse.c delete mode 100644 libft/tests/ft_vector/tests_vec_shift.c delete mode 100644 libft/tests/ft_vector/tests_vec_shrink.c delete mode 100644 libft/tests/ft_vector/tests_vec_sort.c delete mode 100644 libft/tests/ft_vector/tests_vec_swap.c delete mode 100644 libft/tests/ft_vector/tests_vec_to_array.c delete mode 100644 libft/tests/ft_vector/vector_tests.c delete mode 100644 libft/tests/lambdas_for_tests.c delete mode 100644 libft/tests/main_tests.c delete mode 100644 libft/tests/tests_utils.c delete mode 100644 textures/a.xpm delete mode 100644 textures/b.xpm create mode 100644 textures/chiseled_stone_bricks.xpm create mode 100644 textures/chiseled_tuff.xpm create mode 100644 textures/chiseled_tuff_bricks.xpm create mode 100644 textures/chiseled_tuff_bricks_top.xpm create mode 100644 textures/chiseled_tuff_top.xpm delete mode 100644 textures/cobblestone_32.xpm delete mode 100644 textures/sandy_32.xpm delete mode 100644 textures/wasteland_32.xpm diff --git a/.c b/.c new file mode 100644 index 0000000..e69de29 diff --git a/libft/Makefile b/libft/Makefile deleted file mode 100644 index 11ff5d2..0000000 --- a/libft/Makefile +++ /dev/null @@ -1,744 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# Makefile :+: :+: :+: # -# +:+ +:+ +:+ # -# By: bgoulard +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2023/12/05 09:04:05 by bgoulard #+# #+# # -# Updated: 2024/11/09 00:08:07 by bgoulard ### ########.fr # -# # -# **************************************************************************** # - -# Colors -GRAY = "\\e[90m" -GREEN = "\\e[42m" -RED = "\\e[41m" -RESET = "\\e[0m" -BOLD = "\\e[1m" - -# Commands -CC = clang -NAME = ft -OUTDIR = ../build - -TEST_NAME = tests_run -AR = ar -COV = llvm-cov -PRD = llvm-profdata -ECHO = $(shell which echo) -e -PRINTF = $(shell which printf) - -# Directories - -SRC_DIR = src -BUILD_DIR = ../build/bgoulard -TESTS_DIR = tests -INC_DIR = include -COVERAGE_DIR = coverage - -FT_MAP_DIR = ft_map -FT_LIST_DIR = ft_list -FT_STRING_DIR = ft_string -FT_VEC_DIR = ft_vector -FT_OPTIONAL_DIR = ft_optional -FT_ARGS_DIR = ft_args -FT_MATH_DIR = ft_math -FT_PAIR_DIR = ft_pair - -# Counpound directories - -FT_LIST_LL_DIR = $(FT_LIST_DIR)/ft_ll -FT_LIST_DL_DIR = $(FT_LIST_DIR)/ft_dl -FT_CHR_DIR = $(FT_STRING_DIR)/ft_chr -FT_MEM_DIR = $(FT_STRING_DIR)/ft_mem -FT_STR_DIR = $(FT_STRING_DIR)/ft_str -FT_T_STRING_DIR = $(FT_STRING_DIR)/ft_string - -# Compilation flags -## -## To change debug level run make DEBUG_LEVEL=xxx -## - -LDFLAGS = -CPPFLAGS = -I$(INC_DIR) -MMD -MP -FFLAGS =\ - -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined \ - -fsanitize=leak -fsanitize=pointer-compare \ - -fsanitize=pointer-subtract \ - -fsanitize-address-use-after-scope -fsanitize=pointer-overflow -CFLAGS =\ - -Wall -Wextra $(CPPFLAGS) -Werror -fPIC -fdiagnostics-color -TEST_FLAGS =\ - -g2 -DTEST \ - -fprofile-instr-generate -ftest-coverage -fcoverage-mapping \ - -DEBUG_LEVEL =\ - 0 -DEBUG_FLAGS =\ - -g2 -DDEBUG $(FFLAGS) -DDEBUG_LEVEL=$(DEBUG_LEVEL) - -# Inner variables - -MAX_FILE_LEN = 0 -TARGET ?= "ALL" -CLOG_FILE = ./compilation.log - -# Check for llvm-cov and llvm-profdata -# If not found, use the version 12 if available -# If not found, use the version 14 (latest version) -ifeq (, $(shell which $(COV) 2> /dev/null)) - COV = llvm-cov-12 - ifeq (, $(shell which $(COV) 2> /dev/null)) - COV = llvm-cov-14 - endif -endif - -ifeq (, $(shell which $(PRD) 2> /dev/null)) - PRD = llvm-profdata-12 - ifeq (, $(shell which $(PRD) 2> /dev/null)) - PRD = llvm-profdata-14 - endif -endif - -# Sources - -FT_PAIR_SRC = \ - $(FT_PAIR_DIR)/ft_pair_cmp.c \ - $(FT_PAIR_DIR)/ft_pair_destroy.c \ - $(FT_PAIR_DIR)/ft_pair_get.c \ - $(FT_PAIR_DIR)/ft_pair_new.c \ - $(FT_PAIR_DIR)/ft_pair_set.c \ - -FT_MATH_SRC = \ - $(FT_MATH_DIR)/ft_clamp.c \ - $(FT_MATH_DIR)/ft_complex.c \ - $(FT_MATH_DIR)/ft_intrange.c \ - $(FT_MATH_DIR)/ft_log.c \ - $(FT_MATH_DIR)/ft_minmax.c \ - $(FT_MATH_DIR)/ft_sqrt.c \ - $(FT_MATH_DIR)/ft_pow.c \ - $(FT_MATH_DIR)/ft_abs.c \ - $(FT_MATH_DIR)/ft_align.c \ - $(FT_MATH_DIR)/ft_round.c - -FT_MAP_SRC = \ - $(FT_MAP_DIR)/ft_map_clear.c \ - $(FT_MAP_DIR)/ft_map_create.c \ - $(FT_MAP_DIR)/ft_map_destroy.c \ - $(FT_MAP_DIR)/ft_map_get.c \ - $(FT_MAP_DIR)/ft_map_hash.c \ - $(FT_MAP_DIR)/ft_map_remove.c \ - $(FT_MAP_DIR)/ft_map_set.c - -FT_LIST_LL_SRC = \ - $(FT_LIST_LL_DIR)/ft_ll_find.c \ - $(FT_LIST_LL_DIR)/ft_ll_add.c \ - $(FT_LIST_LL_DIR)/ft_ll_clear.c \ - $(FT_LIST_LL_DIR)/ft_ll_delete.c \ - $(FT_LIST_LL_DIR)/ft_ll_apply.c \ - $(FT_LIST_LL_DIR)/ft_ll_iterator.c \ - $(FT_LIST_LL_DIR)/ft_ll_map.c \ - $(FT_LIST_LL_DIR)/ft_ll_new.c \ - $(FT_LIST_LL_DIR)/ft_ll_rev.c \ - $(FT_LIST_LL_DIR)/ft_ll_size.c \ - $(FT_LIST_LL_DIR)/ft_ll_create.c \ - $(FT_LIST_LL_DIR)/ft_ll_getters.c \ - $(FT_LIST_LL_DIR)/ft_ll_pushpop.c \ - $(FT_LIST_LL_DIR)/ft_ll_sub.c \ - -FT_LIST_DL_SRC = \ - $(FT_LIST_DL_DIR)/ft_dl_apply.c \ - $(FT_LIST_DL_DIR)/ft_dl_clear.c \ - $(FT_LIST_DL_DIR)/ft_dl_create.c \ - $(FT_LIST_DL_DIR)/ft_dl_delete.c \ - $(FT_LIST_DL_DIR)/ft_dl_getters.c \ - $(FT_LIST_DL_DIR)/ft_dl_iterator.c \ - $(FT_LIST_DL_DIR)/ft_dl_pushpop.c \ - $(FT_LIST_DL_DIR)/ft_dl_size.c \ - $(FT_LIST_DL_DIR)/ft_dl_sub.c \ - $(FT_LIST_DL_DIR)/ft_dl_add.c \ - $(FT_LIST_DL_DIR)/ft_dl_rev.c \ - $(FT_LIST_DL_DIR)/ft_dl_map.c \ - $(FT_LIST_DL_DIR)/ft_dl_new.c \ - $(FT_LIST_DL_DIR)/ft_dl_find.c \ - -FT_STR_SRC = \ - $(FT_STR_DIR)/ft_atof.c \ - $(FT_STR_DIR)/ft_atoi.c \ - $(FT_STR_DIR)/ft_atoi_base.c \ - $(FT_STR_DIR)/ft_itoa.c \ - $(FT_STR_DIR)/ft_itoa_base.c \ - $(FT_STR_DIR)/ft_perror.c \ - $(FT_STR_DIR)/ft_putendl_fd.c \ - $(FT_STR_DIR)/ft_putnbr_fd.c \ - $(FT_STR_DIR)/ft_putstr_fd.c \ - $(FT_STR_DIR)/ft_shift_args.c \ - $(FT_STR_DIR)/ft_split.c \ - $(FT_STR_DIR)/ft_splits.c \ - $(FT_STR_DIR)/ft_str_isalpha.c \ - $(FT_STR_DIR)/ft_str_isalnum.c \ - $(FT_STR_DIR)/ft_str_isbool.c \ - $(FT_STR_DIR)/ft_str_isdigit.c \ - $(FT_STR_DIR)/ft_str_isfloat.c \ - $(FT_STR_DIR)/ft_str_ishex.c \ - $(FT_STR_DIR)/ft_str_isdouble.c \ - $(FT_STR_DIR)/ft_str_isint.c \ - $(FT_STR_DIR)/ft_str_islong.c \ - $(FT_STR_DIR)/ft_str_isnum.c \ - $(FT_STR_DIR)/ft_str_isoct.c \ - $(FT_STR_DIR)/ft_str_isvalid.c \ - $(FT_STR_DIR)/ft_str_replace.c \ - $(FT_STR_DIR)/ft_strappend_c.c \ - $(FT_STR_DIR)/ft_strchr.c \ - $(FT_STR_DIR)/ft_strclen.c \ - $(FT_STR_DIR)/ft_strcmp.c \ - $(FT_STR_DIR)/ft_strcnb.c \ - $(FT_STR_DIR)/ft_strcspn.c \ - $(FT_STR_DIR)/ft_strdup.c \ - $(FT_STR_DIR)/ft_strend_with.c \ - $(FT_STR_DIR)/ft_strerror.c \ - $(FT_STR_DIR)/ft_striteri.c \ - $(FT_STR_DIR)/ft_strjoin.c \ - $(FT_STR_DIR)/ft_strlcat.c \ - $(FT_STR_DIR)/ft_strlcpy.c \ - $(FT_STR_DIR)/ft_strlen.c \ - $(FT_STR_DIR)/ft_strmapi.c \ - $(FT_STR_DIR)/ft_strncmp.c \ - $(FT_STR_DIR)/ft_strndup.c \ - $(FT_STR_DIR)/ft_strnstr.c \ - $(FT_STR_DIR)/ft_strrchr.c \ - $(FT_STR_DIR)/ft_strspn.c \ - $(FT_STR_DIR)/ft_strstart_with.c \ - $(FT_STR_DIR)/ft_strtok.c \ - $(FT_STR_DIR)/ft_strtrim.c \ - $(FT_STR_DIR)/ft_substr.c \ - $(FT_STR_DIR)/ft_utoa.c \ - $(FT_STR_DIR)/get_next_line.c \ - -FT_T_STRING_SRC = \ - $(FT_T_STRING_DIR)/ft_string_append.c \ - $(FT_T_STRING_DIR)/ft_string_new.c \ - $(FT_T_STRING_DIR)/ft_string_put.c \ - $(FT_T_STRING_DIR)/ft_string_from.c \ - $(FT_T_STRING_DIR)/ft_string_clear.c \ - $(FT_T_STRING_DIR)/ft_string_destroy.c \ - $(FT_T_STRING_DIR)/ft_string_insert.c \ - $(FT_T_STRING_DIR)/ft_string_reserve.c \ - $(FT_T_STRING_DIR)/ft_string_resize.c \ - $(FT_T_STRING_DIR)/ft_string_shrink.c \ - $(FT_T_STRING_DIR)/ft_string_substr.c \ - $(FT_T_STRING_DIR)/ft_string_to_str.c \ - $(FT_T_STRING_DIR)/ft_string_trim.c \ - $(FT_T_STRING_DIR)/ft_string_cmp.c \ - $(FT_T_STRING_DIR)/ft_string_get.c \ - $(FT_T_STRING_DIR)/ft_string_chr.c \ - $(FT_T_STRING_DIR)/ft_string_replace.c \ - $(FT_T_STRING_DIR)/ft_string_set.c - -FT_MEM_SRC = \ - $(FT_MEM_DIR)/ft_apply_2d.c \ - $(FT_MEM_DIR)/ft_bzero.c \ - $(FT_MEM_DIR)/ft_calloc.c \ - $(FT_MEM_DIR)/ft_fd_to_buff.c \ - $(FT_MEM_DIR)/ft_free.c \ - $(FT_MEM_DIR)/ft_free_2d.c \ - $(FT_MEM_DIR)/ft_len_2d.c \ - $(FT_MEM_DIR)/ft_malloc.c \ - $(FT_MEM_DIR)/ft_memchr.c \ - $(FT_MEM_DIR)/ft_memcmp.c \ - $(FT_MEM_DIR)/ft_memcpy.c \ - $(FT_MEM_DIR)/ft_memmap.c \ - $(FT_MEM_DIR)/ft_memmove.c \ - $(FT_MEM_DIR)/ft_memset.c \ - $(FT_MEM_DIR)/ft_qsort.c \ - $(FT_MEM_DIR)/ft_realloc.c \ - $(FT_MEM_DIR)/ft_swap.c - -FT_CHR_SRC = \ - $(FT_CHR_DIR)/ft_isalnum.c \ - $(FT_CHR_DIR)/ft_isalpha.c \ - $(FT_CHR_DIR)/ft_isascii.c \ - $(FT_CHR_DIR)/ft_isdigit.c \ - $(FT_CHR_DIR)/ft_ishexdigit.c \ - $(FT_CHR_DIR)/ft_islower.c \ - $(FT_CHR_DIR)/ft_isoctdigit.c \ - $(FT_CHR_DIR)/ft_isprint.c \ - $(FT_CHR_DIR)/ft_isspace.c \ - $(FT_CHR_DIR)/ft_isupper.c \ - $(FT_CHR_DIR)/ft_putchar_fd.c \ - $(FT_CHR_DIR)/ft_tolower.c \ - $(FT_CHR_DIR)/ft_toupper.c - -FT_VEC_SRC = \ - $(FT_VEC_DIR)/ft_vec_add.c \ - $(FT_VEC_DIR)/ft_vec_apply.c \ - $(FT_VEC_DIR)/ft_vec_at.c \ - $(FT_VEC_DIR)/ft_vec_cat.c \ - $(FT_VEC_DIR)/ft_vec_clear.c \ - $(FT_VEC_DIR)/ft_vec_destroy.c \ - $(FT_VEC_DIR)/ft_vec_filter.c \ - $(FT_VEC_DIR)/ft_vec_get.c \ - $(FT_VEC_DIR)/ft_vec_map.c \ - $(FT_VEC_DIR)/ft_vec_new.c \ - $(FT_VEC_DIR)/ft_vec_pop.c \ - $(FT_VEC_DIR)/ft_vec_remove.c \ - $(FT_VEC_DIR)/ft_vec_reserve.c \ - $(FT_VEC_DIR)/ft_vec_reverse.c \ - $(FT_VEC_DIR)/ft_vec_shift.c \ - $(FT_VEC_DIR)/ft_vec_shrink.c \ - $(FT_VEC_DIR)/ft_vec_sort.c \ - $(FT_VEC_DIR)/ft_vec_swap.c \ - $(FT_VEC_DIR)/ft_vec_to_array.c - -FT_OPTIONAL_SRC = \ - $(FT_OPTIONAL_DIR)/ft_optional_chain.c \ - $(FT_OPTIONAL_DIR)/ft_optional_copy.c \ - $(FT_OPTIONAL_DIR)/ft_optional_destroy.c \ - $(FT_OPTIONAL_DIR)/ft_optional_new.c \ - $(FT_OPTIONAL_DIR)/ft_optional_unwrap.c - -FT_ARGS_SRC = \ - $(FT_ARGS_DIR)/ft_arg_custom_checker.c \ - $(FT_ARGS_DIR)/ft_parse_args.c \ - $(FT_ARGS_DIR)/ft_parse_err.c \ - $(FT_ARGS_DIR)/ft_parse_opt.c \ - $(FT_ARGS_DIR)/ft_progname.c \ - $(FT_ARGS_DIR)/ft_set_opt_args.c \ - $(FT_ARGS_DIR)/ft_setup_prog.c \ - $(FT_ARGS_DIR)/ft_version.c - -# Counpound sources - -FT_LIST_SRC = \ - $(FT_LIST_LL_SRC) \ - $(FT_LIST_DL_SRC) \ - -FT_STRING_SRC = \ - $(FT_CHR_SRC) \ - $(FT_MEM_SRC) \ - $(FT_STR_SRC) \ - $(FT_T_STRING_SRC) - -# Tests sources - -TESTS_SRC =\ - $(TESTS_DIR)/ft_args/tests_custom_checker.c \ - $(TESTS_DIR)/ft_args/tests_optlist.c \ - $(TESTS_DIR)/ft_args/tests_progname.c \ - $(TESTS_DIR)/ft_args/tests_version.c \ - $(TESTS_DIR)/ft_args/tests_setup_prog.c \ - $(TESTS_DIR)/ft_args/args_tests.c \ - \ - $(TESTS_DIR)/ft_list/ll_tests/ll_tests_utils.c \ - $(TESTS_DIR)/ft_list/ll_tests/ll_list_tests.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_push.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_new.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_map.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_rev.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_sizers.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_apply.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_iterators.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_clear.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_copy.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_create.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_deletors.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_find.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_get.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_subrange.c \ - $(TESTS_DIR)/ft_list/ll_tests/tests_list_add.c \ - $(TESTS_DIR)/ft_list/dl_tests/dl_tests_utils.c \ - $(TESTS_DIR)/ft_list/dl_tests/dl_list_tests.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_add.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_clear.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_copy.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_create.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_delete.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_iterators.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_get.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_subrange.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_map.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_new.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_push.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_rev.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_sizers.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_apply.c \ - $(TESTS_DIR)/ft_list/dl_tests/tests_dlist_find.c \ - \ - $(TESTS_DIR)/ft_map/map_tests.c \ - $(TESTS_DIR)/ft_map/tests_map_remove.c \ - $(TESTS_DIR)/ft_map/tests_map_hash.c \ - $(TESTS_DIR)/ft_map/tests_map_create.c \ - $(TESTS_DIR)/ft_map/tests_map_destroy.c \ - $(TESTS_DIR)/ft_map/tests_map_set_cmphash.c \ - $(TESTS_DIR)/ft_map/tests_map_get.c \ - $(TESTS_DIR)/ft_map/tests_map_size.c \ - $(TESTS_DIR)/ft_map/tests_map_cappacity.c \ - $(TESTS_DIR)/ft_map/tests_map_clear.c \ - $(TESTS_DIR)/ft_map/tests_map_set.c \ - \ - $(TESTS_DIR)/ft_math/tests_abs.c \ - $(TESTS_DIR)/ft_math/tests_align.c \ - $(TESTS_DIR)/ft_math/tests_clamp.c \ - $(TESTS_DIR)/ft_math/tests_complex.c \ - $(TESTS_DIR)/ft_math/tests_intrange.c \ - $(TESTS_DIR)/ft_math/tests_log.c \ - $(TESTS_DIR)/ft_math/tests_minmax.c \ - $(TESTS_DIR)/ft_math/tests_pow.c \ - $(TESTS_DIR)/ft_math/tests_sqrt.c \ - $(TESTS_DIR)/ft_math/tests_round.c \ - $(TESTS_DIR)/ft_math/math_tests.c \ - \ - $(TESTS_DIR)/ft_optional/tests_optional_chain.c \ - $(TESTS_DIR)/ft_optional/tests_optional_copy.c \ - $(TESTS_DIR)/ft_optional/tests_optional_destroy.c \ - $(TESTS_DIR)/ft_optional/tests_optional_dup.c \ - $(TESTS_DIR)/ft_optional/tests_optional_from_val.c \ - $(TESTS_DIR)/ft_optional/tests_optional_map.c \ - $(TESTS_DIR)/ft_optional/tests_optional_new.c \ - $(TESTS_DIR)/ft_optional/tests_optional_unwrap.c \ - $(TESTS_DIR)/ft_optional/optional_tests.c \ - \ - $(TESTS_DIR)/ft_pair/tests_pair_cmp.c \ - $(TESTS_DIR)/ft_pair/tests_pair_cmp_first.c \ - $(TESTS_DIR)/ft_pair/tests_pair_cmp_second.c \ - $(TESTS_DIR)/ft_pair/tests_pair_destroy.c \ - $(TESTS_DIR)/ft_pair/tests_pair_get_first.c \ - $(TESTS_DIR)/ft_pair/tests_pair_get_second.c \ - $(TESTS_DIR)/ft_pair/tests_pair_new.c \ - $(TESTS_DIR)/ft_pair/tests_pair_set.c \ - $(TESTS_DIR)/ft_pair/pair_tests.c \ - \ - $(TESTS_DIR)/ft_string/ft_char/tests_isalnum.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isalpha.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isascii.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isdigit.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_ishexdigit.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isoctdigit.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isspace.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_isprint.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_puchar.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_tolower.c \ - $(TESTS_DIR)/ft_string/ft_char/tests_toupper.c \ - $(TESTS_DIR)/ft_string/ft_char/ft_char_tests.c \ - \ - $(TESTS_DIR)/ft_string/ft_mem/tests_apply_2d.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_bzero.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_calloc.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_fd_to_buff.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_free.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_free_2d.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_len_2d.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memchr.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memcmp.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memcpy.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memmap.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memmove.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_memset.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_qsort.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_realloc.c \ - $(TESTS_DIR)/ft_string/ft_mem/tests_swap.c \ - $(TESTS_DIR)/ft_string/ft_mem/mem_tests.c \ - \ - $(TESTS_DIR)/ft_string/ft_str/test_atoi_base.c \ - $(TESTS_DIR)/ft_string/ft_str/test_atoi.c \ - $(TESTS_DIR)/ft_string/ft_str/test_atof.c \ - $(TESTS_DIR)/ft_string/ft_str/test_gnl.c \ - $(TESTS_DIR)/ft_string/ft_str/test_itoa_base.c \ - $(TESTS_DIR)/ft_string/ft_str/test_itoa.c \ - $(TESTS_DIR)/ft_string/ft_str/test_putendl.c \ - $(TESTS_DIR)/ft_string/ft_str/test_putnbr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_putstr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_shift_args.c \ - $(TESTS_DIR)/ft_string/ft_str/test_split.c \ - $(TESTS_DIR)/ft_string/ft_str/test_splits.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isalpha.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isalnum.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isdouble.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isdigit.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isbool.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isfloat.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_ishex.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isint.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_islong.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isnum.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isoct.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_isvalid.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strchr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strclen.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strcmp.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strcnb.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strcspn.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strdup.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strend_with.c \ - $(TESTS_DIR)/ft_string/ft_str/test_striteri.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strjoin.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strlcat.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strlcpy.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strlen.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strmapi.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strncmp.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strndup.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strnstr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strrchr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strspn.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strstart_with.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_replace.c \ - $(TESTS_DIR)/ft_string/ft_str/test_str_replace_chr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strappend_c.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strtok.c \ - $(TESTS_DIR)/ft_string/ft_str/test_strtrim.c \ - $(TESTS_DIR)/ft_string/ft_str/test_substr.c \ - $(TESTS_DIR)/ft_string/ft_str/test_utoa.c \ - $(TESTS_DIR)/ft_string/ft_str/str_tests.c \ - $(TESTS_DIR)/ft_string/string_tests.c \ - \ - $(TESTS_DIR)/ft_string/ft_string/test_append.c \ - $(TESTS_DIR)/ft_string/ft_string/test_append_c.c \ - $(TESTS_DIR)/ft_string/ft_string/test_append_n.c \ - $(TESTS_DIR)/ft_string/ft_string/test_append_s.c \ - $(TESTS_DIR)/ft_string/ft_string/test_append_sn.c \ - $(TESTS_DIR)/ft_string/ft_string/test_cap.c \ - $(TESTS_DIR)/ft_string/ft_string/test_chr.c \ - $(TESTS_DIR)/ft_string/ft_string/test_clear.c \ - $(TESTS_DIR)/ft_string/ft_string/test_cmp.c \ - $(TESTS_DIR)/ft_string/ft_string/test_cmp_str.c \ - $(TESTS_DIR)/ft_string/ft_string/test_destroy.c \ - $(TESTS_DIR)/ft_string/ft_string/test_from.c \ - $(TESTS_DIR)/ft_string/ft_string/test_from_c.c \ - $(TESTS_DIR)/ft_string/ft_string/test_from_n.c \ - $(TESTS_DIR)/ft_string/ft_string/test_from_s.c \ - $(TESTS_DIR)/ft_string/ft_string/test_from_sn.c \ - $(TESTS_DIR)/ft_string/ft_string/test_get.c \ - $(TESTS_DIR)/ft_string/ft_string/test_insert.c \ - $(TESTS_DIR)/ft_string/ft_string/test_insert_c.c \ - $(TESTS_DIR)/ft_string/ft_string/test_insert_n.c \ - $(TESTS_DIR)/ft_string/ft_string/test_insert_s.c \ - $(TESTS_DIR)/ft_string/ft_string/test_insert_sn.c \ - $(TESTS_DIR)/ft_string/ft_string/test_len.c \ - $(TESTS_DIR)/ft_string/ft_string/test_ncmp.c \ - $(TESTS_DIR)/ft_string/ft_string/test_ncmp_str.c \ - $(TESTS_DIR)/ft_string/ft_string/test_new.c \ - $(TESTS_DIR)/ft_string/ft_string/test_offset.c \ - $(TESTS_DIR)/ft_string/ft_string/test_put.c \ - $(TESTS_DIR)/ft_string/ft_string/test_rchr.c \ - $(TESTS_DIR)/ft_string/ft_string/test_replace.c \ - $(TESTS_DIR)/ft_string/ft_string/test_replace_chr.c \ - $(TESTS_DIR)/ft_string/ft_string/test_reserve.c \ - $(TESTS_DIR)/ft_string/ft_string/test_resize.c \ - $(TESTS_DIR)/ft_string/ft_string/test_roffset.c \ - $(TESTS_DIR)/ft_string/ft_string/test_set.c \ - $(TESTS_DIR)/ft_string/ft_string/test_set_inplace.c \ - $(TESTS_DIR)/ft_string/ft_string/test_set_n.c \ - $(TESTS_DIR)/ft_string/ft_string/test_shrink.c \ - $(TESTS_DIR)/ft_string/ft_string/test_substr.c \ - $(TESTS_DIR)/ft_string/ft_string/test_to_str.c \ - $(TESTS_DIR)/ft_string/ft_string/test_trim.c \ - $(TESTS_DIR)/ft_string/ft_string/test_trim_chr.c \ - $(TESTS_DIR)/ft_string/ft_string/test_trimstr.c \ - $(TESTS_DIR)/ft_string/ft_string/t_string_tests.c \ - \ - $(TESTS_DIR)/ft_vector/tests_vec_add.c \ - $(TESTS_DIR)/ft_vector/tests_vec_apply.c \ - $(TESTS_DIR)/ft_vector/tests_vec_at.c \ - $(TESTS_DIR)/ft_vector/tests_vec_cat.c \ - $(TESTS_DIR)/ft_vector/tests_vec_clear.c \ - $(TESTS_DIR)/ft_vector/tests_vec_convert_alloc_array.c \ - $(TESTS_DIR)/ft_vector/tests_vec_destroy.c \ - $(TESTS_DIR)/ft_vector/tests_vec_filter.c \ - $(TESTS_DIR)/ft_vector/tests_vec_from_array.c \ - $(TESTS_DIR)/ft_vector/tests_vec_from_size.c \ - $(TESTS_DIR)/ft_vector/tests_vec_get.c \ - $(TESTS_DIR)/ft_vector/tests_vec_map.c \ - $(TESTS_DIR)/ft_vector/tests_vec_new.c \ - $(TESTS_DIR)/ft_vector/tests_vec_pop.c \ - $(TESTS_DIR)/ft_vector/tests_vec_remove.c \ - $(TESTS_DIR)/ft_vector/tests_vec_remove_if.c \ - $(TESTS_DIR)/ft_vector/tests_vec_reserve.c \ - $(TESTS_DIR)/ft_vector/tests_vec_reverse.c \ - $(TESTS_DIR)/ft_vector/tests_vec_shift.c \ - $(TESTS_DIR)/ft_vector/tests_vec_shrink.c \ - $(TESTS_DIR)/ft_vector/tests_vec_sort.c \ - $(TESTS_DIR)/ft_vector/tests_vec_swap.c \ - $(TESTS_DIR)/ft_vector/tests_vec_to_array.c \ - $(TESTS_DIR)/ft_vector/vector_tests.c \ - \ - $(TESTS_DIR)/main_tests.c \ - $(TESTS_DIR)/lambdas_for_tests.c \ - $(TESTS_DIR)/tests_utils.c - -# Inner variables for targets - -STABLE = \ - $(FT_MATH_SRC) \ - $(FT_LIST_SRC) \ - $(FT_VEC_SRC) \ - $(FT_STRING_SRC) \ - $(FT_MAP_SRC) \ - $(FT_OPTIONAL_SRC) \ - $(FT_ARGS_SRC) \ - $(FT_PAIR_SRC) \ - -UNSTABLE = \ - -INNER_SRC = \ - $(STABLE) - -# Check if user wants to compile unstable sources -# to compile unstable sources run make with TARGET=UNSTABLE -ifeq (UNSTABLE, $(findstring UNSTABLE, $(TARGET))) -INNER_SRC += \ - $(UNSTABLE) -endif -# Check if user wants to compile all sources -# to compile all sources run make with TARGET=ALL -ifeq (ALL, $(findstring ALL, $(TARGET))) -INNER_SRC = \ - $(STABLE) \ - $(UNSTABLE) -endif - -# Objects creation - -# add prefix to sources to specify the directory src/ -SRCS = $(addprefix $(SRC_DIR)/, $(INNER_SRC)) - -# add prefix to sources to specify the directory build/ for objects -OBJ = $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/,$(INNER_SRC))) - -# add prefix to sources to specify the directory build/tests/ for test objects -TOBJ = $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/$(TESTS_DIR)/,$(INNER_SRC))) -TOBJ += $(patsubst %.c, %.o, $(addprefix $(BUILD_DIR)/,$(TESTS_SRC))) - -# Inner variables for rules - -# Get the max length of the sources names to align the output -MAX_FILE_LEN = $(shell $(PRINTF) "%s\n" $(SRCS) | \ - awk '{print length}' | sort -n | tail -1) - -# Rules - -# Default rule for objects imported from src/ -$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c - @$(ECHO) -n $(GRAY) "building from " - @$(PRINTF) "%*s ... "$(RESET) $(MAX_FILE_LEN) $< - @mkdir -p $(dir $@) - @( $(CC) $(CFLAGS) -c $< -o $@ 2>> $(CLOG_FILE) && \ - $(ECHO) $(GREEN) "Success" $(RESET) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) \ - $(BOLD) "see:" $(CLOG_FILE) $(RESET) - -# Rule for tests objects imported from src/ -$(BUILD_DIR)/$(TESTS_DIR)/%.o: $(SRC_DIR)/%.c - @$(ECHO) -n $(GRAY) "building from " $< "..." $(RESET) - @mkdir -p $(dir $@) - @( $(CC) $(CFLAGS) $(TEST_FLAGS) -c $< -o $@ \ - 2>> $(CLOG_FILE) && \ - $(ECHO) $(GREEN) "Success" $(RESET) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) \ - $(BOLD) "see:" $(CLOG_FILE) $(RESET) - -# Rule for tests objects imported from tests/ -$(BUILD_DIR)/$(TESTS_DIR)/%.o: $(TESTS_DIR)/%.c - @$(ECHO) -n $(GRAY) "building from " $< "..." $(RESET) - @mkdir -p $(dir $@) - @( $(CC) $(CFLAGS) $(TEST_FLAGS) -c $< -o $@ \ - 2>> $(CLOG_FILE) && \ - $(ECHO) $(GREEN) "Success" $(RESET) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) \ - $(BOLD) "see:" $(CLOG_FILE) $(RESET) - -# Default rule -all: $(OUTDIR)/lib$(NAME).a - -tmp: - @echo $(SRCS) - -so: $(OUTDIR)/lib$(NAME).so - -# Rule for shared library -$(OUTDIR)/lib$(NAME).so: $(OBJ) - @$(ECHO) -n $(GRAY) "Making ... " $(RESET) $(BOLD) \ - "$(OUTDIR)/lib$(NAME).so" $(RESET) $(GRAY) " ... " $(RESET) - @( $(CC) -shared -o $(OUTDIR)/lib$(NAME).so $(OBJ) 2> /dev/null && \ - $(ECHO) $(GREEN) "Success" $(RESET) && $(RM) $(CLOG_FILE) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) "see:" $(CLOG_FILE) - -# Rule for static library -$(OUTDIR)/lib$(NAME).a: $(OBJ) - @$(ECHO) -n $(GRAY) "Making ... " $(RESET) $(BOLD) \ - "$(OUTDIR)/lib$(NAME).a" $(RESET) $(GRAY) " ... " $(RESET) - @( $(AR) -rcs $(OUTDIR)/lib$(NAME).a $(OBJ) 2> /dev/null && \ - $(ECHO) $(GREEN) "Success" $(RESET) && $(RM) $(CLOG_FILE) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) "see:" $(CLOG_FILE) - -# Rule to compile and run tests -$(TEST_NAME): $(TOBJ) - @$(ECHO) -n $(GRAY) "Compiling tests ... " $(RESET) - @$(CC) $(CFLAGS) $(TOBJ) -o $(TEST_NAME) $(TEST_FLAGS) \ - $(LDFLAGS) -lgcov \ - 2>> $(CLOG_FILE) && \ - $(ECHO) $(GREEN) "Success" $(RESET) || \ - $(ECHO) $(RED) "Failed" $(RESET) - @$(ECHO) -n $(GRAY) "Running tests ... " $(RESET) && \ - ./$(TEST_NAME) && \ - $(ECHO) $(GREEN) "Success" $(RESET) || \ - $(ECHO) $(RED) "Failed" $(RESET) - -# Rule to generate coverage using llvm -$(COVERAGE_DIR): $(TEST_NAME) - @$(ECHO) -n $(GRAY) "Generating profraw ... " $(RESET) && \ - ./$(TEST_NAME) && \ - $(ECHO) -n $(GRAY) " profdata ... " $(RESET) && \ - $(PRD) merge -sparse default.profraw -o \ - $(TEST_NAME).profdata && \ - $(ECHO) -n $(GRAY) "coverage in html ... " \ - $(RESET) && \ - $(COV) show -format=html \ - -instr-profile=$(TEST_NAME).profdata \ - -ignore-filename-regex=$(TESTS_DIR)/* \ - --show-branches=count \ - ./$(TEST_NAME) -output-dir=$(COVERAGE_DIR) > /dev/null && \ - $(RM) *.profraw *.profdata && \ - $(ECHO) $(GREEN) "Success" $(RESET) || \ - $(ECHO) $(RED) "Failed" $(RESET) - -# Rule to compile using debug flags -debug: - @$(ECHO) $(GRAY) "Compiling debug, flags are" $(RESET) \ - "$(CFLAGS) $(DEBUG_FLAGS)" $(RESET) && \ - make --no-print-directory -C . re \ - CFLAGS="$(CFLAGS) $(DEBUG_FLAGS)" && \ - make --no-print-directory -C . \ - so CFLAGS="$(CFLAGS) $(DEBUG_FLAGS)" && \ - $(ECHO) $(GREEN) "Success" $(RESET) || \ - $(ECHO) $(RED) "Failed" $(RESET) - -# Rule to clean objects -clean: - @$(ECHO) -n $(GRAY) "Clean ... " $(RESET) && \ - ( $(RM) -rf $(BUILD_DIR) $(CLOG_FILE) $(TEST_NAME) *.gcov \ - *.gcno *.gcda 2> /dev/null && \ - $(ECHO) $(GREEN) "Success" $(RESET) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) - -# Rule to clean objects and libraries/compiled files -fclean: clean - @$(ECHO) -n $(GRAY) "FClean ... " $(RESET) && \ - ( $(RM) -rf $(OUTDIR)/lib$(NAME).a l$(OUTDIR)/ib$(NAME).so \ - $(COVERAGE_DIR) $(TEST_NAME) \ - *.profraw *.profdata Doxygen 2> /dev/null && \ - $(ECHO) $(GREEN) "Success" $(RESET) ) || \ - $(ECHO) $(RED) "Failed" $(RESET) - -# Rule to recompile -re: fclean - @$(ECHO) -ne $(GRAY) "Recompiling ..." $(RESET) "\n" && \ - make --no-print-directory all && \ - $(ECHO) $(GREEN) "Success" $(RESET) || \ - $(ECHO) $(RED) "Failed" $(RESET) - --include $(OBJ:.o=.d) - -# rule to force rules to be executed even if files exist -.PHONY: re fclean clean diff --git a/libft/include/ft_list_types.h b/libft/include/ft_list_types.h deleted file mode 100644 index 88d4476..0000000 --- a/libft/include/ft_list_types.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_types.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/07 10:37:44 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:48:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FT_LIST_TYPES_H -# define FT_LIST_TYPES_H - -# include -# define FTLIST_SUCCESS 0 -# define FTLIST_FAILURE 1 - -/// @brief Structure representing a node in a list -/// @param data The data of the node -/// @param next The next node -typedef struct s_list -{ - void *data; - struct s_list *next; -} t_list; - -/// @brief Structure representing a node in a doubly linked list -/// @param data The data of the node -/// @param next The next node -/// @param prev The previous node -typedef struct s_dl_list -{ - struct s_dl_list *next; - struct s_dl_list *prev; - void *data; -} t_dlist; - -/// @brief Type of function to apply on a doubly linked list node -typedef void (*t_dnode_apply)(t_dlist *); - -/// @brief Type of function to apply on a simply linked list node -typedef void (*t_lnode_apply)(t_list *); - -#endif /* FT_LIST_TYPES_H */ diff --git a/libft/include/ft_math.h b/libft/include/ft_math.h deleted file mode 100644 index 6f14661..0000000 --- a/libft/include/ft_math.h +++ /dev/null @@ -1,187 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_math.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 18:59:37 by bgoulard #+# #+# */ -/* Updated: 2024/08/21 21:38:22 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FT_MATH_H -# define FT_MATH_H - -/* ************************************************************************** */ -/* */ -/* Module: FT_MATH */ -/* Prefix: ft_* */ -/* */ -/* The FT_MATH module provides a way to handle task or queries related */ -/* to arithmetic operations. */ -/* */ -/* ************************************************************************** */ - -# include "ft_math_types.h" -# include - -/// @brief Return the nearest aligned value of size on the alignment -/// @param size The size to align -/// @param alignment The alignment to use -/// @return The aligned value of size on the alignment -/// @note Optimized for power of 2 alignment -size_t ft_align_2(size_t size, size_t alignment); - -/// @brief Return the nearest aligned value of size on the alignment -/// @param size The size to align -/// @param alignment The alignment to use -/// @return The aligned value of size on the alignment -/// @note See: ft_align_2 for an optimized version for power of 2 -size_t ft_align(size_t size, size_t alignment); - -/// @brief return the logaritm of the number in the specified base -/// @param nbr number to get the logaritm -/// @param base base of the logaritm -/// @return the logaritm of the number in the specified base. in case of error -/// return -1 -int ft_llogof(long long nbr, int base); - -/// @brief return the logaritm of the number in the specified base -/// @param nbr number to get the logaritm -/// @param base base of the logaritm -/// @return the logaritm of the number in the specified base. in case of error -/// return -1 -int ft_ullogof(unsigned long long nbr, int base); - -/// @brief return the logaritm of the number in the specified base -/// @param nbr number to get the logaritm -/// @param base base of the logaritm -/// @return the logaritm of the number in the specified base. in case of error -/// return -1 -int ft_logof(int nbr, int base); - -/// @brief return the logaritm of the number in the specified base -/// @param nbr number to get the logaritm -/// @param base base of the logaritm -/// @return the logaritm of the number in the specified base. in case of error -/// return -1 -int ft_log(int nbr); - -/// @brief returns the minimum of a and b -/// @param a first number -/// @param b second number -/// @return the smallest between a and b -int ft_min(int a, int b); - -/// @brief returns the maximum of a and b -/// @param a first number -/// @param b second number -/// @return the biggest between a and b -int ft_max(int a, int b); - -/// @brief Clamp a value between a minimum and a maximum -/// @param value The value to clamp -/// @param min The minimum value -/// @param max The maximum value -/// @return The clamped value between or at the minimum or maximum -/// @note This is a clamp function aka inferior and superior to min and max -/// are set to min and max -/// @file ft_clamp.c -int ft_clamp(int value, int min, int max); - -/// @brief Clamp a value between a minimum and a maximum -/// @param value The value to clamp -/// @param min The minimum value -/// @param max The maximum value -/// @return The clamped value between or at the minimum or maximum -/// @note See ft_clamp. -/// @file ft_clamp.c -float ft_clamp_f(float value, float min, float max); - -/// @brief Clamp a value between a minimum and a maximum -/// @param value The value to clamp -/// @param min The minimum value -/// @param max The maximum value -/// @return The clamped value between or at the minimum or maximum -/// @note See ft_clamp. -/// @file ft_clamp.c -double ft_clamp_d(double value, double min, double max); - -/// @brief Take a value in a range and puts it in another range of 1 to new_max -/// @param value The value to range -/// @param min The minimum value of the range -/// @param max The maximum value of the range -/// @param new_max The maximum value of the new range -/// @return The value ranged between 1 and new_max -int ft_range(int value, int min, int max, int new_max); - -/// @brief Take a value in a range and puts it in another range of 1 to new_max -/// @param value The value to range -/// @param min The minimum value of the range -/// @param max The maximum value of the range -/// @param new_max The maximum value of the new range -/// @return The value ranged between 1 and new_max -/// @note See ft_range. -float ft_range_f(float value, float min, float max, float new_max); - -/// @brief Take a value in a range and puts it in another range of 1 to new_max -/// @param value The value to range -/// @param min The minimum value of the range -/// @param max The maximum value of the range -/// @param new_max The maximum value of the new range -/// @return The value ranged between 1 and new_max -/// @note See ft_range. -double ft_range_d(double value, double min, double max, double new_max); - -/// @brief Return the absolute value of a -/// @param a The value to get the absolute value -/// @return The absolute value of a -int ft_abs(int a); - -/// @brief Return the rounded value of x -/// @param x The value to round -/// @return The rounded value of x -/// @note This function round the value to the nearest integer -double ft_round(double x); - -/// @brief Return the power of a number x to the power of y -/// @param x The number to power -/// @param y The power -/// @return The result of x to the power of y -size_t ft_pow(size_t x, size_t y); - -/// @brief Return the root square of a number -/// @param nb The number to get the root square -/// @return The root square of nb -/// @note This function use the newton's method to get the root square -/// @note If nb is negative, return -1 -/// @file ft_sqrt.c -double ft_sqrt(double nb); - -/// @brief Return the absolute value of a -/// @param a The value to get the absolute value -/// @return The absolute value of a -/// @note See ft_abs. -double ft_complex_abs(t_complex nb); - -/// @brief Add a long to a complex number -/// @param nb The complex number to add the factor -/// @param factor The factor to add to the complex number -/// @return The complex number with the factor added -/// @note See ft_complex_addl. -t_complex ft_complex_addl(t_complex nb, long factor); - -/// @brief Multiply a complex number by a long -/// @param nb The complex number to multiply -/// @param factor The factor to multiply the complex number -/// @return The complex number multiplied by the factor -t_complex ft_complex_mull(t_complex nb, long factor); - -/// @brief Multiply a complex number by a double -/// @param nb The complex number to multiply -/// @param factor The factor to multiply the complex number -/// @return The complex number multiplied by the factor -t_complex ft_complex_muld(t_complex nb, double factor); - -#endif diff --git a/libft/tests/ft_args/args_tests.c b/libft/tests/ft_args/args_tests.c deleted file mode 100644 index f2db3f0..0000000 --- a/libft/tests/ft_args/args_tests.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* args_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 17:02:31 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 18:33:18 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/args_tests.h" - -int parse_args_test(void) -{ - return (0); -} - -int tests_args(void) -{ - int collect; - const t_test test[] = { - {"getset_version", getset_version_test}, {"getset_progname", \ - getset_program_name_test}, {"getset_opt_list", getset_opt_list_test}, - {"parse_args", parse_args_test}, {"setup_prog", tests_setup_prog}, - {"getset_custom_parser", getset_custom_checker_test}, {NULL, NULL}}; - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_args/tests_custom_checker.c b/libft/tests/ft_args/tests_custom_checker.c deleted file mode 100644 index 9a29e01..0000000 --- a/libft/tests/ft_args/tests_custom_checker.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_custom_checker.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 18:15:10 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 14:28:04 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_args.h" - -static bool loc_checker(const void *arg) -{ - const char *str = (const char *)arg; - - if (str[0] == 'a') - return (true); - return (false); -} - -int getset_custom_checker_test(void) -{ - ft_arg_set_custom_checker(loc_checker); - if (ft_arg_get_custom_checker() != loc_checker) - return (-1); - return (0); -} diff --git a/libft/tests/ft_args/tests_optlist.c b/libft/tests/ft_args/tests_optlist.c deleted file mode 100644 index 02e3b1c..0000000 --- a/libft/tests/ft_args/tests_optlist.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optlist.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/28 15:52:31 by bgoulard #+# #+# */ -/* Updated: 2024/05/28 15:52:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_args.h" -#include "ft_args_types.h" -#include - -static void empty(void *ar, char *arg) -{ - (void)ar; - (void)arg; -} - -int getset_opt_list_test(void) -{ - const t_opt *op2 = NULL; - const t_opt op1[] = { - {"--test", 't', &empty, 0}, - }; - - ft_set_opt_list(op1); - if (ft_get_opt_list() != op1) - return (1); - ft_set_opt_list(op2); - if (ft_get_opt_list() != op1) - return (2); - return (0); -} diff --git a/libft/tests/ft_args/tests_progname.c b/libft/tests/ft_args/tests_progname.c deleted file mode 100644 index 25b1052..0000000 --- a/libft/tests/ft_args/tests_progname.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_progname.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:37:47 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 22:38:23 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_args.h" -#include "ft_string.h" - -int getset_program_name_test(void) -{ - char *s1; - char *s2; - - s1 = "toto"; - s2 = 0; - ft_set_progname(s1); - if (ft_progname() != s1) - return (ft_putstr_fd(ft_progname(), 2), 1); - ft_set_progname(s2); - if (ft_progname() == s2) - return (2); - return (0); -} diff --git a/libft/tests/ft_args/tests_setup_prog.c b/libft/tests/ft_args/tests_setup_prog.c deleted file mode 100644 index 1a18709..0000000 --- a/libft/tests/ft_args/tests_setup_prog.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_setup_prog.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/28 15:55:09 by bgoulard #+# #+# */ -/* Updated: 2024/05/28 16:04:22 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_args.h" -#include "ft_string.h" - -int tests_setup_prog(void) -{ - const char *argv[] = {"dummy_prog", "--test", NULL}; - - ft_setup_prog(argv); - if (ft_progname() != argv[0]) - return (1); - if (ft_strcmp(ft_progversion(), VERSION) != 0) - return (2); - return (0); -} diff --git a/libft/tests/ft_args/tests_version.c b/libft/tests/ft_args/tests_version.c deleted file mode 100644 index e0d3675..0000000 --- a/libft/tests/ft_args/tests_version.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_version.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:37:13 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 22:38:27 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_args.h" -#include "ft_string.h" -#include - -int getset_version_test(void) -{ - char *s1; - char *s2; - - s1 = "toto"; - s2 = 0; - ft_set_version(s1); - if (ft_progversion() != s1) - return (ft_putstr_fd(ft_progversion(), STDERR_FILENO), 1); - ft_set_version(s2); - if (ft_progversion() == s2) - return (2); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/dl_list_tests.c b/libft/tests/ft_list/dl_tests/dl_list_tests.c deleted file mode 100644 index 2233d7c..0000000 --- a/libft/tests/ft_list/dl_tests/dl_list_tests.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* dl_list_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/12 20:37:03 by iron #+# #+# */ -/* Updated: 2024/05/30 12:10:48 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/dl_tests.h" - -static const t_test *init_tests(void) -{ - static const t_test var[] = { - {"add_front", t_dl_add_front}, {"add_back", \ - t_dl_add_back}, {"apply", t_dl_apply}, {\ - "apply_range", t_dl_apply_range}, {\ - "apply_range_node", t_dl_apply_range_node}, {\ - "clear", t_dl_clear}, {"clear_range", \ - t_dl_clear_range}, {"create", t_dl_create}, {\ - "copy_node", t_dl_copy_node}, {"copy_list", \ - t_dl_copy_list}, {"delete_self", \ - t_dl_delete_self}, {"delete_range", \ - t_dl_delete_range}, {"delete", t_dl_delete}, \ - {"find", t_dl_find}, {"get_datas", \ - t_dl_get_datas}, {"get_nodes", t_dl_get_nodes}, \ - {"at", t_dl_at}, {"begin", \ - t_dl_begin}, {"end", t_dl_end}, {\ - "map", t_dl_map}, {"new", t_dl_new}, \ - {"pop", t_dl_pop}, {"pop_back", \ - t_dl_pop_back}, {"push", t_dl_push}, \ - {"push_back", t_dl_push_back}, {"rev", \ - t_dl_rev}, {"size", t_dl_size}, {\ - "size_of_data", t_dl_size_of_data}, {\ - "subrange", t_dl_subrange}, {NULL, NULL}}; - - return (var); -} - -int tests_doubly_linked_list_all(void) -{ - int collect; - const t_test *test = init_tests(); - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_list/dl_tests/dl_tests_utils.c b/libft/tests/ft_list/dl_tests/dl_tests_utils.c deleted file mode 100644 index 303d040..0000000 --- a/libft/tests/ft_list/dl_tests/dl_tests_utils.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* dl_test_utils.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 11:08:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 14:27:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -void create_2elem_dlist(t_dlist **list, void **data1, void **data2) -{ - *data1 = malloc(sizeof(int)); - *data2 = malloc(sizeof(int)); - *(int *)*data1 = 42; - *(int *)*data2 = 21; - *list = NULL; - ft_dl_push(list, *data1); - ft_dl_push_back(list, *data2); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_add.c b/libft/tests/ft_list/dl_tests/tests_dlist_add.c deleted file mode 100644 index d630f0f..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_add.c +++ /dev/null @@ -1,73 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_add.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:48:41 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:54:39 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -int t_dl_add_front(void) -{ - t_dlist *list; - int *data; - int *data2; - - data = malloc(sizeof(int)); - data2 = malloc(sizeof(int)); - *data = 42; - *data2 = 21; - list = ft_dl_create(data2); - ft_dl_add_front(&list, NULL); - if (!list || list->next) - return (1); - else - { - ft_dl_add_front(&list, ft_dl_create(data)); - if (!list || list->data != data || !list->next) - return (1); - else if (list->next->data != data2 || list->next->next) - return (1); - else if (list->next->prev != list) - return (1); - } - ft_dl_clear(&list, free); - ft_dl_add_front(NULL, NULL); - return (0); -} - -int t_dl_add_back(void) -{ - t_dlist *list; - int *data; - int *data2; - - list = NULL; - data = malloc(sizeof(int)); - data2 = malloc(sizeof(int)); - *data = 42; - *data2 = 21; - ft_dl_add_back(&list, ft_dl_create(data)); - ft_dl_add_back(&list, NULL); - if (!list || list->next) - return (1); - else - { - ft_dl_add_back(&list, ft_dl_create(data2)); - if (!list || list->data != data || !list->next || \ - list->next->data != data2) - return (1); - else if (list->next->next || list->next->prev != list) - return (1); - } - ft_dl_clear(&list, free); - ft_dl_add_front(NULL, NULL); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_apply.c b/libft/tests/ft_list/dl_tests/tests_dlist_apply.c deleted file mode 100644 index 8776929..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_apply.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_apply.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:55:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:48:52 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -static void dnode_add42(t_dlist *node) -{ - *(int *)node->data += 42; -} - -int t_dl_apply(void) -{ - t_dlist *list; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - ft_dl_apply(list, add42); - if (ft_dl_size(list) != 2) - return (1); - else if (*(int *)list->data != 84) - return (2); - else if (*(int *)list->next->data != 63) - return (3); - ft_dl_clear(&list, free); - return (0); -} - -int t_dl_apply_range(void) -{ - t_dlist *list; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - ft_dl_apply_range(list, list->next, add42); - if (ft_dl_size(list) != 2) - return (1); - else if (*(int *)list->data != 84 || \ - *(int *)list->next->data != 21) - return (1); - return (ft_dl_clear(&list, free), 0); -} - -int t_dl_apply_range_node(void) -{ - t_dlist *list; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - ft_dl_apply_range_node(list, list->next, dnode_add42); - if (ft_dl_size(list) != 2) - return (1); - else if (*(int *)list->data != 84 || \ - *(int *)list->next->data != 21) - return (1); - return (ft_dl_clear(&list, free), 0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_clear.c b/libft/tests/ft_list/dl_tests/tests_dlist_clear.c deleted file mode 100644 index fe755e7..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_clear.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_clear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:56:57 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:57:45 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_clear(void) -{ - t_dlist *list; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_dl_create(data); - ft_dl_clear(&list, NULL); - list = ft_dl_create(data); - ft_dl_clear(&list, free); - return (0); -} - -// -//ft_dl_add_back(&list, ft_dl_create(data3)) -// data -> data2 -> data3 -//ft_dl_clear_range(list->next, list->next->next, NULL) -// data -> NULL -> data3 -//ft_dl_add_back(&list, ft_dl_create(data2)) -// data -> NULL -> data3 -> data2 -//ft_dl_clear_range(list->next->next, NULL, free) -// data -> NULL -> NULL -> NULL -//ft_dl_delete_range(list, NULL, NULL) -// delete nodes -// - -int t_dl_clear_range(void) -{ - t_dlist *list; - int *data; - int *data2; - int *data3; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - data3 = malloc(sizeof(int)); - *data3 = 63; - ft_dl_add_back(&list, ft_dl_create(data3)); - ft_dl_clear_range(list->next, list->next->next, NULL); - if ((ft_dl_size(list) != 3) || (list->data != data || \ - list->next->data || list->next->next->data != data3)) - return (1); - ft_dl_add_back(&list, ft_dl_create(data2)); - ft_dl_clear_range(list->next->next, NULL, free); - if (ft_dl_size(list) != 4 || list->data != data \ - || list->next->data || list->next->next->data) - return (2); - ft_dl_clear_range(list, NULL, free); - ft_dl_clear_range(NULL, NULL, free); - ft_dl_delete_range(list, NULL, NULL); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_copy.c b/libft/tests/ft_list/dl_tests/tests_dlist_copy.c deleted file mode 100644 index b055bd0..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_copy.c +++ /dev/null @@ -1,65 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_copy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:58:55 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:59:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_copy_node(void) -{ - int *data; - t_dlist *list; - t_dlist *copy; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_dl_create(data); - copy = ft_dl_copy_node(list); - if (!copy) - return (1); - else if (copy->data != list->data) - return (1); - else if (copy->next != list->next) - return (1); - else if (copy->prev != list->prev) - return (1); - ft_dl_clear(&list, free); - ft_dl_clear(©, NULL); - return (0); -} - -int t_dl_copy_list(void) -{ - t_dlist *list; - t_dlist *copy; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - copy = ft_dl_copy_list(list); - if (!copy) - return (1); - else if (copy->data != list->data) - return (1); - else if (!copy->next) - return (1); - else if (copy->next->data != list->next->data) - return (1); - else if (copy->next->next) - return (1); - else if (copy->next->prev != copy) - return (1); - ft_dl_clear(&list, free); - ft_dl_clear(©, NULL); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_create.c b/libft/tests/ft_list/dl_tests/tests_dlist_create.c deleted file mode 100644 index e7cfe18..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_create.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_create.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:58:15 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:00:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ -#include "ft_list.h" -#include "ft_list_types.h" -#include - -int t_dl_create(void) -{ - t_dlist *list; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_dl_create(data); - if (!list) - return (1); - else if (list->data != data) - return (1); - else if (list->next) - return (1); - else if (list->prev) - return (1); - ft_dl_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_delete.c b/libft/tests/ft_list/dl_tests/tests_dlist_delete.c deleted file mode 100644 index 8e8d872..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_delete.c +++ /dev/null @@ -1,110 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_delete.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:01:32 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:20:30 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_delete_self(void) -{ - int *data; - int *data2; - int *data3; - t_dlist *list; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - data3 = malloc(sizeof(int)); - *data3 = 63; - ft_dl_add_back(&list, ft_dl_create(data3)); - ft_dl_delete_self(list->next, NULL); - if (!list || list->data != data || !list->next || \ - list->next->data != data3 || list->next->next) - return (1); - ft_dl_clear(&list, free); - data3 = malloc(sizeof(int)); - *data3 = 63; - *data2 = 21; - list = ft_dl_create(data3); - ft_dl_add_back(&list, ft_dl_create(data2)); - ft_dl_delete_self(list->next, free); - if (list->next || list->data != data3) - return (1); - return (ft_dl_clear(&list, free), \ - ft_dl_delete_self(NULL, NULL), 0); -} -/* - ft_dl_add_back(&list, ft_dl_create(data3)); - // NULL <-(42)<=>(21)<=>(63)-> NULL - list2 = list->next; - // 42 <-(21)<=>(63)-> NULL - nb_deleted = ft_dl_delete_range(list, list->next, NULL); - // NULL <-(21)<=>(63)-> NULL - ft_dl_add_front(&list2, ft_dl_create(data)); - // NULL <-(42)<=>(21)<=>(63)-> NULL - list = list2; - nb_deleted = ft_dl_delete_range(list->next, list->next->next, free); - // NULL <-(42)<=>(63)-> NULL -*/ - -int t_dl_delete_range(void) -{ - t_dlist *list; - t_dlist *list2; - int *data_array[3]; - int nb_deleted; - - create_2elem_dlist(&list, (void **)&data_array[0], (void **)&data_array[1]); - data_array[2] = malloc(sizeof(int)); - *data_array[2] = 63; - ft_dl_add_back(&list, ft_dl_create(data_array[2])); - list2 = list->next; - nb_deleted = ft_dl_delete_range(list, list->next, NULL); - if (nb_deleted != 1 || ft_dl_size(list2) != 2 || *(int *)list2->data \ - != *data_array[1] || *(int *)list2->next->data != *data_array[2]) - return (1); - ft_dl_add_front(&list2, ft_dl_create(data_array[0])); - list = list2; - nb_deleted = ft_dl_delete_range(list->next, list->next->next, free); - if (nb_deleted != 1 || ft_dl_size(list) != 2 || *(int *)list2->data \ - != *data_array[0] || *(int *)list2->next->data != *data_array[2]) - return (1); - return (ft_dl_clear(&list2, free), 0); -} - -int t_dl_delete(void) -{ - t_dlist *list; - int *data; - int *data2; - int *data3; - int nb_deleted; - - data3 = malloc(sizeof(int)); - *data3 = 63; - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - ft_dl_add_back(&list, ft_dl_create(data3)); - nb_deleted = ft_dl_delete(&list, NULL); - if (nb_deleted != 3) - return (1); - else if (list) - return (1); - ft_dl_add_front(&list, ft_dl_create(data)); - ft_dl_add_back(&list, ft_dl_create(data2)); - ft_dl_add_back(&list, ft_dl_create(data3)); - nb_deleted = ft_dl_delete(&list, free); - if (nb_deleted != 3) - return (1); - else if (list) - return (1); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_find.c b/libft/tests/ft_list/dl_tests/tests_dlist_find.c deleted file mode 100644 index 2210e46..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_find.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_find.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:01:51 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:49:02 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -/* -ft_dl_add_back(&list, ft_dl_create(data2)); -// data-> data2 -*/ - -int t_dl_find(void) -{ - t_dlist *list; - t_dlist *found_ret[3]; - int *data; - int *data2; - int *data3; - - data3 = malloc(sizeof(int)); - *data3 = 21; - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - found_ret[0] = ft_dl_find(list, data2, NULL); - found_ret[1] = ft_dl_find(list, data3, NULL); - found_ret[2] = ft_dl_find(list, data3, cmp_int); - if (ft_dl_size(found_ret[0]) != 1 || found_ret[0]->data != data2) - return (1); - else if (found_ret[1]) - return (1); - else if (ft_dl_size(found_ret[2]) != 1 || found_ret[2]->data != data2) - return (1); - return (ft_dl_clear(&list, free), free(data3), 0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_get.c b/libft/tests/ft_list/dl_tests/tests_dlist_get.c deleted file mode 100644 index eed83af..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_get.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_get.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:04:21 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:04:43 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_get_datas(void) -{ - t_dlist *list; - int *data; - int *data2; - void **datas; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - datas = ft_dl_get_datas(list); - if (!datas) - return (1); - else if (datas[0] != data) - return (1); - else if (datas[1] != data2) - return (1); - if (ft_dl_get_datas(NULL)) - return (1); - ft_dl_clear(&list, free); - free(datas); - return (0); -} - -int t_dl_get_nodes(void) -{ - t_dlist *list; - int *data; - int *data2; - t_dlist **nodes; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - nodes = ft_dl_get_nodes(list); - if (!nodes) - return (1); - else if (nodes[0] != list) - return (1); - else if (nodes[1] != list->next) - return (1); - if (ft_dl_get_nodes(NULL)) - return (1); - ft_dl_clear(&list, free); - free(nodes); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_iterators.c b/libft/tests/ft_list/dl_tests/tests_dlist_iterators.c deleted file mode 100644 index 5f99449..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_iterators.c +++ /dev/null @@ -1,81 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_iterators.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:04:13 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:04:17 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_at(void) -{ - t_dlist *list; - t_dlist *at; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - at = ft_dl_at(list, 1); - if (!at) - return (1); - else if (at->data != data2) - return (1); - else if (at->next) - return (1); - else if (at->prev != list) - return (1); - ft_dl_clear(&list, free); - return (0); -} - -int t_dl_begin(void) -{ - t_dlist *list; - t_dlist *begin; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - begin = ft_dl_begin(list->next); - if (!begin) - return (1); - else if (begin != list) - return (1); - else if (begin->data != data) - return (1); - else if (begin->next != list->next) - return (1); - else if (begin->prev) - return (1); - ft_dl_clear(&list, free); - return (0); -} - -int t_dl_end(void) -{ - t_dlist *list; - t_dlist *end; - int *data; - int *data2; - - create_2elem_dlist(&list, (void **)&data, (void **)&data2); - end = ft_dl_end(list); - if (!end) - return (1); - else if (end->data != data2) - return (1); - else if (end->next) - return (1); - else if (end->prev != list) - return (1); - ft_dl_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_map.c b/libft/tests/ft_list/dl_tests/tests_dlist_map.c deleted file mode 100644 index e5c91c0..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_map.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:06:32 by bgoulard #+# #+# */ -/* Updated: 2024/07/19 18:24:00 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include -#include - -int t_dl_map(void) -{ - t_dlist *list; - t_dlist *map; - t_dlist *map2; - int *data1; - int *data2; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - map2 = ft_dl_map(list, NULL, free); - map = ft_dl_map(list, add42_ret, free); - if (!map) - return (1); - else if (*(int *)map->data != 84) - return (1); - else if (!map->next) - return (1); - else if (*(int *)map->next->data != 63) - return (1); - else if (map->next->next) - return (1); - else if (map2) - return (1); - ft_dl_clear(&list, free); - ft_dl_clear(&map, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_new.c b/libft/tests/ft_list/dl_tests/tests_dlist_new.c deleted file mode 100644 index 5f46385..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_new.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:05:52 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:06:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -int t_dl_new(void) -{ - t_dlist *list; - - list = ft_dl_new(); - if (!list) - return (1); - ft_dl_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_push.c b/libft/tests/ft_list/dl_tests/tests_dlist_push.c deleted file mode 100644 index 2d7063f..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_push.c +++ /dev/null @@ -1,115 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_push.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:07:52 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:07:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_pop(void) -{ - t_dlist *list; - int *data1; - int *data2; - int *ret; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - ret = ft_dl_pop(&list); - if (!list) - return (1); - else if (ret != data1) - return (2); - ret = ft_dl_pop(&list); - if (ret != data2) - return (3); - if (list) - return (4); - ret = ft_dl_pop(&list); - if (ret) - return (5); - ret = ft_dl_pop(NULL); - if (ret) - return (6); - return (free(data1), free(data2), 0); -} - -int t_dl_pop_back(void) -{ - t_dlist *list; - int *data1; - int *data2; - int *data3; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - data3 = ft_dl_pop_back(&list); - if (!list) - return (1); - else if (data3 != data2) - return (1); - data3 = ft_dl_pop_back(&list); - if (list) - return (1); - else if (data3 != data1) - return (1); - data3 = ft_dl_pop_back(NULL); - if (data3) - return (1); - data3 = ft_dl_pop_back(&list); - if (data3) - return (1); - free(data1); - free(data2); - return (0); -} - -int t_dl_push(void) -{ - t_dlist *list; - int *data1; - - data1 = malloc(sizeof(int)); - *data1 = 42; - list = NULL; - ft_dl_push(&list, data1); - if (!list) - return (1); - else if (list->data != data1) - return (1); - ft_dl_clear(&list, free); - return (0); -} - -int t_dl_push_back(void) -{ - t_dlist *list; - int *data1; - int *data2; - int *data3; - - data1 = malloc(sizeof(int)); - *data1 = 42; - list = NULL; - data2 = malloc(sizeof(int)); - *data2 = 21; - data3 = malloc(sizeof(int)); - *data3 = 63; - ft_dl_push_back(&list, data1); - ft_dl_push_back(&list, data2); - ft_dl_push_back(&list, data3); - if (ft_dl_size(list) != 3) - return (1); - else if (list->data != data1 || list->next->data != data2 || \ - list->next->next->data != data3) - return (1); - ft_dl_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_rev.c b/libft/tests/ft_list/dl_tests/tests_dlist_rev.c deleted file mode 100644 index 654a8ad..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_rev.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_rev.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:08:41 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:08:46 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_rev(void) -{ - t_dlist *list; - int *data1; - int *data2; - int *original_data1; - int *original_data2; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - original_data1 = data1; - original_data2 = data2; - ft_dl_rev(&list); - if (ft_dl_size(list) != 2) - return (1); - else if (list->data != original_data2 || list->next->data != original_data1) - return (1); - ft_dl_clear(&list, free); - if (ft_dl_rev(NULL)) - return (1); - list = NULL; - if (ft_dl_rev(&list)) - return (1); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_sizers.c b/libft/tests/ft_list/dl_tests/tests_dlist_sizers.c deleted file mode 100644 index dcfe396..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_sizers.c +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_sizers.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:09:18 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:48:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -int t_dl_size(void) -{ - t_dlist *list; - int *data1; - int *data2; - size_t size_ret[3]; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - size_ret[0] = ft_dl_size(NULL); - size_ret[1] = ft_dl_size(list->next); - size_ret[2] = ft_dl_size(list); - if (size_ret[0] != 0) - return (1); - else if (size_ret[1] != 1) - return (1); - else if (size_ret[2] != 2) - return (1); - ft_dl_clear(&list, free); - return (0); -} - -int t_dl_size_of_data(void) -{ - t_dlist *list; - int *data1; - int *data2; - size_t size_ret[3]; - - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - size_ret[0] = ft_dl_size_of_data(NULL, is42); - size_ret[1] = ft_dl_size_of_data(list->next, is42); - size_ret[2] = ft_dl_size_of_data(list, is42); - if (size_ret[0] != 0) - return (1); - else if (size_ret[1] != 0) - return (2); - else if (size_ret[2] != 1) - return (3); - ft_dl_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/dl_tests/tests_dlist_subrange.c b/libft/tests/ft_list/dl_tests/tests_dlist_subrange.c deleted file mode 100644 index b60ffe0..0000000 --- a/libft/tests/ft_list/dl_tests/tests_dlist_subrange.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_dlist_subrange.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 17:10:08 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 17:10:45 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_dl_subrange(void) -{ - t_dlist *list; - t_dlist *sub; - int *data1; - int *data2; - int *data3; - - data3 = malloc(sizeof(int)); - *data3 = 63; - create_2elem_dlist(&list, (void **)&data1, (void **)&data2); - ft_dl_push_back(&list, data3); - sub = ft_dl_subrange(list, list->next); - if (ft_dl_size(sub) != 1 || sub->data != data1) - return (1); - ft_dl_clear(&sub, NULL); - sub = ft_dl_subrange(list, list->next->next); - if (ft_dl_size(sub) != 2 || sub->data != data1 || \ - sub->next->data != data2 || ft_dl_clear(&sub, NULL), 0) - return (2); - if (ft_dl_subrange(NULL, NULL)) - return (3); - sub = ft_dl_subrange(list, list); - if (ft_dl_size(sub) != 1 || sub->data != data1) - return (4); - return (ft_dl_clear(&sub, NULL), ft_dl_clear(&list, free), 0); -} diff --git a/libft/tests/ft_list/ll_tests/ll_list_tests.c b/libft/tests/ft_list/ll_tests/ll_list_tests.c deleted file mode 100644 index 6a61d96..0000000 --- a/libft/tests/ft_list/ll_tests/ll_list_tests.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ll_list_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/12 13:17:51 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 12:11:12 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/ll_tests.h" - -int tests_linked_list_all(void) -{ - int collect; - const t_test test[] = { - {"add_front", t_ll_add_front}, {"add_back", - t_ll_add_back}, {"apply", t_ll_apply}, { - "apply_range", t_ll_apply_range}, { - "apply_range_node", t_ll_apply_range_node}, { - "clear", t_ll_clear}, {"create", - t_ll_create}, {"copy_node", t_ll_copy_node}, - {"copy_list", t_ll_copy_list}, {"delone", - t_ll_delone}, {"delete_range", t_ll_delete_range}, - {"find", t_ll_find}, {"get_datas", - t_ll_get_datas}, {"get_nodes", t_ll_get_nodes}, { - "end", t_ll_end}, {"at", t_ll_at}, { - "map", t_ll_map}, {"new", t_ll_new}, { - "push", t_ll_push}, {"push_back", - t_ll_push_back}, {"pop", t_ll_pop}, { - "pop_back", t_ll_pop_back}, {"rev", t_ll_rev}, - {"size", t_ll_size}, {"size_match", - t_ll_size_match}, {"subrange", t_ll_subrange}, - {NULL, NULL} - }; - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_list/ll_tests/ll_tests_utils.c b/libft/tests/ft_list/ll_tests/ll_tests_utils.c deleted file mode 100644 index 1c16a95..0000000 --- a/libft/tests/ft_list/ll_tests/ll_tests_utils.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ll_test_utils.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 11:08:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 14:27:13 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -void create_2elem_list(t_list **list, void **data1, void **data2) -{ - *data1 = malloc(sizeof(int)); - *data2 = malloc(sizeof(int)); - *(int *)*data1 = 42; - *(int *)*data2 = 21; - *list = NULL; - ft_ll_push(list, *data1); - ft_ll_push_back(list, *data2); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_add.c b/libft/tests/ft_list/ll_tests/tests_list_add.c deleted file mode 100644 index a138041..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_add.c +++ /dev/null @@ -1,65 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_add.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:15:52 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:46:39 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -/* - list = NULL; - ft_ll_add_front(&list, ft_ll_create(data2)); // (21)-> NULL - ft_ll_add_front(&list, ft_ll_create(data)); // (42)-> (21)-> NULL - --- - ft_ll_add_front(NULL, list); // null resiliency - ft_ll_clear(&list, free); -*/ - -int t_ll_add_front(void) -{ - t_list *list; - int *data; - int *data2; - - data = malloc(sizeof(int)); - *data = 42; - data2 = malloc(sizeof(int)); - *data2 = 21; - list = NULL; - ft_ll_add_front(&list, ft_ll_create(data2)); - ft_ll_add_front(&list, ft_ll_create(data)); - if (!list || list->data != data || !list->next - || list->next->data != data2 || list->next->next) - return (1); - ft_ll_add_front(NULL, list); - ft_ll_clear(&list, free); - return (0); -} - -int t_ll_add_back(void) -{ - t_list *list; - int *data; - int *data2; - - data = malloc(sizeof(int)); - *data = 42; - data2 = malloc(sizeof(int)); - *data2 = 21; - list = ft_ll_create(data); - ft_ll_add_back(&list, ft_ll_create(data2)); - if (!list || list->data != data || !list->next) - return (1); - else if (list->next->data != data2 || list->next->next) - return (1); - ft_ll_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_apply.c b/libft/tests/ft_list/ll_tests/tests_list_apply.c deleted file mode 100644 index 523d295..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_apply.c +++ /dev/null @@ -1,92 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_apply.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:18:39 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:47:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/ll_tests.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -static void lnode_add42(t_list *node) -{ - *(int *)node->data += 42; -} - -int t_ll_apply(void) -{ - const int data3 = 63; - const int data4 = 84; - t_list *list; - int *data; - int *data2; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - ft_ll_apply(list, add42); - if (!list || !list->next || list->next->next - || *(int *)list->data != data4 || *(int *)list->next->data != data3) - return (1); - ft_ll_apply(list, NULL); - if (!list || !list->next || list->next->next - || *(int *)list->data != data4 || *(int *)list->next->data != data3) - return (1); - ft_ll_clear(&list, free); - return (0); -} - -int t_ll_apply_range(void) -{ - t_list *list; - int *data; - int *data2; - const int data3 = 84; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - ft_ll_apply_range(list, list->next, add42); - if (*(int *)list->data != data3) - return (1); - else if (ft_ll_size(list) != 2) - return (1); - else if (*(int *)list->next->data != 21) - return (1); - ft_ll_apply_range(list, list->next, NULL); - if (ft_ll_size(list) != 2) - return (1); - else if (*(int *)list->data != data3) - return (1); - else if (*(int *)list->next->data != 21) - return (1); - ft_ll_apply_range(NULL, NULL, add42); - ft_ll_clear(&list, free); - return (0); -} - -int t_ll_apply_range_node(void) -{ - const int data3 = 84; - t_list *list; - int *data; - int *data2; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - ft_ll_apply_range_node(list, list->next, lnode_add42); - if (*(int *)list->data != data3 || !list->next - || *(int *)list->next->data != 21 || list->next->next) - return (1); - ft_ll_apply_range_node(list, list->next, NULL); - if (*(int *)list->data != data3 || !list->next - || *(int *)list->next->data != 21 || list->next->next) - return (1); - ft_ll_apply_range_node(NULL, NULL, lnode_add42); - ft_ll_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_clear.c b/libft/tests/ft_list/ll_tests/tests_list_clear.c deleted file mode 100644 index 53613e0..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_clear.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listclear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:21:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:22:49 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "tests/ll_tests.h" -#include - -int t_ll_clear(void) -{ - t_list *list; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_ll_create(data); - ft_ll_clear(&list, NULL); - list = ft_ll_create(data); - ft_ll_clear(&list, free); - ft_ll_clear(NULL, NULL); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_copy.c b/libft/tests/ft_list/ll_tests/tests_list_copy.c deleted file mode 100644 index c9a1396..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_copy.c +++ /dev/null @@ -1,62 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listcopy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:24:02 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:25:18 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "tests/lists_test_utils.h" -#include "tests/ll_tests.h" -#include - -int t_ll_copy_node(void) -{ - t_list *list; - t_list *copy; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_ll_create(data); - copy = ft_ll_copy_node(list); - if (!copy) - return (1); - else if (copy->data != list->data) - return (1); - else if (copy->next != list->next) - return (1); - free(data); - free(list); - free(copy); - return (0); -} - -int t_ll_copy_list(void) -{ - t_list *list; - t_list *copy; - int *data; - int *data2; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - copy = ft_ll_copy_list(list); - if (!copy) - return (1); - else if (copy->data != list->data) - return (1); - else if (!copy->next) - return (1); - else if (copy->next->data != list->next->data) - return (1); - else if (copy->next->next) - return (1); - ft_ll_clear(&list, free); - ft_ll_clear(©, NULL); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_create.c b/libft/tests/ft_list/ll_tests/tests_list_create.c deleted file mode 100644 index 97c1fb7..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_create.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listcreate.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:23:08 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:23:34 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "tests/ll_tests.h" -#include - -int t_ll_create(void) -{ - t_list *list; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_ll_create(data); - if (!list) - return (1); - else if (list->data != data) - return (1); - else if (list->next) - return (1); - free(data); - free(list); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_deletors.c b/libft/tests/ft_list/ll_tests/tests_list_deletors.c deleted file mode 100644 index 9f34ee2..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_deletors.c +++ /dev/null @@ -1,81 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listdeletors.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:25:58 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:26:50 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -// ft_ll_delone(NULL, NULL); // null resiliency - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_ll_delone(void) -{ - t_list *list; - int *data; - - data = malloc(sizeof(int)); - *data = 42; - list = ft_ll_create(data); - ft_ll_delone(list, NULL); - list = ft_ll_create(data); - ft_ll_delone(list, free); - ft_ll_delone(NULL, NULL); - return (0); -} - -/* - ft_ll_add_back(&list, ft_ll_create(data2)); // (42)-> (21)-> NULL - list2 = list->next; - nb_deleted = ft_ll_delete_range(list, list->next, NULL); - // (42)-> (21)-> NULL - nb_deleted2 = ft_ll_delete_range(list, list->next, free); - // (21)-> NULL - // we use list2 to check if the list is still valid - // list was destroyed by ft_ll_delete_range - --- - ft_ll_clear(&list2, free); // NULL - --- - nb_deleted = ft_ll_delete_range(NULL, NULL, free); // null resiliency - --- - list = ft_ll_create(data); // (42)-> NULL - nb_deleted = ft_ll_delete_range(list, NULL, free); // NULL - --- - -*/ - -int t_ll_delete_range(void) -{ - t_list *list; - t_list *list2; - int *data; - int *data2; - int nb_del[2]; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - list2 = list->next; - nb_del[0] = ft_ll_delete_range(list, list->next, NULL); - nb_del[1] = ft_ll_delete_range(list, list->next, free); - if ((nb_del[0] != 0 || nb_del[1] != 1) || \ - (list2->data != data2 || list2->next)) - return (__LINE__); - ft_ll_clear(&list2, free); - nb_del[0] = ft_ll_delete_range(NULL, NULL, free); - if (nb_del[0] != 0) - return (__LINE__); - data = malloc(sizeof(int)); - *data = 42; - list = ft_ll_create(data); - nb_del[0] = ft_ll_delete_range(list, NULL, free); - if (nb_del[0] != 1) - return (__LINE__); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_find.c b/libft/tests/ft_list/ll_tests/tests_list_find.c deleted file mode 100644 index 2c66690..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_find.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_find.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:27:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:47:52 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -int t_ll_find(void) -{ - t_list *list; - int *data; - int *data2; - int *data3; - void *found; - - data3 = malloc(sizeof(int)); - create_2elem_list(&list, (void **)&data, (void **)&data2); - found = ft_ll_find(list, data2, NULL); - if (!found || *(int *)found != *data2) - return (1); - *data3 = 63; - found = ft_ll_find(list, data3, cmp_int); - if (found) - return (2); - found = ft_ll_find(NULL, data2, NULL); - if (found) - return (3); - *data3 = 42; - found = ft_ll_find(list, data3, cmp_int); - if (!found || *(int *)found != *data) - return (4); - ft_ll_clear(&list, free); - free(data3); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_get.c b/libft/tests/ft_list/ll_tests/tests_list_get.c deleted file mode 100644 index b62a2f5..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_get.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listget.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:32:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:33:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_ll_get_datas(void) -{ - t_list *list; - int *data; - int *data2; - void **datas; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - datas = ft_ll_get_datas(list); - if (!datas || datas[2] || datas[0] != data || \ - datas[1] != data2) - return (1); - if (ft_ll_get_datas(NULL)) - return (1); - ft_ll_clear(&list, free); - free(datas); - return (0); -} - -int t_ll_get_nodes(void) -{ - t_list *list; - int *data; - int *data2; - t_list **nodes; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - nodes = ft_ll_get_nodes(list); - if (!nodes || nodes[2] || nodes[0] != list || \ - nodes[1] != list->next) - return (1); - if (ft_ll_get_nodes(NULL)) - return (1); - ft_ll_clear(&list, free); - free(nodes); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_iterators.c b/libft/tests/ft_list/ll_tests/tests_list_iterators.c deleted file mode 100644 index a8c228e..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_iterators.c +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_listend.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:33:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:34:43 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_ll_end(void) -{ - t_list *list; - int *data; - int *data2; - t_list *last; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - last = ft_ll_end(list); - if (!last) - return (1); - else if (last->data != data2) - return (1); - else if (last->next) - return (1); - last = ft_ll_end(NULL); - if (last) - return (1); - ft_ll_clear(&list, free); - return (0); -} - -int t_ll_at(void) -{ - t_list *list; - int *data; - int *data2; - t_list *at; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - at = ft_ll_at(list, 1); - if (!at || at->data != data2 || at->next) - return (1); - at = ft_ll_at(list, 456); - if (at) - return (1); - at = ft_ll_at(NULL, 0); - if (at) - return (1); - ft_ll_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_map.c b/libft/tests/ft_list/ll_tests/tests_list_map.c deleted file mode 100644 index 14a1c6c..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_map.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:36:51 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:44:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -int t_ll_map(void) -{ - t_list *list; - int *data; - int *data2; - t_list *map; - t_list *map_err[3]; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - map = ft_ll_map(list, add42_ret, free); - map_err[0] = ft_ll_map(list, NULL, free); - map_err[1] = ft_ll_map(NULL, add42_ret, free); - map_err[2] = ft_ll_map(list, add42_ret, NULL); - if (!map || *(int *)map->data != 84 || !map->next) - return (1); - else if (*(int *)map->next->data != 63) - return (1); - else if (map->next->next) - return (1); - else if (map_err[0] || map_err[1] || map_err[2]) - return (1); - ft_ll_clear(&list, free); - ft_ll_clear(&map, free); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_new.c b/libft/tests/ft_list/ll_tests/tests_list_new.c deleted file mode 100644 index 10c0a2d..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_new.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:37:19 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:39:43 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include - -int t_ll_new(void) -{ - t_list *list; - - list = ft_ll_new(); - if (!list) - return (1); - free(list); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_push.c b/libft/tests/ft_list/ll_tests/tests_list_push.c deleted file mode 100644 index 0bedc77..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_push.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_push.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:37:47 by bgoulard #+# #+# */ -/* Updated: 2024/11/11 21:18:36 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_ll_push(void) -{ - t_list *list; - t_list *list_rep1; - t_list *list_rep2; - const int data[][1] = { - {42}, - {21} - }; - - list = NULL; - list_rep1 = ft_ll_push(&list, &data[0]); - list_rep2 = ft_ll_push(&list, &data[1]); - if (!list || !list_rep1 || !list_rep2) - return (1); - else if (list != list_rep2) - return (1); - else if (list->next != list_rep1) - return (1); - else if (ft_ll_size(list) != 2) - return (1); - else if (list->data != &data[1] || list->next->data != &data[0]) - return (1); - ft_ll_clear(&list, NULL); - ft_ll_push(NULL, NULL); - return (0); -} - -int t_ll_push_back(void) -{ - t_list *list; - int *data; - int *data2; - - data = malloc(sizeof(int)); - *data = 42; - data2 = malloc(sizeof(int)); - *data2 = 21; - list = NULL; - ft_ll_push_back(&list, data); - ft_ll_push_back(&list, data2); - if (ft_ll_size(list) != 2) - return (1); - else if (list->data != data) - return (1); - else if (list->next->data != data2) - return (1); - ft_ll_clear(&list, free); - ft_ll_push_back(NULL, NULL); - return (0); -} - -int t_ll_pop(void) -{ - t_list *list; - int *data; - int *data2; - void *pop; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - pop = ft_ll_pop(&list); - if (!list || ft_ll_size(list) != 1) - return (1); - else if (list->data != data2) - return (1); - else if (pop != data) - return (1); - ft_ll_clear(&list, free); - free(pop); - if (ft_ll_pop(&list) || ft_ll_pop(NULL)) - return (1); - return (0); -} - -/* -create_2elem_list(&list, (void **)&data, (void **)&data2); // (42)-> (21)-> NULL -data3 = malloc(sizeof(int)); -*data3 = 63; -ft_ll_push(&list, data3); // (63)-> (42)-> (21)-> NULL -pop = ft_ll_pop_back(&list); // 21 : (63)-> (42)-> NULL -if (ft_ll_size(list) != 2) - return (1); -else if (list->data != data3) - return (1); -else if (list->next->data != data) - return (1); -else if (pop != data2) - return (1); -pop = ft_ll_pop_back(&list); // 42 : (63)-> NULL - -*/ -int t_ll_pop_back(void) -{ - t_list *list; - int *data; - int *data2; - int *data3; - void *pop; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - data3 = malloc(sizeof(int)); - *data3 = 63; - ft_ll_push(&list, data3); - pop = ft_ll_pop_back(&list); - if (ft_ll_size(list) != 2) - return (1); - else if (list->data != data3 || list->next->data != data || pop != data2) - return (1); - pop = ft_ll_pop_back(&list); - if (ft_ll_size(list) != 1 || list->data != data3 || pop != data) - return (1); - pop = ft_ll_pop_back(&list); - if (list || pop != data3 || ft_ll_size(list) != 0 || \ - ft_ll_pop_back(&list)) - return (1); - return (free(data), free(data2), free(data3), 0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_rev.c b/libft/tests/ft_list/ll_tests/tests_list_rev.c deleted file mode 100644 index 7f30c5f..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_rev.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_rev.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:40:24 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:41:32 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -int t_ll_rev(void) -{ - t_list *list; - t_list *rev; - int *data; - int *data2; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - rev = ft_ll_rev(&list); - if (ft_ll_size(list) != 2) - return (1); - else if (rev->data != data2) - return (1); - else if (rev->next->data != data) - return (1); - ft_ll_clear(&rev, free); - rev = NULL; - rev = ft_ll_rev(NULL); - if (rev || ft_ll_rev(&rev)) - return (1); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_sizers.c b/libft/tests/ft_list/ll_tests/tests_list_sizers.c deleted file mode 100644 index 2df3fdf..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_sizers.c +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_sizers.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:43:28 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:46:41 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include "tests/tests_lambda_functions.h" -#include - -int t_ll_size(void) -{ - t_list *list; - int *data; - int *data2; - size_t size_ret[3]; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - size_ret[0] = ft_ll_size(NULL); - size_ret[1] = ft_ll_size(list->next); - size_ret[2] = ft_ll_size(list); - if (size_ret[0] != 0) - return (1); - if (size_ret[1] != 1) - return (1); - if (size_ret[2] != 2) - return (1); - ft_ll_clear(&list, free); - return (0); -} - -int t_ll_size_match(void) -{ - t_list *list; - int *data; - int *data2; - size_t size_ret[3]; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - size_ret[0] = ft_ll_size_match(NULL, is42); - size_ret[1] = ft_ll_size_match(list, is42); - size_ret[2] = ft_ll_size_match(list->next, is42); - if (size_ret[0] != 0) - return (1); - if (size_ret[1] != 1) - return (1); - if (size_ret[2] != 0) - return (1); - ft_ll_clear(&list, free); - return (0); -} diff --git a/libft/tests/ft_list/ll_tests/tests_list_subrange.c b/libft/tests/ft_list/ll_tests/tests_list_subrange.c deleted file mode 100644 index 25e5e46..0000000 --- a/libft/tests/ft_list/ll_tests/tests_list_subrange.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_list_subrange.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 16:44:51 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 16:46:04 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_list.h" -#include "ft_list_types.h" -#include "tests/lists_test_utils.h" -#include - -/* - ft_ll_push(&list, data); // (42)-> NULL - ft_ll_push(&list, data2); // (21)-> (42)-> NULL - sub = ft_ll_subrange(list, list->next); // (21)-> NULL - sub = ft_ll_subrange(list, NULL); // (21)-> (42)-> NULL - sub = ft_ll_subrange(list, (const t_list *)data2); // (21)-> (42)-> NULL -*/ - -int t_ll_subrange(void) -{ - t_list *list; - int *data; - int *data2; - t_list *sub; - - create_2elem_list(&list, (void **)&data, (void **)&data2); - ft_ll_rev(&list); - sub = ft_ll_subrange(list, list->next); - if (ft_ll_size(sub) != 1 || sub->data != data2) - return (1); - ft_ll_clear(&sub, NULL); - sub = ft_ll_subrange(list, NULL); - if (ft_ll_size(sub) != 2 || sub->data != data2 || sub->next->data != data) - return (2); - ft_ll_clear(&sub, NULL); - sub = ft_ll_subrange(list, (const t_list *)data2); - if (ft_ll_size(sub) != 2 || sub->data != data2 || sub->next->data != data) - return (3); - ft_ll_clear(&sub, NULL); - if (ft_ll_subrange(NULL, NULL)) - return (4); - sub = ft_ll_subrange(list, list); - if (ft_ll_size(sub) != 1 || sub->data != data2) - return (5); - return (ft_ll_clear(&sub, NULL), ft_ll_clear(&list, free), 0); -} diff --git a/libft/tests/ft_map/map_tests.c b/libft/tests/ft_map/map_tests.c deleted file mode 100644 index 28bd79a..0000000 --- a/libft/tests/ft_map/map_tests.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* map_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/11 18:27:46 by bgoulard #+# #+# */ -/* Updated: 2024/06/07 14:59:37 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/map_tests.h" - -// see with --leak-check=full -int tests_map(void) -{ - int collect; - const t_test test[] = { - {"create", test_map_create}, - {"destroy", test_map_destroy}, // here - {"destroy_free", test_map_destroy_free}, - {"clear", test_map_clear}, // here - {"set", test_map_set}, - {"set_cmp", test_map_set_cmp}, - {"set_hash", test_map_set_hash}, - {"get", test_map_get}, - {"size", test_map_size}, - {"capacity", test_map_capacity}, - {"remove", test_map_remove}, // here - {"hash", test_map_hash}, - {NULL, NULL} - }; - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_map/tests_map_cappacity.c b/libft/tests/ft_map/tests_map_cappacity.c deleted file mode 100644 index 6bd46dd..0000000 --- a/libft/tests/ft_map/tests_map_cappacity.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_cappacity.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:16:49 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:03:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" - -int test_map_capacity(void) -{ - t_map *map; - size_t ret; - - map = ft_map_create(10); - ret = ft_map_capacity(map); - if (ret != 10) - return (1); - ft_map_destroy(map); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_clear.c b/libft/tests/ft_map/tests_map_clear.c deleted file mode 100644 index 525b47e..0000000 --- a/libft/tests/ft_map/tests_map_clear.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_clear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:11:13 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:41:04 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" -#include "ft_string.h" - -// clear the map and check if the value is still present -// try to double clear the map - -int test_map_clear(void) -{ - t_map *map; - - map = ft_map_create(10); - ft_map_set(map, "key", "value", ft_strlen("key")); - ft_map_clear(map); - if (ft_map_get(map, "key", ft_strlen("key"))) - return (1); - ft_map_clear(map); - ft_map_destroy(map); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_create.c b/libft/tests/ft_map/tests_map_create.c deleted file mode 100644 index 51bcc73..0000000 --- a/libft/tests/ft_map/tests_map_create.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_create.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:07:38 by bgoulard #+# #+# */ -/* Updated: 2024/05/19 18:07:42 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" - -int test_map_create(void) -{ - t_map *map; - - map = ft_map_create(10); - if (!map) - return (1); - ft_map_destroy(map); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_destroy.c b/libft/tests/ft_map/tests_map_destroy.c deleted file mode 100644 index 4449d4b..0000000 --- a/libft/tests/ft_map/tests_map_destroy.c +++ /dev/null @@ -1,48 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:08:04 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:07:40 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_string.h" -#include "ft_map_types.h" -#include - -// check valgrind for no memory leak -int test_map_destroy(void) -{ - t_map *map; - - map = ft_map_create(10); - ft_map_destroy(map); - return (0); -} - -// accessing to key[0] and value[0] after the call to check -// that no free occured on the data at first call -int test_map_destroy_free(void) -{ - t_map *map; - char *key; - char *value; - - key = ft_strdup("keys"); - value = ft_strdup("values"); - map = ft_map_create(10); - ft_map_set(map, key, value, ft_strlen(key)); - ft_map_destroy_free(map, NULL); - key[0] = 'k'; - value[0] = 'v'; - map = ft_map_create(15); - ft_map_set(map, key, value, ft_strlen(key)); - ft_map_destroy_free(map, free); - free(key); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_get.c b/libft/tests/ft_map/tests_map_get.c deleted file mode 100644 index 383c9de..0000000 --- a/libft/tests/ft_map/tests_map_get.c +++ /dev/null @@ -1,84 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_get.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:14:47 by bgoulard #+# #+# */ -/* Updated: 2024/06/23 18:28:31 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -/* - // search for a non existing key - ret = ft_map_get(map, "key2", strlen("key2") + 1); - --- - // search for a non existing key in a full map - map = ft_map_create(1); -*/ - -#include "ft_map.h" -#include "ft_map_types.h" -#include "ft_string.h" -#include - -int test_map_get_ultra_small(void) -{ - char *str[2]; - t_map *map; - void *ret; - - str[0] = ft_strdup("value"); - str[1] = ft_strdup("value2"); - map = ft_map_create(1); - ft_map_set(map, "key", str[0], ft_strlen("key")); - ft_map_set(map, "key2", str[1], ft_strlen("key")); - ret = ft_map_get(map, "key", ft_strlen("key")); - if (!ret) - return (1); - else if (ft_strcmp((char *)ret, "value")) - return (2); - ret = ft_map_get(map, "key2", ft_strlen("key2")); - if (!ret) - return (3); - else if (ft_strcmp((char *)ret, "value2")) - return (4); - ft_map_destroy_free(map, free); - return (0); -} - -int test_map_normal(void) -{ - char *str; - t_map *map; - void *ret; - - str = ft_strdup("value"); - map = ft_map_create(10); - ft_map_set(map, "key", str, ft_strlen("key")); - ret = ft_map_get(map, "key", ft_strlen("key")); - if (!ret) - return (1); - else if (ft_strcmp((char *)ret, "value")) - return (2); - ret = ft_map_get(map, "key2", ft_strlen("key2")); - if (ret) - return (3); - ft_map_destroy(map); - free(str); - return (0); -} - -int test_map_get(void) -{ - int ret; - - ret = test_map_get_ultra_small(); - if (ret != 0) - return (ret + 10 * 0); - ret = test_map_normal(); - if (ret != 0) - return (ret + 10 * 1); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_hash.c b/libft/tests/ft_map/tests_map_hash.c deleted file mode 100644 index 5f881d3..0000000 --- a/libft/tests/ft_map/tests_map_hash.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_hash.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:21:33 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:24:06 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_defs.h" -#include "ft_map.h" -#include "ft_string.h" - -// we dont really test the hash function, we just test that -// it doesn't overflow our map - -int test_map_hash(void) -{ - size_t ret; - size_t ret2; - - ret = ft_hash_djb2("key", ft_strlen("key")); - ret2 = ft_hash_djb2("key2", ft_strlen("key2")); - if (ret == ret2) - return (1); - ret = ft_hash_sdbm("key", ft_strlen("key")); - ret2 = ft_hash_sdbm("key2", ft_strlen("key2")); - if (ret == ret2) - return (1); - ret = ft_hash_fnv1a("key", ft_strlen("key")); - ret2 = ft_hash_fnv1a("key2", ft_strlen("key2")); - if (ret == ret2) - return (1); - ret = ft_hash_dummy("key", ft_strlen("key")); - ret2 = ft_hash_dummy("key2", ft_strlen("key2")); - if (ret == ret2) - return (1); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_remove.c b/libft/tests/ft_map/tests_map_remove.c deleted file mode 100644 index 93f682b..0000000 --- a/libft/tests/ft_map/tests_map_remove.c +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_remove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:18:53 by bgoulard #+# #+# */ -/* Updated: 2024/06/23 18:31:50 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_string.h" -#include "ft_map_types.h" -#include "ft_string.h" -#include - -static int test_map_remove_normal(void) -{ - char *str; - void *ret; - t_map *map; - - str = ft_strdup("value"); - map = ft_map_create(10); - ft_map_set(map, "key", str, ft_strlen("key")); - ret = ft_map_remove(map, "key", ft_strlen("key")); - if (!ret) - return (1); - else if (ret != str) - return (2); - ret = ft_map_remove(map, "key2", ft_strlen("key2")); - if (ret) - return (3); - ft_map_destroy(map); - free(str); - return (0); -} - -static int test_map_remove_colision(void) -{ - const char *keys[] = {"key", "key2", "key3", "key4", NULL}; - const char *str[] = { - ft_strdup("value"), ft_strdup("value2"), ft_strdup("value3"), - ft_strdup("value4"), NULL}; - t_map *map; - int ret; - - map = ft_map_create(1); - ret = 0; - while (str[ret]) - { - ft_map_set(map, keys[ret], str[ret], ft_strlen(keys[ret])); - ret++; - } - ret = 0; - if (ft_map_remove(map, keys[2], ft_strlen(keys[2])) != str[2]) - return (1); - if (ft_map_remove(map, keys[1], ft_strlen(keys[1])) != str[1]) - return (2); - if (ft_map_remove(map, keys[0], ft_strlen(keys[0])) != str[0]) - return (3); - if (ft_map_remove(map, keys[3], ft_strlen(keys[3])) != str[3]) - return (4); - return (ft_map_destroy(map), ft_apply_2d((void **)str, free), 0); -} - -int test_map_remove(void) -{ - int ret; - - ret = test_map_remove_normal(); - if (ret != 0) - return (ret); - ret = test_map_remove_colision(); - if (ret != 0) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_set.c b/libft/tests/ft_map/tests_map_set.c deleted file mode 100644 index 344cb13..0000000 --- a/libft/tests/ft_map/tests_map_set.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_set.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:12:34 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:39:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" -#include "ft_string.h" - -int test_map_set(void) -{ - char *str; - char *str2; - t_map *map; - - str = ft_strdup("value"); - str2 = ft_strdup("value2"); - map = ft_map_create(1); - if (ft_map_set(map, "key", str, ft_strlen("key")) != true) - return (1); - if (ft_map_set(map, "key", str2, ft_strlen("key")) != true) - return (1); - ft_map_destroy(map); - free(str); - free(str2); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_set_cmphash.c b/libft/tests/ft_map/tests_map_set_cmphash.c deleted file mode 100644 index 5e4ed38..0000000 --- a/libft/tests/ft_map/tests_map_set_cmphash.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_set_cmphash.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:13:15 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:14:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" - -int test_map_set_cmp(void) -{ - t_map *map; - - map = ft_map_create(10); - ft_map_set_cmp(map, NULL); - if (map->cmp) - return (1); - ft_map_destroy(map); - return (0); -} - -int test_map_set_hash(void) -{ - t_map *map; - - map = ft_map_create(10); - ft_map_set_hash(map, NULL); - if (map->hash) - return (1); - ft_map_destroy(map); - return (0); -} diff --git a/libft/tests/ft_map/tests_map_size.c b/libft/tests/ft_map/tests_map_size.c deleted file mode 100644 index cd3a65a..0000000 --- a/libft/tests/ft_map/tests_map_size.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_map_size.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/19 18:15:34 by bgoulard #+# #+# */ -/* Updated: 2024/06/25 22:17:17 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_map.h" -#include "ft_map_types.h" -#include "ft_string.h" -#include - -int test_map_size(void) -{ - char *str; - t_map *map; - size_t ret; - - str = ft_strdup("value"); - map = ft_map_create(10); - ft_map_set(map, "key", str, ft_strlen("key")); - ret = ft_map_size(map); - if (ret != 1) - return (1); - ft_map_destroy(map); - free(str); - return (0); -} diff --git a/libft/tests/ft_math/math_tests.c b/libft/tests/ft_math/math_tests.c deleted file mode 100644 index 0d7e5e1..0000000 --- a/libft/tests/ft_math/math_tests.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* math_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:16:35 by bgoulard #+# #+# */ -/* Updated: 2024/06/26 20:50:59 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/math_tests.h" - -int tests_math(void) -{ - int i; - const t_test tests[] = { - {"abs", test_ft_abs}, {"clamp", test_ft_clamp}, - {"complex_abs", test_ft_complex_abs}, - {"complex_addl", test_ft_complex_addl}, - {"complex_mull", test_ft_complex_mull}, - {"complex_muld", test_ft_complex_muld}, - {"range", test_ft_range}, {"range_f", test_ft_range_f}, - {"range_d", test_ft_range_d}, {"log", test_ft_log}, - {"llogof", test_ft_llogof}, {"ullogof", test_ft_ullogof}, - {"logof", test_ft_logof}, {"min", test_ft_min}, - {"max", test_ft_max}, {"pow", test_ft_pow}, {"round", test_ft_round}, - {"sqrt", test_ft_sqrt}, {"clamp_f", test_ft_clamp_f}, - {"clamp_d", test_ft_clamp_d}, {"align", test_ft_align}, - {"align_2", test_ft_align_2}, {NULL, NULL}}; - - i = 0; - run_test(tests, &i); - return (i); -} diff --git a/libft/tests/ft_math/tests_abs.c b/libft/tests/ft_math/tests_abs.c deleted file mode 100644 index 04277e7..0000000 --- a/libft/tests/ft_math/tests_abs.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_ft_abs.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:20:34 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 23:21:18 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_abs(void) -{ - int x; - - x = -42; - if (ft_abs(x) != 42) - return (1); - x = 42; - if (ft_abs(x) != 42) - return (1); - x = 0; - if (ft_abs(x) != 0) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_align.c b/libft/tests/ft_math/tests_align.c deleted file mode 100644 index 88182f4..0000000 --- a/libft/tests/ft_math/tests_align.c +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_align.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/06/26 19:53:26 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:05:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_align_2(void) -{ - size_t size; - size_t result; - - size = 42; - result = ft_align_2(size, 4); - if (result != 44) - return (1); - result = ft_align_2(size, 8); - if (result != 48) - return (2); - result = ft_align_2(size, 16); - if (result != 48) - return (3); - size = 275; - result = ft_align_2(size, 4); - if (result != 276) - return (4); - return (0); -} - -int test_ft_align(void) -{ - size_t size; - size_t result; - - size = 42; - result = ft_align(size, 4); - if (result != 44) - return (1); - result = ft_align(size, 8); - if (result != 48) - return (2); - result = ft_align(size, 16); - if (result != 48) - return (3); - size = 275; - result = ft_align(size, 6); - if (result != 276) - return (4); - return (0); -} diff --git a/libft/tests/ft_math/tests_clamp.c b/libft/tests/ft_math/tests_clamp.c deleted file mode 100644 index 08861b7..0000000 --- a/libft/tests/ft_math/tests_clamp.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_clamp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:46:19 by bgoulard #+# #+# */ -/* Updated: 2024/05/28 09:12:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_clamp(void) -{ - const int max = 42; - const int min = 21; - int x; - - x = 0; - if (ft_clamp(x, min, max) != min) - return (1); - x = 21; - if (ft_clamp(x, min, max) != min) - return (1); - x = 42; - if (ft_clamp(x, min, max) != max) - return (1); - x = 84; - if (ft_clamp(x, min, max) != max) - return (1); - x = 23; - if (ft_clamp(x, min, max) != x) - return (1); - return (0); -} - -int test_ft_clamp_f(void) -{ - const float max = 42.0; - const float min = 21.0; - float x; - - x = 0; - if (ft_clamp_f(x, min, max) != min) - return (1); - x = 21; - if (ft_clamp_f(x, min, max) != min) - return (1); - x = 42; - if (ft_clamp_f(x, min, max) != max) - return (1); - x = 84; - if (ft_clamp_f(x, min, max) != max) - return (1); - x = 23; - if (ft_clamp_f(x, min, max) != x) - return (1); - return (0); -} - -int test_ft_clamp_d(void) -{ - const double max = 42.0; - const double min = 21.0; - double x; - - x = 0; - if (ft_clamp_d(x, min, max) != min) - return (1); - x = 21; - if (ft_clamp_d(x, min, max) != min) - return (1); - x = 42; - if (ft_clamp_d(x, min, max) != max) - return (1); - x = 84; - if (ft_clamp_d(x, min, max) != max) - return (1); - x = 23; - if (ft_clamp_d(x, min, max) != x) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_complex.c b/libft/tests/ft_math/tests_complex.c deleted file mode 100644 index dd3cf28..0000000 --- a/libft/tests/ft_math/tests_complex.c +++ /dev/null @@ -1,78 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_complex.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:46:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 09:08:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" -#include "ft_math_types.h" - -int test_ft_complex_abs(void) -{ - const t_complex x = {42, 0}; - const t_complex y = {0, 42}; - const t_complex z = {42, 42}; - double res; - - res = ft_complex_abs(x); - if (res < 41.99 || res > 42.01) - return (1); - res = ft_complex_abs(y); - if (res < 41.99 || res > 42.01) - return (2); - res = ft_complex_abs(z); - if (res < 59.39 || res > 59.41) - return (3); - return (0); -} - -int test_ft_complex_addl(void) -{ - const t_complex x = {42, 0}; - const t_complex y = {0, 42}; - t_complex res; - - res = ft_complex_addl(x, 42); - if (res.real != 84 || res.imaginary != 42) - return (1); - res = ft_complex_addl(y, 42); - if (res.real != 42 || res.imaginary != 84) - return (1); - return (0); -} - -int test_ft_complex_mull(void) -{ - const t_complex x = {42, 0}; - const t_complex y = {0, 42}; - t_complex res; - - res = ft_complex_mull(x, 2); - if (res.real != 84 || res.imaginary != 0) - return (1); - res = ft_complex_mull(y, 2); - if (res.real != 0 || res.imaginary != 84) - return (1); - return (0); -} - -int test_ft_complex_muld(void) -{ - const t_complex x = {42, 0}; - const t_complex y = {0, 42}; - t_complex res; - - res = ft_complex_muld(x, 2.5); - if (res.real != 105 || res.imaginary != 0) - return (1); - res = ft_complex_muld(y, 2.5); - if (res.real != 0 || res.imaginary != 105) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_intrange.c b/libft/tests/ft_math/tests_intrange.c deleted file mode 100644 index febd3e7..0000000 --- a/libft/tests/ft_math/tests_intrange.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_intrange.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:41:40 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 17:09:13 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_range_errors(void) -{ - const int min = 9; - const int max = 42; - const int new_max = 21; - int x; - - x = -1; - if (ft_range(x, min, max, new_max) != 0) - return (1); - x = min; - if (ft_range(x, min + max, max, new_max) != 0) - return (2); - x = max + 1; - if (ft_range(x, min, max, 0) != 0) - return (3); - return (0); -} - -int test_ft_range(void) -{ - const int min = 9; - const int max = 42; - const int new_max = 21; - int x; - - x = -1; - if (ft_range(x, min, max, new_max) != 0) - return (1); - x = min; - if (ft_range(x, min, max, new_max) != 0) - return (2); - x = max + 1; - if (ft_range(x, max, max, new_max) != 0) - return (3); - if (ft_range(x, min, max, new_max) != new_max) - return (4); - x = 42; - if (ft_range(x, min, max, new_max) != new_max) - return (5); - x = 21; - if (ft_range(x, min, max, new_max) != (int)(((double)(x - min) / \ - (max - min)) * new_max)) - return (6); - return (test_ft_range_errors()); -} - -int test_ft_range_f(void) -{ - const float min = 9.0f; - const float max = 42.0f; - const float new_max = 21.0f; - float x; - - x = -1; - if (ft_range_f(x, min, max, new_max) != 0) - return (1); - x = min; - if (ft_range_f(x, min, max, new_max) != 0) - return (2); - x = max + 1; - if (ft_range_f(x, max, max, new_max) != 0) - return (3); - if (ft_range_f(x, min, max, new_max) != new_max) - return (4); - x = 42; - if (ft_range_f(x, min, max, new_max) != new_max) - return (5); - x = 21; - if (ft_range_f(x, min, max, new_max) != \ - (float)(((double)(x - min) / (max - min)) * new_max)) - return (6); - return (0); -} - -int test_ft_range_d_errors(void) -{ - const double min = 9.0; - const double max = 42.0; - const double new_max = 21.0; - double x; - - x = -1; - if (ft_range_d(x, min, max, new_max) != 0) - return (1); - x = min; - if (ft_range_d(x, min + max, max, new_max) != 0) - return (2); - x = max + 1; - if (ft_range_d(x, min, max, 0) != 0) - return (3); - return (0); -} - -int test_ft_range_d(void) -{ - const double min = 9.0; - const double max = 42.0; - const double new_max = 21.0; - double x; - - x = -1; - if (ft_range_d(x, min, max, new_max) != 0) - return (1); - x = min; - if (ft_range_d(x, min, max, new_max) != 0) - return (2); - x = max + 1; - if (ft_range_d(x, max, max, new_max) != 0) - return (3); - if (ft_range_d(x, min, max, new_max) != new_max) - return (4); - x = 42; - if (ft_range_d(x, min, max, new_max) != new_max) - return (5); - x = 21; - if (ft_range_d(x, min, max, new_max) != ((x - min) / (max - min)) * new_max) - return (6); - return (test_ft_range_d_errors()); -} diff --git a/libft/tests/ft_math/tests_log.c b/libft/tests/ft_math/tests_log.c deleted file mode 100644 index 0b344b7..0000000 --- a/libft/tests/ft_math/tests_log.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_log.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:42:03 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 09:27:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_log(void) -{ - int x; - - x = 23; - if (ft_log(x) != 1) - return (1); - x = 0; - if (ft_log(x) != -1) - return (2); - x = 1; - if (ft_log(x) != 0) - return (3); - x = 420; - if (ft_log(x) != 2) - return (4); - x = -12; - if (ft_log(x) != -1) - return (5); - return (0); -} - -int test_ft_llogof(void) -{ - if (ft_llogof(0, 2) != -1) - return (1); - if (ft_llogof(1, 2) != 0) - return (2); - if (ft_llogof(2, 2) != 1) - return (3); - if (ft_llogof(8, 2) != 3) - return (4); - if (ft_llogof(23, 3) != 2) - return (5); - return (0); -} - -int test_ft_ullogof(void) -{ - if (ft_ullogof(0, 2) != -1) - return (1); - if (ft_ullogof(1, 2) != 0) - return (2); - if (ft_ullogof(2, 2) != 1) - return (3); - return (0); -} - -int test_ft_logof(void) -{ - if (ft_logof(0, 2) != -1) - return (1); - if (ft_logof(1, 2) != 0) - return (2); - if (ft_logof(2, 2) != 1) - return (3); - if (ft_logof(8, 2) != 3) - return (4); - return (0); -} diff --git a/libft/tests/ft_math/tests_minmax.c b/libft/tests/ft_math/tests_minmax.c deleted file mode 100644 index 6a24213..0000000 --- a/libft/tests/ft_math/tests_minmax.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_minmax.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:49:30 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 00:54:36 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_min(void) -{ - const int a = 1; - const int b = 2; - const int c = 3; - - if (ft_min(a, b) != a) - return (1); - if (ft_min(b, c) != b) - return (1); - return (0); -} - -int test_ft_max(void) -{ - const int a = 1; - const int b = 2; - const int c = 3; - - if (ft_max(a, b) != b) - return (1); - if (ft_max(c, b) != c) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_pow.c b/libft/tests/ft_math/tests_pow.c deleted file mode 100644 index 6d90959..0000000 --- a/libft/tests/ft_math/tests_pow.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pow.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:21:25 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 01:01:12 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_pow(void) -{ - size_t x; - size_t y; - - x = 2; - y = 3; - if (ft_pow(x, y) != 8) - return (1); - y = 0; - if (ft_pow(x, y) != 1) - return (1); - y = 1; - if (ft_pow(x, y) != 2) - return (1); - if (ft_pow(0, y) != 0) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_round.c b/libft/tests/ft_math/tests_round.c deleted file mode 100644 index 60a5e8f..0000000 --- a/libft/tests/ft_math/tests_round.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_ft_round.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:24:56 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 23:25:46 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_round(void) -{ - double x; - - x = 42.42; - if (ft_round(x) != 42) - return (1); - x = 42.52; - if (ft_round(x) != 43) - return (1); - x = 42.499; - if (ft_round(x) != 42) - return (1); - x = 42.5; - if (ft_round(x) != 43) - return (1); - return (0); -} diff --git a/libft/tests/ft_math/tests_sqrt.c b/libft/tests/ft_math/tests_sqrt.c deleted file mode 100644 index 2f99a35..0000000 --- a/libft/tests/ft_math/tests_sqrt.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_sqrt.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 23:49:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 09:34:56 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_math.h" - -int test_ft_sqrt(void) -{ - double x; - double result; - - x = 4; - result = ft_sqrt(x); - if (result > 2.01 || result < 1.99) - return (1); - x = 2; - result = ft_sqrt(x); - if (result > 1.42 || result < 1.41) - return (2); - x = -1; - result = ft_sqrt(x); - if (result >= -0.99 || result <= -1.01) - return (3); - return (0); -} diff --git a/libft/tests/ft_optional/optional_tests.c b/libft/tests/ft_optional/optional_tests.c deleted file mode 100644 index 4f31dbf..0000000 --- a/libft/tests/ft_optional/optional_tests.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* optional_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/06 00:57:26 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 12:08:25 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/optional_test.h" -#include "tests/tests.h" - -void *add_4(void *val) -{ - long long ptr; - - ptr = (long long)val; - ptr += 4; - return ((void *)ptr); -} - -int tests_optional(void) -{ - int collect; - const t_test test[] = { - {"copy", test_optional_copy}, - {"new", test_optional_new}, - {"from_val", test_optional_from_val}, - {"dup", test_optional_dup}, - {"chain", test_optional_chain}, - {"map", test_optional_map}, - {"unwrap", test_optional_unwrap}, - {"destroy", test_optional_destroy}, - {NULL, NULL} - }; - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_optional/tests_optional_chain.c b/libft/tests/ft_optional/tests_optional_chain.c deleted file mode 100644 index aa3b539..0000000 --- a/libft/tests/ft_optional/tests_optional_chain.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optional_chain.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:28:51 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:58:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" -#include "tests/optional_test.h" -#include "ft_defs.h" - -int test_optional_chain(void) -{ - t_optional opt; - bool ret; - const t_data_tr_i function_list[3] = { - add_4, - add_4, - NULL - }; - - opt.pres = OPT_SOME; - opt.val = (void *)42; - ret = ft_optional_chain(&opt, function_list); - if (ret != true || opt.pres != OPT_SOME || opt.val != (void *)42 + 8) - return (1); - opt.pres = OPT_NONE; - ret = ft_optional_chain(&opt, function_list); - if (ret != false || opt.pres != OPT_NONE) - return (1); - ret = ft_optional_chain(&opt, NULL); - if (ret != false || opt.pres != OPT_NONE) - return (1); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_copy.c b/libft/tests/ft_optional/tests_optional_copy.c deleted file mode 100644 index 14cc5ec..0000000 --- a/libft/tests/ft_optional/tests_optional_copy.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optional_copy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:29:49 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 12:08:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" -#include - -int test_optional_copy(void) -{ - int *ptr; - t_optional opt_a; - t_optional opt_b; - - ptr = malloc(sizeof(int)); - *ptr = 42; - opt_a.pres = OPT_SOME; - opt_a.val = ptr; - ft_optional_copy(&opt_b, &opt_a); - if (opt_b.pres != OPT_SOME) - return (1); - if (*(int *)opt_b.val != 42) - return (2); - free(ptr); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_destroy.c b/libft/tests/ft_optional/tests_optional_destroy.c deleted file mode 100644 index 3ddd972..0000000 --- a/libft/tests/ft_optional/tests_optional_destroy.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_optional_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:30:05 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 22:32:48 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" - -int test_optional_destroy(void) -{ - t_optional *opt_a; - - opt_a = ft_optional_new(); - opt_a->val = (void *)42; - opt_a->pres = OPT_SOME; - if (ft_optional_destroy(opt_a) != false) - return (1); - if (opt_a->pres != OPT_SOME) - return (2); - if (opt_a->val != (void *)42) - return (3); - opt_a->pres = OPT_NONE; - if (ft_optional_destroy(opt_a) != true) - return (4); - if (ft_optional_destroy(NULL) != false) - return (5); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_dup.c b/libft/tests/ft_optional/tests_optional_dup.c deleted file mode 100644 index 8722b80..0000000 --- a/libft/tests/ft_optional/tests_optional_dup.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_optional_dup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:30:28 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 22:32:45 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" - -int test_optional_dup(void) -{ - t_optional opt_a; - t_optional *opt_b; - - opt_a.pres = OPT_SOME; - opt_a.val = (void *)42; - opt_b = ft_optional_dup(&opt_a); - if (!opt_b) - return (1); - if (opt_b->pres != OPT_SOME) - return (2); - if (opt_b->val != (void *)42) - return (3); - opt_b->pres = OPT_NONE; - ft_optional_destroy(opt_b); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_from_val.c b/libft/tests/ft_optional/tests_optional_from_val.c deleted file mode 100644 index 6257618..0000000 --- a/libft/tests/ft_optional/tests_optional_from_val.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_optional_from_val.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:30:45 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 22:32:41 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" -#include - -int test_optional_from_val(void) -{ - int *ptr; - t_optional *opt; - - ptr = malloc(sizeof(int)); - *ptr = 42; - opt = ft_optional_from_val(ptr); - if (!opt) - return (1); - if (opt->pres != OPT_SOME) - return (2); - if (opt->val != ptr) - return (3); - opt->pres = OPT_NONE; - ft_optional_destroy(opt); - free(ptr); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_map.c b/libft/tests/ft_optional/tests_optional_map.c deleted file mode 100644 index 4bb8590..0000000 --- a/libft/tests/ft_optional/tests_optional_map.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optional_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:31:24 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:59:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" -#include "tests/optional_test.h" - -int test_optional_map(void) -{ - t_optional opt; - t_optional ret; - void *(*function_list[3])(void *); - - function_list[0] = &add_4; - function_list[1] = &add_4; - function_list[2] = NULL; - opt.pres = OPT_SOME; - opt.val = (void *)42; - ret = ft_optional_map(&opt, function_list); - if (ret.pres != OPT_SOME) - return (1); - if (ret.val != (void *)42 + 8) - return (2); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_new.c b/libft/tests/ft_optional/tests_optional_new.c deleted file mode 100644 index 36a7a26..0000000 --- a/libft/tests/ft_optional/tests_optional_new.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optional_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:31:28 by bgoulard #+# #+# */ -/* Updated: 2024/07/17 22:39:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" - -int test_optional_new(void) -{ - t_optional *opt; - - opt = ft_optional_new(); - if (!opt) - return (1); - if (opt->pres != OPT_NONE) - return (2); - if (opt->val) - return (3); - ft_optional_destroy(opt); - return (0); -} diff --git a/libft/tests/ft_optional/tests_optional_unwrap.c b/libft/tests/ft_optional/tests_optional_unwrap.c deleted file mode 100644 index 9d8e768..0000000 --- a/libft/tests/ft_optional/tests_optional_unwrap.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_optional_unwrap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 22:32:05 by bgoulard #+# #+# */ -/* Updated: 2024/06/25 22:30:19 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_optional.h" -#include "ft_optional_types.h" -#include -#include -#include -#include - -int test_optional_unwrap(void) -{ - t_optional opt; - int *ptr; - - opt.pres = OPT_SOME; - ptr = malloc(sizeof(int)); - *ptr = 42; - opt.val = ptr; - if (ft_optional_unwrap(opt) != ptr) - return (1); - free(ptr); - opt.pres = OPT_NONE; - opt.val = (void *)0xDEADBEEF; - if (ft_optional_unwrap(opt) != NULL) - return (2); - return (0); -} diff --git a/libft/tests/ft_pair/pair_tests.c b/libft/tests/ft_pair/pair_tests.c deleted file mode 100644 index c895311..0000000 --- a/libft/tests/ft_pair/pair_tests.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* pair_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 15:53:09 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:15:20 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/pair_tests.h" -#include "tests/tests.h" - -int tests_pair(void) -{ - int collect; - const t_test test[] = { - {"test_pair_set", test_pair_set}, - {"test_pair_new", test_pair_new}, - {"test_pair_second", test_pair_second}, - {"test_pair_first", test_pair_first}, - {"test_pair_cmp", test_pair_cmp}, - {"test_pair_cmp_first", test_pair_cmp_first}, - {"test_pair_cmp_second", test_pair_cmp_second}, - {"tests_pair_destroy", tests_pair_destroy}, - {NULL, NULL} - }; - - collect = 0; - run_test(test, &collect); - return (collect); -} diff --git a/libft/tests/ft_pair/tests_pair_cmp.c b/libft/tests/ft_pair/tests_pair_cmp.c deleted file mode 100644 index 25b1b0d..0000000 --- a/libft/tests/ft_pair/tests_pair_cmp.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_cmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:20:58 by bgoulard #+# #+# */ -/* Updated: 2024/08/21 21:43:29 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "tests/pair_tests.h" -#include "tests/tests_lambda_functions.h" - -static int test_ptr(void) -{ - t_pair pair_a; - t_pair pair_b; - void *a; - void *b; - void *c; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADDEAD; - c = (void *)0xDEADCAFE; - ft_pair_set(&pair_a, a, b); - ft_pair_set(&pair_b, c, a); - if (ft_pair_cmp(&pair_a, &pair_b, NULL) == 0) - return (1); - if (ft_pair_cmp(&pair_a, &pair_a, NULL) != 0) - return (2); - if (ft_pair_cmp(&pair_b, &pair_a, NULL) == 0) - return (3); - if (ft_pair_cmp(NULL, &pair_a, NULL) == 0 || ft_pair_cmp(&pair_a, NULL, - NULL) == 0) - return (4); - if (ft_pair_cmp(NULL, NULL, NULL) != 0) - return (5); - return (0); -} - -static int test_cmp(void) -{ - t_pair pair_a; - t_pair pair_b; - long a; - long b; - long c; - - a = 21; - b = 42; - c = 420; - ft_pair_set(&pair_a, (void *)a, (void *)b); - ft_pair_set(&pair_b, (void *)c, (void *)a); - if (ft_pair_cmp(&pair_a, &pair_b, &cmp_int) == 0) - return (1); - return (0); -} - -int test_pair_cmp(void) -{ - int ret; - - ret = test_ptr(); - if (ret != 0) - return (ret); - ret = test_cmp(); - if (ret != 0) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_cmp_first.c b/libft/tests/ft_pair/tests_pair_cmp_first.c deleted file mode 100644 index 8f42714..0000000 --- a/libft/tests/ft_pair/tests_pair_cmp_first.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_cmp_first.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:20:45 by bgoulard #+# #+# */ -/* Updated: 2024/08/21 21:48:51 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_defs.h" -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "ft_string.h" -#include "tests/pair_tests.h" - -static int test_ptr(void) -{ - t_pair pair; - t_pair pair_b; - void *a; - void *b; - void *c; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADCAFE; - c = (void *)0xDEADDEAD; - ft_pair_set(&pair, b, b); - pair_b.first = c; - if (ft_pair_cmp_first(&pair, &pair_b, NULL) >= 0) - return (1); - pair_b.first = b; - if (ft_pair_cmp_first(&pair, &pair_b, NULL) != 0) - return (2); - pair_b.first = a; - if (ft_pair_cmp_first(&pair, &pair_b, NULL) <= 0) - return (3); - if (ft_pair_cmp_first(&pair, NULL, NULL) == 0 || ft_pair_cmp_first(NULL, - &pair, NULL) == 0) - return (4); - if (ft_pair_cmp_first(NULL, NULL, NULL) != 0) - return (5); - return (0); -} - -static int test_cmp(void) -{ - t_pair pair_a; - t_pair pair_b; - const char *a = "a"; - const char *b = "b"; - const char *c = "c"; - - ft_pair_set(&pair_a, (void *)a, (void *)b); - ft_pair_set(&pair_b, (void *)c, (void *)a); - if (ft_pair_cmp_first(&pair_a, &pair_b, (t_data_cmp) & ft_strcmp) == 0) - return (1); - return (0); -} - -int test_pair_cmp_first(void) -{ - int ret; - - ret = test_ptr(); - if (ret != 0) - return (ret); - ret = test_cmp(); - if (ret != 0) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_cmp_second.c b/libft/tests/ft_pair/tests_pair_cmp_second.c deleted file mode 100644 index 81d70ed..0000000 --- a/libft/tests/ft_pair/tests_pair_cmp_second.c +++ /dev/null @@ -1,73 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_cmp_second.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:19:11 by bgoulard #+# #+# */ -/* Updated: 2024/08/21 21:48:39 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "ft_string.h" -#include "tests/pair_tests.h" - -static int test_ptr(void) -{ - t_pair pair; - t_pair pair_b; - void *a; - void *b; - void *c; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADCAFE; - c = (void *)0xDEADDEAD; - pair_b.second = c; - ft_pair_set(&pair, b, b); - if (ft_pair_cmp_second(&pair, &pair_b, NULL) >= 0) - return (1); - pair_b.second = b; - if (ft_pair_cmp_second(&pair, &pair_b, NULL) != 0) - return (2); - pair_b.second = a; - if (ft_pair_cmp_second(&pair, &pair_b, NULL) <= 0) - return (3); - if (ft_pair_cmp_second(&pair, NULL, NULL) == 0 || ft_pair_cmp_second(NULL, - &pair, NULL) == 0) - return (4); - if (ft_pair_cmp_second(NULL, NULL, NULL) != 0) - return (5); - return (0); -} - -static int test_cmp(void) -{ - t_pair pair_a; - t_pair pair_b; - const char *a = "a"; - const char *b = "b"; - const char *c = "c"; - - ft_pair_set(&pair_a, (void *)a, (void *)b); - ft_pair_set(&pair_b, (void *)c, (void *)a); - if (ft_pair_cmp_second(&pair_a, &pair_b, (t_data_cmp) & ft_strcmp) == 0) - return (1); - return (0); -} - -int test_pair_cmp_second(void) -{ - int ret; - - ret = test_ptr(); - if (ret != 0) - return (ret); - ret = test_cmp(); - if (ret != 0) - return (ret); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_destroy.c b/libft/tests/ft_pair/tests_pair_destroy.c deleted file mode 100644 index 4536f24..0000000 --- a/libft/tests/ft_pair/tests_pair_destroy.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 17:09:25 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:16:28 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/pair_tests.h" -#include "ft_pair_types.h" -#include "ft_pair.h" - -int tests_pair_destroy(void) -{ - t_pair *pair; - - pair = ft_pair_new("key", "value"); - ft_pair_destroy(&pair, NULL, NULL); - if (pair != NULL) - return (1); - pair = ft_pair_new(ft_strdup("key"), ft_strdup("value")); - ft_pair_destroy(&pair, &free, &free); - if (pair != NULL) - return (2); - ft_pair_destroy(NULL, NULL, NULL); - pair = NULL; - ft_pair_destroy(&pair, NULL, NULL); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_get_first.c b/libft/tests/ft_pair/tests_pair_get_first.c deleted file mode 100644 index 4a73c2a..0000000 --- a/libft/tests/ft_pair/tests_pair_get_first.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_get_first.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:17:14 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:04:32 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "tests/pair_tests.h" - -int test_pair_first(void) -{ - t_pair pair; - void *a; - void *b; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADDEAD; - ft_pair_set(&pair, a, b); - if (ft_pair_first(&pair) != a) - return (1); - if (ft_pair_first(NULL) != NULL) - return (2); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_get_second.c b/libft/tests/ft_pair/tests_pair_get_second.c deleted file mode 100644 index 46d2bec..0000000 --- a/libft/tests/ft_pair/tests_pair_get_second.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_get_second.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:15:50 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:04:40 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "tests/pair_tests.h" - -int test_pair_second(void) -{ - t_pair pair; - void *a; - void *b; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADDEAD; - ft_pair_set(&pair, a, b); - if (ft_pair_second(&pair) != b) - return (1); - if (ft_pair_second(NULL) != NULL) - return (2); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_new.c b/libft/tests/ft_pair/tests_pair_new.c deleted file mode 100644 index 0b78dd2..0000000 --- a/libft/tests/ft_pair/tests_pair_new.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:14:03 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:25:03 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "tests/pair_tests.h" - -int test_pair_new(void) -{ - t_pair *pair; - void *a; - void *b; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADDEAD; - pair = ft_pair_new(NULL, NULL); - if (!pair) - return (1); - if (pair->first || pair->second) - return (2); - ft_pair_set(pair, a, b); - if (pair->first != a || pair->second != b) - return (3); - ft_pair_destroy(&pair, NULL, NULL); - return (0); -} diff --git a/libft/tests/ft_pair/tests_pair_set.c b/libft/tests/ft_pair/tests_pair_set.c deleted file mode 100644 index 2d8bcc8..0000000 --- a/libft/tests/ft_pair/tests_pair_set.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_pair_set.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/06 16:09:32 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 16:46:25 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_pair.h" -#include "ft_pair_types.h" -#include "tests/pair_tests.h" - -int test_pair_set(void) -{ - t_pair pair; - void *a; - void *b; - void *c; - - a = (void *)0xDEADBEEF; - b = (void *)0xDEADDEAD; - c = (void *)0xDEADCAFE; - ft_pair_set(&pair, a, b); - if (pair.first != a || pair.second != b) - return (1); - ft_pair_set(&pair, c, a); - if (pair.first != c || pair.second != a) - return (1); - ft_pair_set(NULL, a, b); - return (0); -} diff --git a/libft/tests/ft_string/ft_char/ft_char_tests.c b/libft/tests/ft_string/ft_char/ft_char_tests.c deleted file mode 100644 index d2e66b9..0000000 --- a/libft/tests/ft_string/ft_char/ft_char_tests.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_char_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 14:31:03 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:37:50 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/char_tests.h" -#include "tests/tests.h" - -int char_tests(void) -{ - int i; - const t_test tests[] = { - {"isalnum", test_ft_isalnum}, {"isalpha", test_ft_isalpha}, - {"isascii", test_ft_isascii}, {"isdigit", test_ft_isdigit}, - {"isprint", test_ft_isprint}, {"tolower", test_ft_tolower}, - {"toupper", test_ft_toupper}, {"isalnum", test_ft_isalnum}, - {"putchar", test_ft_putchar}, {"ishexdigit", test_ft_ishexdigit}, - {"isoctdigit", test_ft_isoctdigit}, {"isspace", test_ft_isspace}, - {NULL, NULL}}; - - i = 0; - run_test(tests, &i); - return (i); -} diff --git a/libft/tests/ft_string/ft_char/tests_isalnum.c b/libft/tests/ft_string/ft_char/tests_isalnum.c deleted file mode 100644 index c7e28a2..0000000 --- a/libft/tests/ft_string/ft_char/tests_isalnum.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:55:54 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:11:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -int test_ft_isalnum(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isalnum(i) != ((i >= '0' && i <= '9') || (i >= 'a' && i <= 'z') - || (i >= 'A' && i <= 'Z'))) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isalpha.c b/libft/tests/ft_string/ft_char/tests_isalpha.c deleted file mode 100644 index 6b98ade..0000000 --- a/libft/tests/ft_string/ft_char/tests_isalpha.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:56:07 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 15:56:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -int test_ft_isalpha(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isalpha(i) != ((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z'))) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isascii.c b/libft/tests/ft_string/ft_char/tests_isascii.c deleted file mode 100644 index 77aa91a..0000000 --- a/libft/tests/ft_string/ft_char/tests_isascii.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isascii.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:56:46 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:30:15 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -int test_ft_isascii(void) -{ - int i; - - i = -1; - while (i < 256) - { - if (ft_isascii(i) != (i >= 0 && i <= 127)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isdigit.c b/libft/tests/ft_string/ft_char/tests_isdigit.c deleted file mode 100644 index e42bdd3..0000000 --- a/libft/tests/ft_string/ft_char/tests_isdigit.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:57:05 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 15:57:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -int test_ft_isdigit(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isdigit(i) != (i >= '0' && i <= '9')) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_ishexdigit.c b/libft/tests/ft_string/ft_char/tests_ishexdigit.c deleted file mode 100644 index 7c7d309..0000000 --- a/libft/tests/ft_string/ft_char/tests_ishexdigit.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_ishexdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 16:25:47 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:26:01 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -static int local_ishexdigit(int c) -{ - if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') - || (c >= 'A' && c <= 'F')) - return (1); - return (0); -} - -int test_ft_ishexdigit(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_ishexdigit(i) != local_ishexdigit(i)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isoctdigit.c b/libft/tests/ft_string/ft_char/tests_isoctdigit.c deleted file mode 100644 index 011466b..0000000 --- a/libft/tests/ft_string/ft_char/tests_isoctdigit.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isoctdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 16:26:13 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:26:23 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -static int local_isoctdigit(int c) -{ - if (c >= '0' && c <= '7') - return (1); - return (0); -} - -int test_ft_isoctdigit(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isoctdigit(i) != local_isoctdigit(i)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isprint.c b/libft/tests/ft_string/ft_char/tests_isprint.c deleted file mode 100644 index 417a336..0000000 --- a/libft/tests/ft_string/ft_char/tests_isprint.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_isprint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:57:59 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 15:58:04 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -int test_ft_isprint(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isprint(i) != (i >= 32 && i <= 126)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_isspace.c b/libft/tests/ft_string/ft_char/tests_isspace.c deleted file mode 100644 index 6edce03..0000000 --- a/libft/tests/ft_string/ft_char/tests_isspace.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_char_isspace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 16:32:37 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 21:25:51 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -static int local_isspace(int c) -{ - if (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' - || c == '\v') - return (1); - return (0); -} - -int test_ft_isspace(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_isspace(i) != local_isspace(i)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_puchar.c b/libft/tests/ft_string/ft_char/tests_puchar.c deleted file mode 100644 index d666b26..0000000 --- a/libft/tests/ft_string/ft_char/tests_puchar.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_puchar.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 16:01:41 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:18:25 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" -#include "tests/tests.h" -#include -#include -#include - -int test_ft_putchar(void) -{ - const char *file; - char buf[256]; - char c; - int fd; - int ret; - - file = "ft_putchar"; - c = 0; - fd = open_test_file((char **)&file); - if (fd < 0) - return (1); - while ((unsigned char)c < 255) - ft_putchar_fd(c++, fd); - close(fd); - fd = open(file, O_RDONLY); - if (fd < 0) - return (2); - ret = read(fd, buf, 256); - if (ret != 255) - return (3); - buf[255] = 0; - while (ret--) - if (buf[ret] != --c) - return (4); - return (destroy_test_file(fd, (char *)file), free((char *)file), 0); -} diff --git a/libft/tests/ft_string/ft_char/tests_tolower.c b/libft/tests/ft_string/ft_char/tests_tolower.c deleted file mode 100644 index 6387c64..0000000 --- a/libft/tests/ft_string/ft_char/tests_tolower.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_tolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 15:59:59 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:00:44 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -static int local_tolower(int c) -{ - if (c >= 'A' && c <= 'Z') - return (c + 32); - return (c); -} - -int test_ft_tolower(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_tolower(i) != local_tolower(i)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_char/tests_toupper.c b/libft/tests/ft_string/ft_char/tests_toupper.c deleted file mode 100644 index 0cae61c..0000000 --- a/libft/tests/ft_string/ft_char/tests_toupper.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_toupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/23 16:01:14 by bgoulard #+# #+# */ -/* Updated: 2024/05/23 16:18:41 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_char.h" - -static int local_toupper(int c) -{ - if (c >= 'a' && c <= 'z') - return (c - 32); - return (c); -} - -int test_ft_toupper(void) -{ - int i; - - i = 0; - while (i < 256) - { - if (ft_toupper(i) != local_toupper(i)) - return (1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/mem_tests.c b/libft/tests/ft_string/ft_mem/mem_tests.c deleted file mode 100644 index 48cf83b..0000000 --- a/libft/tests/ft_string/ft_mem/mem_tests.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* mem_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/30 13:39:27 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 20:54:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/str__mem_tests.h" - -int mem_tests(void) -{ - int collect; - const t_test tests[] = { - {"apply_2d", test_apply_2d}, {"free_2d", test_free_2d}, - {"len_2d", test_len_2d}, {"fd_to_buff", test_fd_to_buff}, - {"bzero", test_bzero}, {"calloc", test_calloc}, {"realloc", test_realloc}, - {"free", test_free}, {"memchr", test_memchr}, {"memcmp", test_memcmp}, - {"memcpy", test_memcpy}, {"memmap", test_memmap}, {"memmove", test_memmove}, - {"memset", test_memset}, {"swap", test_swap}, {"qsort", test_qsort}, - {NULL, NULL} - }; - - collect = 0; - run_test(tests, &collect); - return (collect); -} diff --git a/libft/tests/ft_string/ft_mem/tests_apply_2d.c b/libft/tests/ft_string/ft_mem/tests_apply_2d.c deleted file mode 100644 index fe96bf3..0000000 --- a/libft/tests/ft_string/ft_mem/tests_apply_2d.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_apply_2d.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/28 16:05:28 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:59:40 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -static void to_a(void *ptr) -{ - char *sptr; - - sptr = (char *)ptr; - while (*sptr) - { - *sptr = 'a'; - sptr++; - } -} - -int test_apply_2d(void) -{ - char *arr2d[4]; - size_t i; - - i = 0; - while (i < 3) - arr2d[i++] = ft_strdup("Hello World"); - arr2d[i] = NULL; - ft_apply_2d((void **)arr2d, to_a); - if (ft_strcmp(arr2d[0], "aaaaaaaaaaa") != 0 || ft_strcmp(arr2d[1], - "aaaaaaaaaaa") != 0 || ft_strcmp(arr2d[2], "aaaaaaaaaaa") != 0) - return (1); - return (ft_apply_2d((void **)arr2d, free), 0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_bzero.c b/libft/tests/ft_string/ft_mem/tests_bzero.c deleted file mode 100644 index 071a752..0000000 --- a/libft/tests/ft_string/ft_mem/tests_bzero.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_bzero.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:24:17 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 14:37:09 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_bzero(void) -{ - char str[10]; - const char str2[10] = {0}; - - ft_strlcpy(str, "123456789", 10); - ft_bzero(str, 10); - if (ft_memcmp(str, str2, 10) != 0) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_calloc.c b/libft/tests/ft_string/ft_mem/tests_calloc.c deleted file mode 100644 index fcc10e9..0000000 --- a/libft/tests/ft_string/ft_mem/tests_calloc.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_calloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:23:35 by bgoulard #+# #+# */ -/* Updated: 2024/06/25 21:40:19 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -// str[x] = 'a' is to test that we can write in the memory we asked for -int test_calloc(void) -{ - char *str; - - str = ft_calloc(10, sizeof(char)); - str[9] = 'a'; - free(str); - str = ft_calloc(10, sizeof(char *)); - str[9 * sizeof(char *)] = 'a'; - free(str); - str = ft_calloc(0, sizeof(char)); - free(str); - str = ft_calloc(SIZE_MAX, SIZE_MAX); - if (str) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_fd_to_buff.c b/libft/tests/ft_string/ft_mem/tests_fd_to_buff.c deleted file mode 100644 index 0001b0b..0000000 --- a/libft/tests/ft_string/ft_mem/tests_fd_to_buff.c +++ /dev/null @@ -1,71 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_fd_to_buff.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/28 16:15:20 by bgoulard #+# #+# */ -/* Updated: 2024/06/26 19:34:37 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -static int base_case(void) -{ - char buff[100]; - char *ret; - int fd; - - ft_bzero(buff, 100); - ft_strlcat(buff, "Hello World\n\n\n\n\tv\vjkldqskjfsldfjsmldfkj\n", 100); - fd = open(TESTS_FPREFIX "test_fd_to_buff.txt", O_RDWR | O_CREAT, 0644); - if (fd < 0) - return (1); - write(fd, buff, ft_strlen(buff)); - close(fd); - fd = open(TESTS_FPREFIX "test_fd_to_buff.txt", O_RDONLY | O_CREAT); - if (fd < 0) - return (2); - ret = ft_fd_to_buff(fd); - if (ft_strcmp(ret, buff) != 0) - return (3); - destroy_test_file(fd, TESTS_FPREFIX "test_fd_to_buff.txt"); - return (free(ret), 0); -} - -static int error_case(void) -{ - char *ret; - int bad_fd; - - bad_fd = -1; - ret = ft_fd_to_buff(bad_fd); - if (ret) - return (1); - bad_fd = open(TESTS_FPREFIX "test_fd_to_buff.txt", O_CREAT, 0004); - if (bad_fd < 0) - return (2); - close(bad_fd); - bad_fd = open(TESTS_FPREFIX "test_fd_to_buff.txt", O_RDONLY); - ret = ft_fd_to_buff(bad_fd); - if (ret) - return (3); - destroy_test_file(bad_fd, TESTS_FPREFIX "test_fd_to_buff.txt"); - return (0); -} - -int test_fd_to_buff(void) -{ - int ret; - - ret = base_case(); - if (ret != 0) - return (ret); - ret = error_case(); - if (ret != 0) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_free.c b/libft/tests/ft_string/ft_mem/tests_free.c deleted file mode 100644 index 3d4d167..0000000 --- a/libft/tests/ft_string/ft_mem/tests_free.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_free.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:22:59 by bgoulard #+# #+# */ -/* Updated: 2024/08/21 21:49:05 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_free(void) -{ - char *str; - - str = ft_calloc(10, sizeof(char)); - ft_free((void **)&str); - if (str) - return (1); - ft_free((void **)&str); - ft_free((void **) NULL); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_free_2d.c b/libft/tests/ft_string/ft_mem/tests_free_2d.c deleted file mode 100644 index 1dd62ed..0000000 --- a/libft/tests/ft_string/ft_mem/tests_free_2d.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_free_2d.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/28 23:42:53 by bgoulard #+# #+# */ -/* Updated: 2024/05/28 23:55:41 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -// we assume that free_2d is working, -// checking if memory is freed properly is not possible in this context -int test_free_2d(void) -{ - char **tab; - - tab = ft_split("Hello World", ' '); - ft_free_2d((void **)tab); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_len_2d.c b/libft/tests/ft_string/ft_mem/tests_len_2d.c deleted file mode 100644 index 0ca24e2..0000000 --- a/libft/tests/ft_string/ft_mem/tests_len_2d.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_len_2d.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 00:11:07 by bgoulard #+# #+# */ -/* Updated: 2024/05/29 00:15:46 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_len_2d(void) -{ - char *arr2d[4]; - - arr2d[0] = "Hello"; - arr2d[1] = "World"; - arr2d[2] = "!"; - arr2d[3] = NULL; - if (ft_len_2d((const void *const *)arr2d) != 3) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memchr.c b/libft/tests/ft_string/ft_mem/tests_memchr.c deleted file mode 100644 index 9472931..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memchr.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:22:42 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:18:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_memchr(void) -{ - char str[10]; - - ft_strlcpy(str, "1234567", 10); - ft_strlcat(str, "890", 10); - if (ft_memchr(str, '8', 10) != &str[7]) - return (1); - if (ft_memchr(str, '9', 10) != &str[8]) - return (2); - if (ft_memchr(str, 'z', 10)) - return (3); - if (ft_memchr(str, '7', 10) != &str[6]) - return (4); - if (ft_memchr(str, '7', 0)) - return (5); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memcmp.c b/libft/tests/ft_string/ft_mem/tests_memcmp.c deleted file mode 100644 index 58c646a..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memcmp.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:22:12 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 00:46:20 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_memcmp(void) -{ - const char str[] = "1234567\0009"; - const char str2[] = "1234567\0009"; - const char str3[] = "1234567\000a"; - const char str4[] = "1234567\0009"; - - if (ft_memcmp(str, str2, 10) != 0) - return (1); - if (ft_memcmp(str, str3, 10) >= 0) - return (2); - if (ft_memcmp(str3, str, 10) <= 0) - return (3); - if (ft_memcmp(str, str2, 0) != 0) - return (4); - if (ft_memcmp(str, str4, 10) != 0) - return (5); - if (ft_memcmp(str, str, 999) != 0) - return (6); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memcpy.c b/libft/tests/ft_string/ft_mem/tests_memcpy.c deleted file mode 100644 index 4234723..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memcpy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:22:05 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 00:49:34 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -// last ft_memcpy is a test to check that we do nothing on -// dst if src and dst are the same otherwise it will segfault -int test_memcpy(void) -{ - char str[10]; - const char str3[] = "1234567\0009"; - - ft_strlcpy(str, "123456789", 10); - ft_memcpy(str, "abc", 3); - if (ft_memcmp(str, "abc456789", 10) != 0) - return (1); - ft_memcpy(str, str3, 10); - if (ft_memcmp(str, str3, 10) != 0) - return (2); - ft_memcpy(str, str, 999); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memmap.c b/libft/tests/ft_string/ft_mem/tests_memmap.c deleted file mode 100644 index 9ca90a8..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memmap.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:21:39 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 00:53:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_defs.h" -#include "ft_string.h" - -int test_memmap(void) -{ - const char *tb[3] = {"Hello", "World", "!"}; - char **str2; - - str2 = (char **) ft_memmap((void *)tb, sizeof(tb) / sizeof(tb[0]), - (t_data_tr)ft_strdup); - if (ft_strcmp(str2[0], "Hello") != 0) - return (1); - if (ft_strcmp(str2[1], "World") != 0) - return (1); - if (ft_strcmp(str2[2], "!") != 0) - return (1); - ft_free_2d((void **)str2); - str2 = (char **) ft_memmap(NULL, 0, (t_data_tr)ft_strdup); - if (str2) - return (2); - str2 = (char **) ft_memmap((void *)tb, 0, (t_data_tr)ft_strdup); - if (str2) - return (3); - str2 = (char **) ft_memmap((void *)tb, sizeof(tb) / sizeof(tb[0]), NULL); - if (str2) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memmove.c b/libft/tests/ft_string/ft_mem/tests_memmove.c deleted file mode 100644 index 0628cc3..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memmove.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memmove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:21:39 by bgoulard #+# #+# */ -/* Updated: 2024/06/26 19:27:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -// last ft_memmove is a test to check that we do nothing on -// dst if src and dst are the same otherwise it will segfault -int test_memmove(void) -{ - char str[10]; - const char str3[] = "1234567a9"; - - ft_strlcpy(str, "123456789", 10); - ft_memmove(str, "abc", 3); - if (ft_memcmp(str, "abc456789", 10) != 0) - return (1); - ft_memmove(str, str3, 10); - if (ft_memcmp(str, str3, 10) != 0) - return (2); - ft_memmove(str, str + 2, 5); - if (ft_memcmp(str, "3456767a9", 10) != 0) - return (3); - ft_memmove(str + 2, str, 5); - if (ft_memcmp(str, "3434567a9", 10) != 0) - return (4); - ft_memmove(str, str, 999); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_memset.c b/libft/tests/ft_string/ft_mem/tests_memset.c deleted file mode 100644 index ccd3956..0000000 --- a/libft/tests/ft_string/ft_mem/tests_memset.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_memset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:21:24 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:01:56 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -/* - // ignore warning for memset args - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmemset-transposed-args" -*/ -int test_memset(void) -{ - char str[10]; - char str2[10]; - - ft_strlcpy(str, "123456789", 10); - ft_strlcpy(str2, "123456789", 10); - ft_memset(str, 'a', 10); - if (ft_memcmp(str, "aaaaaaaaaa", 10) != 0) - return (1); - ft_memset(str, 'b', 0); - if (ft_memcmp(str, "aaaaaaaaaa", 10) != 0) - return (2); - ft_memset(str, 'c', 5); - if (ft_memcmp(str, "cccccaaaaa", 10) != 0) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_qsort.c b/libft/tests/ft_string/ft_mem/tests_qsort.c deleted file mode 100644 index 4a855f0..0000000 --- a/libft/tests/ft_string/ft_mem/tests_qsort.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_qsort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:20:05 by bgoulard #+# #+# */ -/* Updated: 2024/05/25 12:20:11 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - - // non stable -// int tab[10] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 9}; -// int tab2[10] = {1, 2, 3, 4, 5, 6, 7, 8, 10, 9}; -// int tab3[10] = {1, 256, 3, 4, -6, 7, 81, 10, 9}; -// int tab4[10] = {1, 256, 3, 4, -6, 7, 81, 10, 9}; - -// ft_qsort(tab, 10, sizeof(int), cmp_int); -// qsort(tab2, 10, sizeof(int), cmp_int); -// if (memcmp(tab, tab2, 10) != 0) -// return (1); - -// ft_qsort(tab3, 10, sizeof(int), cmp_int); -// qsort(tab4, 10, sizeof(int), cmp_int); -// if (memcmp(tab3, tab4, 10) != 0) -// return (2); -int test_qsort(void) -{ - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_realloc.c b/libft/tests/ft_string/ft_mem/tests_realloc.c deleted file mode 100644 index 31945c2..0000000 --- a/libft/tests/ft_string/ft_mem/tests_realloc.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_realloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:21:02 by bgoulard #+# #+# */ -/* Updated: 2024/06/26 19:27:29 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_realloc(void) -{ - char *str; - char *str_ret; - - str = ft_calloc(15, sizeof(char)); - ft_strlcpy(str, "Hello world", 15); - str = ft_realloc(str, 25, 15); - ft_strlcat(str, " this is zod!", 25); - if (ft_strcmp(str, "Hello world this is zod!") != 0) - return (1); - str_ret = ft_realloc(str, 10, 10); - if (str != str_ret) - return (2); - free(str); - return (0); -} diff --git a/libft/tests/ft_string/ft_mem/tests_swap.c b/libft/tests/ft_string/ft_mem/tests_swap.c deleted file mode 100644 index 407739d..0000000 --- a/libft/tests/ft_string/ft_mem/tests_swap.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_swap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 12:20:29 by bgoulard #+# #+# */ -/* Updated: 2024/05/25 15:13:47 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -/* - // ignore warning for memset args - #pragma clang diagnostic pop -*/ - -int test_swap(void) -{ - const int pair_og[2] = {1, 2}; - const int *pair[2]; - const int *pair2[2] = {&pair_og[1], &pair_og[0]}; - - pair[0] = &pair_og[0]; - pair[1] = &pair_og[1]; - ft_swap((void **)&pair[0], (void **)&pair[1]); - if (pair[0] != pair2[0] || pair[1] != pair2[1]) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/str_tests.c b/libft/tests/ft_string/ft_str/str_tests.c deleted file mode 100644 index 2847cb8..0000000 --- a/libft/tests/ft_string/ft_str/str_tests.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* str_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/30 13:39:29 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:23:03 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/str__str_tests.h" -#include "tests/tests.h" -#include - -static const t_test *load_tests01(void) -{ - static t_test tb[] = {{"putstr", test_putstr}, {"putendl", test_putendl}, - {"putnbr", test_putnbr}, {"itoa", test_itoa}, {"utoa", test_utoa}, \ - {"itoa_base", test_itoa_base}, {"atoi", test_atoi}, {"atoi_base", \ - test_atoi_base}, {"tok", test_strtok}, {"split", test_split}, - {"splits", tests_splits}, {"chr", test_strchr}, {"dup", test_strdup}, \ - {"iteri", test_striteri}, {"join", test_strjoin}, {"lcat", test_strlcat}, \ - {"lcpy", test_strlcpy}, {"len", test_strlen}, {"mapi", test_strmapi}, \ - {"cmp", test_strcmp}, {"ncmp", test_strncmp}, {"ndup", test_strndup}, \ - {"nstr", test_strnstr}, {"rchr", test_strrchr}, {"trim", test_strtrim}, \ - {"substr", test_substr}, {"replace", test_str_replace}, \ - {"replace_chr", test_str_replace_chr}, {"shift_args", test_shift_args}, \ - {"gnl", test_gnl}, {"atof", test_atof}, {"isalpha", test_str_isalpha}, \ - {"isbool", test_str_isbool}, {"alnum", test_str_isalnum}, \ - {"isdigit", test_str_isdigit}, {"isdouble", test_str_isdouble}, \ - {"ishex", test_str_ishex}, {"islong", test_str_islong}, \ - {"isnum", test_str_isnum}, {"isoct", test_str_isoct}, \ - {"isint", test_str_isint}, {"isfloat", test_str_isfloat}, \ - {"isvalid", test_str_isvalid}, {"clen", test_strclen}, \ - {"cnb", test_strcnb}, {"cspn", test_strcspn}, \ - {"end_with", test_strend_with}, {"start_with", test_strstart_with}, \ - {"spn", test_strspn}, {"append_c", test_strappend_c}, - {NULL, NULL}}; - - return (tb); -} - -int str_tests(void) -{ - int collect; - const t_test *tests = load_tests01(); - - collect = 0; - run_test(tests, &collect); - return (collect); -} diff --git a/libft/tests/ft_string/ft_str/test_atof.c b/libft/tests/ft_string/ft_str/test_atof.c deleted file mode 100644 index 3c4a362..0000000 --- a/libft/tests/ft_string/ft_str/test_atof.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_atof.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 16:08:52 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 16:00:09 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_atof(void) -{ - double res; - size_t i; - const float marge = 0.00001; - const double t_cases[] = { - 1.13, 3.14, 0.0, 0.1, 0.0001, -0.2, -0.3, 0.3, 1200, 0, - 3.15, -3.15, 0.15 - }; - const char *t_str[] = { - "1.13", "3.14", "0.0", "0.1", "0.0001", - "-0.2", "-.3", ".3", "1200", "0", " +3.15", - " -3.15", " .15" - }; - - i = 0; - while (i < sizeof(t_cases) / sizeof(t_cases[0])) - { - res = ft_atof(t_str[i]); - if (res < t_cases[i] - marge || res > t_cases[i] + marge) - return (i + 1); - i++; - } - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_atoi.c b/libft/tests/ft_string/ft_str/test_atoi.c deleted file mode 100644 index bb3f0be..0000000 --- a/libft/tests/ft_string/ft_str/test_atoi.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 11:45:29 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_atoi(void) -{ - size_t i; - const int t_cases[] = { - 0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, -1, -9, - -10, -99, -100, -999, -1000, -9999, -10000 - }; - const char *t_str[] = { - "0", "1", "9", "10", "99", "100", "999", "1000", - "9999", "10000", "-1", "-9", "-10", "-99", "-100", "-999", "-1000", - "-9999", "-10000" - }; - - i = 0; - while (i < sizeof(t_cases) / sizeof(t_cases[0])) - { - if (ft_atoi(t_str[i]) != t_cases[i]) - return (i + 1); - i++; - } - if (ft_atoi(" --99") != 99 || ft_atoi(" -0") != 0 || \ - ft_atoi(" -++--1") != -1) - return (30); - if (ft_atoi("toto") != 0 || ft_atoi("-toto") != 0 || ft_atoi("toto-") \ - != 0 || ft_atoi("a") != 0 || ft_atoi("01234\t56789") != 1234) - return (31); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_atoi_base.c b/libft/tests/ft_string/ft_str/test_atoi_base.c deleted file mode 100644 index 8f9b9da..0000000 --- a/libft/tests/ft_string/ft_str/test_atoi_base.c +++ /dev/null @@ -1,99 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_atoi_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 16:42:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -static int test_base_resps(const char *base, const int *expected_results, - const char **inputs) -{ - int i; - int res; - - i = 0; - while (inputs[i]) - { - res = ft_atoi_base(inputs[i], base); - if (res != expected_results[i]) - return (i + 1); - i++; - } - return (0); -} - -static int test_spaces(void) -{ - if (ft_atoi_base(" 0", "0123456789") != 0) - return (1); - if (ft_atoi_base(" 1", "0123456789") != 1) - return (2); - if (ft_atoi_base(" 9", "0123456789") != 9) - return (3); - if (ft_atoi_base(" 10", "0123456789") != 10) - return (4); - if (ft_atoi_base(" 99", "0123456789") != 99) - return (5); - if (ft_atoi_base(" -99", "0123456789") != -99) - return (6); - if (ft_atoi_base(" -0", "0123456789") != 0) - return (7); - if (ft_atoi_base(" -1", "0123456789") != -1) - return (8); - if (ft_atoi_base(" -10", "0123456789") != -10) - return (9); - if (ft_atoi_base(" -99", "0123456789") != -99) - return (10); - return (0); -} - -static int test_multi_sign(void) -{ - if (ft_atoi_base(" --99", "0123456789") != 99) - return (1); - if (ft_atoi_base(" -0", "0123456789") != 0) - return (2); - if (ft_atoi_base(" -++--1", "0123456789") != -1) - return (3); - if (ft_atoi_base(" -+--10", "0123456789") != -10) - return (4); - if (ft_atoi_base(" -+--99", "0123456789") != -99) - return (5); - return (0); -} - -int test_atoi_base(void) -{ - const char *bases[] = {"0123456789", "01", "0123456789abcdef"}; - const int expected_results[][11] = { - {0, 1, 9, 10, 99, 0, -1, -9, -10, -99}, - {0, 1, 2, 3, 4, 0, -1, -2, -3, -4}, - {0, 10, 15, 16, 153, 0, -10, -15, -16, -153} - }; - const char *strs[][12] = { - {"0", "1", "9", "10", "99", "0", "-1", "-9", "-10", "-99", NULL}, - {"0", "1", "10", "11", "100", "0", "-1", "-10", "-11", "-100", NULL}, - {"0", "a", "f", "10", "99", "0", "-a", "-f", "-10", "-99", NULL} - }; - - if (test_base_resps(bases[0], expected_results[0], strs[0]) || \ - test_base_resps(bases[1], expected_results[1], strs[1]) || \ - test_base_resps(bases[2], expected_results[2], strs[2])) - return (1); - if (ft_atoi_base("23", "011") || ft_atoi_base("23", "0") || \ - ft_atoi_base("23", "1") || ft_atoi_base("23", "0123456789-") || \ - ft_atoi_base("23", "0123456789+")) - return (2); - if (test_spaces()) - return (3); - if (test_multi_sign()) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_gnl.c b/libft/tests/ft_string/ft_str/test_gnl.c deleted file mode 100644 index 1f730a9..0000000 --- a/libft/tests/ft_string/ft_str/test_gnl.c +++ /dev/null @@ -1,75 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_gnl.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 14:26:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" -#include - -static int write_lines(const char **lines, size_t n) -{ - size_t i; - int fd; - - fd = open(TESTS_FPREFIX "gnl.txt", O_RDWR | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - return (-1); - i = 0; - while (i < n) - { - write(fd, lines[i], ft_strlen(lines[i])); - i++; - } - close(fd); - return (0); -} - -static const char **return_lines(size_t *n) -{ - static const char *test_lines[] = { - "Hello World!\n", - "This is Zod!\n", - "Zod shall henceforth be the new earth emperor. Prepare yourself " - "earthilings to the terrible rule of zod the space warrior and self " - "proclaimed emperor of the gallaxy. this is a really long line btw... " - "i sure hope gnl will parse it............................\n", - "Goodbye World!\n", - }; - - *n = sizeof(test_lines) / sizeof(test_lines[0]); - return (test_lines); -} - -int test_gnl(void) -{ - int fd; - char *line; - size_t i; - size_t lines_count; - const char **test_lines = return_lines(&lines_count); - - line = NULL; - if (write_lines(test_lines, lines_count) < 0) - return (1); - fd = open(TESTS_FPREFIX "gnl.txt", O_RDONLY); - i = 0; - while (i < lines_count) - { - line = get_next_line(fd); - if (ft_strcmp(line, test_lines[i++]) != 0) - return (i + 1); - free(line); - } - line = get_next_line(fd); - if (line) - return (2); - return (free(line), destroy_test_file(fd, TESTS_FPREFIX "gnl.txt"), 0); -} diff --git a/libft/tests/ft_string/ft_str/test_itoa.c b/libft/tests/ft_string/ft_str/test_itoa.c deleted file mode 100644 index 27fcbd5..0000000 --- a/libft/tests/ft_string/ft_str/test_itoa.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_itoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 14:26:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string.h" - -int test_itoa(void) -{ - char *res; - size_t i; - const int t_cases[] = {0, 123, -456, 7890, -12345}; - const char *expected_results[] = {"0", "123", "-456", "7890", "-12345"}; - - i = 0; - while (i < sizeof(t_cases) / sizeof(t_cases[0])) - { - res = ft_itoa(t_cases[i]); - if (ft_strcmp(res, expected_results[i++]) != 0) - return (i); - free(res); - } - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_itoa_base.c b/libft/tests/ft_string/ft_str/test_itoa_base.c deleted file mode 100644 index 9552d8b..0000000 --- a/libft/tests/ft_string/ft_str/test_itoa_base.c +++ /dev/null @@ -1,67 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_itoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/06/23 18:24:21 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string.h" - -#define MAGIC 42 - -int eval_base(int *t_cases, const char *bases, const char *expected_results[]) -{ - char *res; - size_t j; - - j = 0; - while (t_cases[j] != MAGIC) - { - res = ft_itoa_base(t_cases[j], bases); - if (ft_strcmp(res, expected_results[j]) != 0) - return (free(res), j + 1); - free(res); - j++; - } - return (0); -} - -int check_base_error(void) -{ - if (ft_itoa_base(0, "0") || ft_itoa_base(0, "010") || \ - ft_itoa_base(0, "0123456789+") || ft_itoa_base(0, "0123456789a-") \ - || ft_itoa_base(0, "0123456789a1") || ft_itoa_base(0, "0123456789a ") \ - || ft_itoa_base(0, "0123456789\t")) - return (15); - return (0); -} - -int test_itoa_base(void) -{ - size_t j; - const int t_cases[] = {0, 123, -456, 7890, -12345, MAGIC}; - const char *bases[] = {"0123456789abcdef", "0123456789", "01", - "0123456789ABCDEF"}; - const char *expected_results[sizeof(bases) - / sizeof(bases[0])][sizeof(t_cases) / sizeof(t_cases[0])] = {{"0", "7b", - "-1c8", "1ed2", "-3039"}, {"0", "123", "-456", "7890", "-12345"}, {"0", - "1111011", "-111001000", "1111011010010", "-11000000111001"}, {"0", - "7B", "-1C8", "1ED2", "-3039"}}; - - j = 0; - while (j < sizeof(bases) / sizeof(bases[0])) - { - if (eval_base((int *)t_cases, bases[j], expected_results[j]) != 0) - return (j + 1); - j++; - } - if (check_base_error() != 0) - return (j + check_base_error()); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_putendl.c b/libft/tests/ft_string/ft_str/test_putendl.c deleted file mode 100644 index 3b2fc13..0000000 --- a/libft/tests/ft_string/ft_str/test_putendl.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_putendl.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:07:22 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -int test_putendl(void) -{ - const char *str; - int fd; - char buff[100]; - int bread; - const char file_name[] = TESTS_FPREFIX "putendl.txt"; - - str = "Hello World!"; - fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - ft_putendl_fd(str, fd); - close(fd); - fd = open(file_name, O_RDONLY); - bread = read(fd, buff, 100); - if (bread < 0 || ft_strncmp(buff, str, ft_strlen(str)) != 0 - || buff[ft_strlen(str)] != '\n') - return (1); - destroy_test_file(fd, file_name); - fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - ft_putendl_fd(NULL, fd); - close(fd); - fd = open(file_name, O_RDONLY); - bread = read(fd, buff, 100); - if (bread != 0) - return (2); - destroy_test_file(fd, file_name); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_putnbr.c b/libft/tests/ft_string/ft_str/test_putnbr.c deleted file mode 100644 index 0005790..0000000 --- a/libft/tests/ft_string/ft_str/test_putnbr.c +++ /dev/null @@ -1,81 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_putnbr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/07/19 21:29:17 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" -#include -#include - -static int nb_to_file(const int *nbs, size_t size, const char *file_name) -{ - int fd; - size_t i; - - fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - if (fd < 0) - return (-1); - i = 0; - while (i < size) - { - ft_putnbr_fd(nbs[i], fd); - ft_putstr_fd("\n", fd); - i++; - } - close(fd); - return (0); -} - -static int file_cmp(const char *file_name, const char *expected) -{ - int fd; - char buff[100]; - - fd = open(file_name, O_RDONLY); - ft_bzero(buff, sizeof(buff)); - read(fd, buff, sizeof(buff)); - if (ft_strncmp(buff, expected, sizeof(buff))) - return (1); - return (destroy_test_file(fd, file_name), 0); -} - -static int test_positives(void) -{ - const int t_cases[] = {0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, \ - INT_MAX}; - const char *expected = "0\n1\n9\n10\n99\n100\n999\n1000\n9999\n10000\n" - "2147483647\n"; - const char *file_name = TESTS_FPREFIX "putnbr.txt"; - - nb_to_file(t_cases, sizeof(t_cases) / sizeof(t_cases[0]), file_name); - return (file_cmp(file_name, expected)); -} - -static int test_negatives(void) -{ - const int nbs[] = {-1, -9, -10, -99, -100, -999, -1000, -9999, -10000, \ - INT_MIN}; - const char *exp = "-1\n-9\n-10\n-99\n-100\n-999\n-1000\n-9999\n-10000\n" - "-2147483648\n"; - const char *file_name = TESTS_FPREFIX "putnbr.txt"; - - nb_to_file(nbs, sizeof(nbs) / sizeof(nbs[0]), file_name); - return (file_cmp(file_name, exp)); -} - -int test_putnbr(void) -{ - if (test_positives() != 0) - return (1); - if (test_negatives() != 0) - return (2); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_putstr.c b/libft/tests/ft_string/ft_str/test_putstr.c deleted file mode 100644 index fd1b2d7..0000000 --- a/libft/tests/ft_string/ft_str/test_putstr.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_putstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:08:01 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -int test_putstr(void) -{ - const char file_name[] = TESTS_FPREFIX "putstr.txt"; - const char *str = "Hello World!"; - int fd; - char buff[100]; - int bread; - - fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - ft_putstr_fd(str, fd); - close(fd); - fd = open(file_name, O_RDONLY); - bread = read(fd, buff, 100); - if (bread < 0 || ft_strncmp(buff, str, ft_strlen(str)) != 0) - return (1); - destroy_test_file(fd, file_name); - fd = open(file_name, O_RDWR | O_CREAT | O_TRUNC, 0666); - ft_putstr_fd(NULL, fd); - close(fd); - fd = open(file_name, O_RDONLY); - bread = read(fd, buff, 100); - if (bread != 0) - return (2); - destroy_test_file(fd, file_name); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_shift_args.c b/libft/tests/ft_string/ft_str/test_shift_args.c deleted file mode 100644 index 3967b67..0000000 --- a/libft/tests/ft_string/ft_str/test_shift_args.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_shift_args.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/07/06 17:39:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_shift_args(void) -{ - const char **tmp = NULL; - const char **test; - int fake_argc; - const char *ret; - const char *fake_args[] = (const char *[]) \ - {"test", "1", "2", "3", "4", NULL}; - - test = fake_args; - ret = NULL; - fake_argc = 5; - ret = ft_shift_args(&test, &fake_argc); - if (fake_argc != 4 || ft_strcmp(test[0], "1") != 0 || \ - ft_strcmp(test[1], "2") != 0 || ft_strcmp(test[2], "3") != 0 || \ - ft_strcmp(test[3], "4") != 0 || ft_strcmp(ret, "test") != 0) - return (1); - (ft_shift_args(&test, &fake_argc), ft_shift_args(&test, &fake_argc), \ - ft_shift_args(&test, &fake_argc), ft_shift_args(&test, &fake_argc)); - ret = ft_shift_args(&test, &fake_argc); - if (fake_argc != 0 || ret) - return (2); - fake_argc = 4012; - if (ft_shift_args(&test, &fake_argc) || ft_shift_args(&tmp, &fake_argc)) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_split.c b/libft/tests/ft_string/ft_str/test_split.c deleted file mode 100644 index 0289220..0000000 --- a/libft/tests/ft_string/ft_str/test_split.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_split.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:08:58 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_split(void) -{ - const char *str = " Hello World! "; - char **res; - const char *str2 = "Hello World! "; - char **res2; - size_t i; - - res = ft_split(str, ' '); - res2 = ft_split(str2, ' '); - if (ft_strcmp(res[0], "Hello") != 0 || ft_strcmp(res[1], "World!") != 0 - || res[2]) - return (1); - if (ft_strcmp(res2[0], "Hello") != 0 || ft_strcmp(res2[1], "World!") != 0 - || res2[2]) - return (2); - i = 0; - while (res[i]) - free(res[i++]); - i = 0; - while (res2[i]) - free(res2[i++]); - return (free(res), free(res2), 0); -} diff --git a/libft/tests/ft_string/ft_str/test_splits.c b/libft/tests/ft_string/ft_str/test_splits.c deleted file mode 100644 index 52c0d8a..0000000 --- a/libft/tests/ft_string/ft_str/test_splits.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_splits.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:22:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 14:16:23 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -int tests_splits(void) -{ - const char *str; - char **res; - size_t i; - - str = "path/to/file:another/path:yet/another/path"; - res = ft_splits(str, " /:"); - if (ft_strcmp(res[0], "path") != 0 || ft_strcmp(res[1], "to") != 0 || \ - ft_strcmp(res[2], "file") != 0 || ft_strcmp(res[3], "another") != 0 || \ - ft_strcmp(res[4], "path") != 0 || ft_strcmp(res[5], "yet") != 0 || \ - ft_strcmp(res[6], "another") != 0 || ft_strcmp(res[7], "path") != 0 || \ - res[8]) - return (1); - i = 0; - while (res[i]) - free(res[i++]); - free(res); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isalnum.c b/libft/tests/ft_string/ft_str/test_str_isalnum.c deleted file mode 100644 index b046103..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isalnum.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:00 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isalnum(void) -{ - if (ft_str_isalnum("HelloWorld42") != 1) - return (1); - if (ft_str_isalnum("Hello World42") != 0) - return (2); - if (ft_str_isalnum("Hello21World!") != 0) - return (3); - if (ft_str_isalnum("Hello420BlazeIt.") != 0) - return (4); - if (ft_str_isalnum("HelloWorld696969\0") != 1) - return (5); - if (ft_str_isalnum("") != 0) - return (6); - if (ft_str_isalnum(NULL) != false) - return (7); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isalpha.c b/libft/tests/ft_string/ft_str/test_str_isalpha.c deleted file mode 100644 index 489931e..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isalpha.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isalpha(void) -{ - if (ft_str_isalpha("HelloWorld") != 1) - return (1); - if (ft_str_isalpha("Hello World") != 0) - return (2); - if (ft_str_isalpha("HelloWorld!") != 0) - return (3); - if (ft_str_isalpha("HelloWorld42") != 0) - return (4); - if (ft_str_isalpha("HelloWorld\0") != 1) - return (5); - if (ft_str_isalpha("") != 0) - return (6); - if (ft_str_isalpha(NULL) != false) - return (7); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isbool.c b/libft/tests/ft_string/ft_str/test_str_isbool.c deleted file mode 100644 index 229d231..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isbool.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isbool.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:22:20 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:20 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isbool(void) -{ - if (ft_str_isbool("1") != 1 || ft_str_isbool("true") != 1) - return (1); - if (ft_str_isbool("0") != 1 || ft_str_isbool("false") != 1) - return (2); - if (ft_str_isbool("true!") != 0) - return (3); - if (ft_str_isbool("falseeurt") != 0) - return (4); - if (ft_str_isbool("truetrue") != 0) - return (5); - if (ft_str_isbool("false42") != 0) - return (6); - if (ft_str_isbool("false\t") != 0) - return (7); - if (ft_str_isbool("") != 0) - return (8); - if (ft_str_isbool(NULL) != false) - return (9); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isdigit.c b/libft/tests/ft_string/ft_str/test_str_isdigit.c deleted file mode 100644 index 0b1be9b..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isdigit.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:32 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isdigit(void) -{ - if (ft_str_isdigit("00000000000000000000012") != 1) - return (1); - if (ft_str_isdigit("1234567890q") != 0) - return (2); - if (ft_str_isdigit("8^)") != 0) - return (3); - if (ft_str_isdigit("42.5") != 0) - return (4); - if (ft_str_isdigit("+00") != 0) - return (5); - if (ft_str_isdigit("") != 0) - return (6); - if (ft_str_isdigit(NULL) != false) - return (7); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isdouble.c b/libft/tests/ft_string/ft_str/test_str_isdouble.c deleted file mode 100644 index 27521b4..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isdouble.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isdouble.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:42 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isdouble(void) -{ - if (ft_str_isdouble("23.3") != 1 || ft_str_isdouble("42") != 1 || \ - ft_str_isdouble(".22") != 1 || ft_str_isdouble("0.0") != 1 || \ - ft_str_isdouble("2.000000") != 1 || ft_str_isdouble("0.000000") != 1) - return (1); - if (ft_str_isdouble("34..4") != 0) - return (2); - if (ft_str_isdouble("0a.0") != 0 || ft_str_isdouble("0.0a") != 0) - return (3); - if (ft_str_isdouble("0.0.0") != 0) - return (4); - if (ft_str_isdouble("-") != 0 || ft_str_isdouble("+") != 0 || \ - ft_str_isdouble("-.") != 0 || ft_str_isdouble("+.") != 0) - return (5); - if (ft_str_isdouble("94308243208523048750743") != 0 || \ - ft_str_isdouble("") != 0 || ft_str_isdouble(".") != 0) - return (6); - if (ft_str_isdouble(NULL) != false) - return (7); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isfloat.c b/libft/tests/ft_string/ft_str/test_str_isfloat.c deleted file mode 100644 index d183a92..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isfloat.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isfloat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:43:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isfloat(void) -{ - if (ft_str_isfloat("23.3") != 1 || ft_str_isfloat("42") != 1 || \ - ft_str_isfloat(".22") != 1 || ft_str_isfloat("0.0") != 1 || \ - ft_str_isfloat("2.000000") != 1 || ft_str_isfloat("0.000000") != 1 || \ - ft_str_isfloat("-2") != 1 || ft_str_isfloat("2") != 1 || \ - ft_str_isfloat("2.") != 1 || ft_str_isfloat(".2") != 1) - return (1); - if (ft_str_isfloat("23.3.3") != 0 || \ - ft_str_isfloat("-") != 0 || ft_str_isfloat("+") != 0 || \ - ft_str_isfloat("") != 0) - return (2); - if (ft_str_isfloat(NULL) != false) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_ishex.c b/libft/tests/ft_string/ft_str/test_str_ishex.c deleted file mode 100644 index c88598b..0000000 --- a/libft/tests/ft_string/ft_str/test_str_ishex.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_ishex.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:44:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_ishex(void) -{ - if (ft_str_ishex("0123456789abcdefABCDEF") != 1) - return (1); - if (ft_str_ishex("0xdeadbeef") != 1 || ft_str_ishex("0xDEADBEEF") != 1) - return (2); - if (ft_str_ishex("0xdeadbeefg") != 0 || ft_str_ishex("0xDEADBEEFG") != 0) - return (3); - if (ft_str_ishex("0x") != 0 || ft_str_ishex("0X") != 0) - return (4); - if (ft_str_ishex("0x+32") != 0 || ft_str_ishex("0x-32") != 0) - return (5); - if (ft_str_ishex("0x0x") != 0 || ft_str_ishex("0X0X") != 0) - return (6); - if (ft_str_ishex("-0x0") != 0 || ft_str_ishex("+0X0") != 0) - return (7); - if (ft_str_ishex("0x0") != 1 || ft_str_ishex("0X0") != 1) - return (8); - if (ft_str_ishex("") != 0) - return (8); - if (ft_str_ishex(NULL) != false) - return (9); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isint.c b/libft/tests/ft_string/ft_str/test_str_isint.c deleted file mode 100644 index 58bd990..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isint.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 09:11:09 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isint(void) -{ - if (ft_str_isint("23") != 1 || ft_str_isint("42") != 1 || \ - ft_str_isint("0") != 1 || ft_str_isint("-42") != 1 || \ - ft_str_isint("2147483647") != 1 || ft_str_isint("-2147483648") != 1) - return (1); - if (ft_str_isint("23.3") != 0 || ft_str_isint("42.0") != 0 || \ - ft_str_isint("0.0") != 0 || ft_str_isint("2.000000") != 0 || \ - ft_str_isint("0.000000") != 0 || ft_str_isint("2147483648") != 0 || \ - ft_str_isint("-2147483649") != 0 || ft_str_isint("2147483647.0") != 0 || \ - ft_str_isint("-2147483648.0") != 0) - return (2); - if (ft_str_isint("") != 0 || ft_str_isint("999999999999") != 0 || \ - ft_str_isint("-") != 0 || ft_str_isint("+") != 0) - return (3); - if (ft_str_isint(NULL) != false) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_islong.c b/libft/tests/ft_string/ft_str/test_str_islong.c deleted file mode 100644 index f784acd..0000000 --- a/libft/tests/ft_string/ft_str/test_str_islong.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_islong.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:44:27 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_islong(void) -{ - if (ft_str_islong("23") != 1 || ft_str_islong("42") != 1 || \ - ft_str_islong("0") != 1 || ft_str_islong("2") != 1 || \ - ft_str_islong("-34") != 1 || ft_str_islong("42") != 1 || \ - ft_str_islong("9223372036854775807") != 1 || \ - ft_str_islong("-9223372036854775808") != 1) - return (1); - if (ft_str_islong("9223372036854775808") != 0 || \ - ft_str_islong("-9223372036854775809") != 0 || \ - ft_str_islong("92233720368547758070") != 0 || \ - ft_str_islong("-92233720368547758080") != 0 || \ - ft_str_islong("9223372036854775807a") != 0 || \ - ft_str_islong("-9223372036854775808a") != 0 || \ - ft_str_islong("9223372036854775807 ") != 0 || \ - ft_str_islong("-9223372036854775808 ") != 0 || \ - ft_str_islong("-+0") != 0 || ft_str_islong("+-0") != 0 || \ - ft_str_islong("0-") != 0 || ft_str_islong("0+") != 0) - return (2); - if (ft_str_islong("") != 0 || ft_str_islong("-") != 0) - return (3); - if (ft_str_islong(NULL) != false) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isnum.c b/libft/tests/ft_string/ft_str/test_str_isnum.c deleted file mode 100644 index 1bd26e9..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isnum.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:44:36 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isnum(void) -{ - if (ft_str_isnum("-23") != 1 || ft_str_isnum("+42") != 1 || \ - ft_str_isnum("0") != 1 || ft_str_isnum("2345865785645643532453") != 1 || \ - ft_str_isnum("2147483647") != 1) - return (1); - if (ft_str_isnum("23.3") != 0 || ft_str_isnum("42.0") != 0 || \ - ft_str_isnum("0.0") != 0 || ft_str_isnum("2.000000") != 0 || \ - ft_str_isnum("0.000000") != 0 || ft_str_isnum("--2147483648") != 0 || \ - ft_str_isnum("++2147483648") != 0) - return (2); - if (ft_str_isnum("") != 0 || ft_str_isnum("+") != 0 || \ - ft_str_isnum("-") != 0) - return (3); - if (ft_str_isnum(NULL) != false) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isoct.c b/libft/tests/ft_string/ft_str/test_str_isoct.c deleted file mode 100644 index 788ebb6..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isoct.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isoct.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:45:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_isoct(void) -{ - if (ft_str_isoct("0o1234567") != 1 || ft_str_isoct("0O1234567") != 1 || \ - ft_str_isoct("0o342") != 1 || ft_str_isoct("0o0") != 1 || \ - ft_str_isoct("0o000000") != 1) - return (1); - if (ft_str_isoct("-0o1234568") != 0 || ft_str_isoct("0o1234568") != 0 || \ - ft_str_isoct("0o9") != 0 || ft_str_isoct("12") != 0 || \ - ft_str_isoct("-7") != 0 || ft_str_isoct("+67") != 0) - return (2); - if (ft_str_isoct(NULL) != false) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_isvalid.c b/libft/tests/ft_string/ft_str/test_str_isvalid.c deleted file mode 100644 index aaadd32..0000000 --- a/libft/tests/ft_string/ft_str/test_str_isvalid.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_isvalid.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/29 08:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:45:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int string_validator(int c) -{ - return (c == 'a' || c == 'b' || c == 'c'); -} - -int test_str_isvalid(void) -{ - if (ft_str_isvalid("abc", string_validator) != 1 || ft_str_isvalid("abcabc", - string_validator) != 1 || ft_str_isvalid("aabbcc", - string_validator) != 1) - return (1); - if (ft_str_isvalid("abd", string_validator) != 0 || ft_str_isvalid("bap", - string_validator) != 0 || ft_str_isvalid("ck", - string_validator) != 0) - return (2); - if (ft_str_isvalid("", string_validator) != 0 || ft_str_isvalid(NULL, - string_validator) != false) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_replace.c b/libft/tests/ft_string/ft_str/test_str_replace.c deleted file mode 100644 index 63706a4..0000000 --- a/libft/tests/ft_string/ft_str/test_str_replace.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_replace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:52:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_replace(void) -{ - char *str; - char *res; - - str = "Hello World!"; - res = ft_str_replace(str, "World", "Zod"); - if (ft_strcmp(res, "Hello Zod!") != 0) - return (1); - free(res); - res = ft_str_replace(str, "World", ""); - if (ft_strcmp(res, "Hello !") != 0) - return (2); - free(res); - str = "Hello World!"; - res = ft_str_replace(str, "toto", "tutu"); - if (ft_strcmp(res, "Hello World!") != 0) - return (3); - free(res); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_str_replace_chr.c b/libft/tests/ft_string/ft_str/test_str_replace_chr.c deleted file mode 100644 index a0a26da..0000000 --- a/libft/tests/ft_string/ft_str/test_str_replace_chr.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_str_replace_chr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:10:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_str_replace_chr(void) -{ - char *str; - char *res; - - str = ft_strdup("Hello World!"); - res = ft_str_replace_chr(str, 'o', 'a'); - if (ft_strcmp(res, "Hella Warld!") != 0) - return (1); - free(res); - str = ft_strdup("Hello World!"); - res = ft_str_replace_chr(str, 'o', '\0'); - if (ft_strcmp(res, "Hell") != 0 || ft_strcmp(res + 5, " W") != 0 - || ft_strcmp(res + 8, "rld!") != 0) - return (4); - free(res); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strappend_c.c b/libft/tests/ft_string/ft_str/test_strappend_c.c deleted file mode 100644 index 0235755..0000000 --- a/libft/tests/ft_string/ft_str/test_strappend_c.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strappend_c.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:12:40 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:08:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -// calloc sets the \0 byte at the end of the string -// we test the function can append at empty string -int test_strappend_c(void) -{ - char *str; - - str = ft_strdup("Hello"); - if (!str) - return (1); - if (ft_strappend_c(&str, ' ') == 0 || ft_strcmp(str, "Hello ") != 0) - return (2); - if (ft_strappend_c(&str, 'W') == 0 || ft_strcmp(str, "Hello W") != 0) - return (3); - if (ft_strappend_c(NULL, '\0')) - return (4); - free(str); - str = ft_calloc(1, 1); - if (!str || ft_strappend_c(&str, ' ') == 0 || ft_strcmp(str, " ") != 0) - return (5); - free(str); - str = NULL; - if (ft_strappend_c(&str, ' ') == 0 || ft_strcmp(str, " ") != 0) - return (6); - free(str); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strchr.c b/libft/tests/ft_string/ft_str/test_strchr.c deleted file mode 100644 index cb74fdc..0000000 --- a/libft/tests/ft_string/ft_str/test_strchr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:12:40 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 07:51:50 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strchr(void) -{ - char *str; - char s; - char s2; - char *res; - - str = "Hello World!"; - s = 'o'; - s2 = 'z'; - res = ft_strchr(str, s); - if (res != str + 4) - return (1); - res = ft_strchr(str, s2); - if (res) - return (2); - res = ft_strchr(str, '\0'); - if (res != str + ft_strlen(str)) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strclen.c b/libft/tests/ft_string/ft_str/test_strclen.c deleted file mode 100644 index 12c95b0..0000000 --- a/libft/tests/ft_string/ft_str/test_strclen.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strclen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:47:16 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:05:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strclen(void) -{ - if (ft_strclen("Hello World", 'o') != 4) - return (1); - if (ft_strclen("Hello World", 'z') != 11) - return (1); - if (ft_strclen("Hello World", 'H') != 0) - return (1); - if (ft_strclen("Hello World", 'd') != 10) - return (1); - if (ft_strclen("Hello World", ' ') != 5) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strcmp.c b/libft/tests/ft_string/ft_str/test_strcmp.c deleted file mode 100644 index 50551af..0000000 --- a/libft/tests/ft_string/ft_str/test_strcmp.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:12:10 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 14:17:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strcmp(void) -{ - const char *buffs[] = { - "none", - "some", - "nonethensome", - "nonethensome", - "!\0a", - "!\0b", - }; - - if (ft_strcmp(buffs[0], buffs[1]) >= 0) - return (1); - if (ft_strcmp(buffs[0], buffs[2]) >= 0) - return (2); - if (ft_strcmp(buffs[2], buffs[3]) != 0) - return (3); - if (ft_strcmp(buffs[4], buffs[5]) != 0) - return (4); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strcnb.c b/libft/tests/ft_string/ft_str/test_strcnb.c deleted file mode 100644 index a2a7b69..0000000 --- a/libft/tests/ft_string/ft_str/test_strcnb.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strcnb.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:47:58 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:06:11 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -int test_strcnb(void) -{ - if (ft_strcnb("Hello World", 'o') != 2) - return (1); - if (ft_strcnb("Hello World", 'z') != 0) - return (2); - if (ft_strcnb("Hello World", 'H') != 1) - return (3); - if (ft_strcnb("Hello World", 'd') != 1) - return (4); - if (ft_strcnb("Hello World", 'l') != 3) - return (5); - if (ft_strcnb(NULL, ' ') != 0) - return (6); - if (ft_strcnb("toto", '\0') != 1) - return (7); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strcspn.c b/libft/tests/ft_string/ft_str/test_strcspn.c deleted file mode 100644 index 0d3d359..0000000 --- a/libft/tests/ft_string/ft_str/test_strcspn.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strcspn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:48:32 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:03:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strcspn(void) -{ - if (ft_strcspn("Hello World", "o") != 4) - return (1); - if (ft_strcspn("Hello World", "z") != 11) - return (1); - if (ft_strcspn("Hello World", "H") != 0) - return (1); - if (ft_strcspn("Hello World", "d") != 10) - return (1); - if (ft_strcspn("Hello World", " ") != 5) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strdup.c b/libft/tests/ft_string/ft_str/test_strdup.c deleted file mode 100644 index ced528f..0000000 --- a/libft/tests/ft_string/ft_str/test_strdup.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:23:17 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:10:32 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strdup(void) -{ - char *str; - char *res; - - str = "Hello World!"; - res = ft_strdup(str); - if (ft_strcmp(res, str) != 0) - return (1); - free(res); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strend_with.c b/libft/tests/ft_string/ft_str/test_strend_with.c deleted file mode 100644 index 5494cfa..0000000 --- a/libft/tests/ft_string/ft_str/test_strend_with.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strend_with.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:49:13 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 10:49:34 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strend_with(void) -{ - if (ft_strend_with("Hello World", "World") != 1) - return (1); - if (ft_strend_with("Hello World", "World!") != 0) - return (1); - if (ft_strend_with("Hello World", "Hello") != 0) - return (1); - if (ft_strend_with("Hello World", "Hello World") != 1) - return (1); - if (ft_strend_with("Hello World", "Hello World!") != 0) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_striteri.c b/libft/tests/ft_string/ft_str/test_striteri.c deleted file mode 100644 index 927c843..0000000 --- a/libft/tests/ft_string/ft_str/test_striteri.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_striteri.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:39:56 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:11:48 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -static void local_iteri(unsigned int i, char *c) -{ - *c = 'a'; - (void)i; -} - -// last 2 calls are to test NULL protection -int test_striteri(void) -{ - char str[20]; - - ft_strlcpy(str, "Hello World!", 20); - ft_striteri(str, &local_iteri); - if (ft_strcmp(str, "aaaaaaaaaaaa") != 0) - return (1); - ft_striteri(NULL, &local_iteri); - ft_striteri(str, NULL); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strjoin.c b/libft/tests/ft_string/ft_str/test_strjoin.c deleted file mode 100644 index ddd9372..0000000 --- a/libft/tests/ft_string/ft_str/test_strjoin.c +++ /dev/null @@ -1,75 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:11:19 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:10:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -static int test_right_empty(void) -{ - char *str; - char *str2; - char *res; - - str = "Hello World!"; - str2 = ""; - res = ft_strjoin(str, str2); - if (ft_strcmp(res, "Hello World!") != 0 || !res || res == str - || res == str2) - return (1); - free(res); - str2 = NULL; - res = ft_strjoin(str, str2); - if (ft_strcmp(res, "Hello World!") != 0 || !res || res == str) - return (2); - free(res); - return (0); -} - -static int test_left_empty(void) -{ - char *str; - char *str2; - char *res; - - str = ""; - str2 = "Hello World!"; - res = ft_strjoin(str, str2); - if (ft_strcmp(res, "Hello World!") != 0 || !res || res == str - || res == str2) - return (1); - free(res); - str = NULL; - res = ft_strjoin(str, str2); - if (ft_strcmp(res, "Hello World!") != 0 || !res || res == str2) - return (2); - free(res); - return (0); -} - -int test_strjoin(void) -{ - char *str; - char *str2; - char *res; - - str = "Hello World!"; - str2 = "Hello World!"; - res = ft_strjoin(str, str2); - if (ft_strcmp(res, "Hello World!Hello World!") != 0) - return (1); - free(res); - if (test_right_empty() != 0) - return (20 + test_right_empty()); - if (test_left_empty() != 0) - return (30 + test_left_empty()); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strlcat.c b/libft/tests/ft_string/ft_str/test_strlcat.c deleted file mode 100644 index 90d9454..0000000 --- a/libft/tests/ft_string/ft_str/test_strlcat.c +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:11:01 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:24:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include -#include - -int test_strlcat(void) -{ - char *res; - size_t size; - int ret; - - size = 15; - res = malloc(sizeof(char) * size); - ft_bzero(res, size); - ret = ft_strlcat(res, "Hello", size); - if (ft_strcmp(res, "Hello") != 0 || ret != 5) - return (1); - ret = ft_strlcat(res, " World!", size); - if (ft_strcmp(res, "Hello World!") != 0 || ret != 12) - return (2); - ret = ft_strlcat(res, "This is zod!", size); - if (ft_strcmp(res, "Hello World!Th") != 0 || ret != 24) - return (3); - ret = ft_strlcat(res, "This is zod!", 5); - if (ft_strcmp(res, "Hello World!Th") != 0 || ret != 5 + 12) - return (4); - if (ft_strlcat(NULL, "test", 0) != 0 || ft_strlcat(NULL, "test", 5) != 0) - return (5); - ret = ft_strlcat(res, NULL, size); - if (ft_strcmp(res, "Hello World!Th") != 0 || ret != 14) - return (6); - return (free(res), 0); -} diff --git a/libft/tests/ft_string/ft_str/test_strlcpy.c b/libft/tests/ft_string/ft_str/test_strlcpy.c deleted file mode 100644 index a8d70ed..0000000 --- a/libft/tests/ft_string/ft_str/test_strlcpy.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strlcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:10:11 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 09:10:36 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include -#include - -static int base_cases(void) -{ - const char *str = "Hello World!"; - char *res; - size_t size; - int ret; - - size = 15; - res = ft_calloc(sizeof(char), size); - ret = ft_strlcpy(res, str, size); - if (ft_strcmp(res, "Hello World!") != 0 || ret != 12) - return (1); - free(res); - res = malloc(sizeof(char) * size); - ret = ft_strlcpy(res, "This is zod!", size); - if (ft_strcmp(res, "This is zod!") != 0 || ret != 12) - return (2); - return (free(res), 0); -} - -static int error_cases(void) -{ - char *res; - size_t size; - int ret; - - size = 15; - res = ft_calloc(sizeof(char), size); - ret = ft_strlcpy(res, "This is too large!", size); - if (ft_strncmp(res, "This is too large!", size - 1) != 0 || \ - ret != (int)ft_strlen("This is too large!")) - return (3); - free(res); - res = ft_calloc(sizeof(char), 1); - ret = ft_strlcpy(res, "Hello World!", 0); - if (ft_strcmp(res, "") != 0 || ret != 12) - return (4); - ret = ft_strlcpy(res, NULL, 42); - if (ft_strcmp(res, "") != 0 || ret != 0) - return (5); - ret = ft_strlcpy(NULL, "Hello World!", 42); - if (ret != 42) - return (6); - return (free(res), 0); -} - -int test_strlcpy(void) -{ - int ret; - - ret = base_cases(); - if (ret != 0) - return (ret); - ret = error_cases(); - if (ret != 0) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strlen.c b/libft/tests/ft_string/ft_str/test_strlen.c deleted file mode 100644 index d3373e8..0000000 --- a/libft/tests/ft_string/ft_str/test_strlen.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 12:26:06 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 12:26:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strlen(void) -{ - char *str; - char *str2; - char *str3; - - str = "Hello World!"; - str2 = ""; - str3 = "Hello\0World!"; - if (ft_strlen(str) != 12) - return (1); - if (ft_strlen(str2) != 0) - return (2); - if (ft_strlen(str3) != 5) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strmapi.c b/libft/tests/ft_string/ft_str/test_strmapi.c deleted file mode 100644 index 07642ed..0000000 --- a/libft/tests/ft_string/ft_str/test_strmapi.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:10:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:40:48 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -static char local_mapi(unsigned int i, char c) -{ - (void)i; - if (c >= 'a' && c <= 'z') - return (c - 32); - if (c >= 'A' && c <= 'Z') - return (c + 32); - return (c); -} - -int test_strmapi(void) -{ - char *str; - char *res; - - str = "Hello World!"; - res = ft_strmapi(str, &local_mapi); - if (ft_strcmp(res, "hELLO wORLD!") != 0) - return (1); - free(res); - res = ft_strmapi(NULL, &local_mapi); - if (res) - return (2); - res = ft_strmapi(str, NULL); - if (res) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strncmp.c b/libft/tests/ft_string/ft_str/test_strncmp.c deleted file mode 100644 index f7d036b..0000000 --- a/libft/tests/ft_string/ft_str/test_strncmp.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 12:23:03 by bgoulard #+# #+# */ -/* Updated: 2024/05/26 12:23:05 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strncmp(void) -{ - const char *str_buffs[] = { - "none", - "some", - "nonethensome", - "nonethensome", - "!\0a", - "!\0b", - NULL - }; - - if (ft_strncmp(str_buffs[0], str_buffs[1], 4) >= 0) - return (1); - if (ft_strncmp(str_buffs[0], str_buffs[2], 4) != 0) - return (2); - if (ft_strncmp(str_buffs[2], str_buffs[3], 4) != 0) - return (3); - if (ft_strncmp(str_buffs[4], str_buffs[5], 4) != 0) - return (4); - if (ft_strncmp(str_buffs[5], str_buffs[0], 0) != 0) - return (5); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strndup.c b/libft/tests/ft_string/ft_str/test_strndup.c deleted file mode 100644 index 65fbaf2..0000000 --- a/libft/tests/ft_string/ft_str/test_strndup.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strndup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:23:38 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:13:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strndup(void) -{ - char *str; - char *res; - - str = "Hello World!"; - res = ft_strndup(str, 5); - if (ft_strcmp(res, "Hello") != 0) - return (1); - free(res); - res = ft_strndup(str, 0); - if (ft_strcmp(res, "") != 0) - return (2); - free(res); - res = ft_strndup(str, 12); - if (ft_strcmp(res, "Hello World!") != 0) - return (3); - free(res); - res = ft_strndup(str, 15); - if (ft_strcmp(res, "Hello World!") != 0) - return (4); - free(res); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strnstr.c b/libft/tests/ft_string/ft_str/test_strnstr.c deleted file mode 100644 index b2bdb6f..0000000 --- a/libft/tests/ft_string/ft_str/test_strnstr.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strnstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:24:10 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 08:44:18 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -int test_strnstr(void) -{ - char *str; - char *res; - - str = "The cake is a lie !\0I'm hidden lol\n"; - if (ft_strnstr(str, "The cake is a lie !", 100) != str) - return (1); - if (ft_strnstr(str, "The cake is a lie !", 20) != str) - return (2); - res = ft_strnstr(str, "The cake is a lie !", 19); - if (!res) - return (3); - if (ft_strnstr(str, "The cake is a lie !", 0)) - return (4); - if (ft_strnstr(str, "hidden", 100)) - return (5); - if (ft_strnstr(NULL, "hidden", 10) || \ - ft_strnstr(str, NULL, 10)) - return (6); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strrchr.c b/libft/tests/ft_string/ft_str/test_strrchr.c deleted file mode 100644 index 149647e..0000000 --- a/libft/tests/ft_string/ft_str/test_strrchr.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:41:05 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:14:12 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -int test_strrchr(void) -{ - char *str; - char s; - char s2; - char *res; - - str = "Hello World!"; - s = 'o'; - s2 = 'z'; - res = ft_strrchr(str, s); - if (res != str + 7) - return (1); - res = ft_strrchr(str, s2); - if (res) - return (2); - res = ft_strrchr(str, '\0'); - if (res != str + ft_strlen(str)) - return (3); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strspn.c b/libft/tests/ft_string/ft_str/test_strspn.c deleted file mode 100644 index fa673bc..0000000 --- a/libft/tests/ft_string/ft_str/test_strspn.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strspn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:48:32 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:05:30 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strspn(void) -{ - if (ft_strspn("Hello World", "o") != 0) - return (1); - if (ft_strspn("Hello World", "z") != 0) - return (1); - if (ft_strspn("Hello World", "H") != 1) - return (1); - if (ft_strspn("Hello World", "d") != 0) - return (1); - if (ft_strspn("Hello World", "Helo Wrd") != 11) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strstart_with.c b/libft/tests/ft_string/ft_str/test_strstart_with.c deleted file mode 100644 index fef0f33..0000000 --- a/libft/tests/ft_string/ft_str/test_strstart_with.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strstart_with.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 10:49:38 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 10:49:51 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strstart_with(void) -{ - if (ft_strstart_with("Hello World", "Hello") != 1) - return (1); - if (ft_strstart_with("Hello World", "Hello!") != 0) - return (1); - if (ft_strstart_with("Hello World", "World") != 0) - return (1); - if (ft_strstart_with("Hello World", "Hello World") != 1) - return (1); - if (ft_strstart_with("Hello World", "Hello World!") != 0) - return (1); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strtok.c b/libft/tests/ft_string/ft_str/test_strtok.c deleted file mode 100644 index a7709ed..0000000 --- a/libft/tests/ft_string/ft_str/test_strtok.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strtok.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:24:49 by bgoulard #+# #+# */ -/* Updated: 2024/06/25 21:43:49 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strtok(void) -{ - char test[50]; - char lorem[30]; - - lorem[0] = '\0'; - test[0] = '\0'; - ft_strlcpy(lorem, "Lorem ipsum dolor ", 30); - ft_strlcpy(test, ":::path/to/file:::another/path::yet/:/another/path", 47); - if (ft_strcmp(ft_strtok(lorem, " "), "Lorem") != 0 - || ft_strcmp(ft_strtok(NULL, " "), "ipsum") != 0 - || ft_strcmp(ft_strtok(NULL, " "), "dolor") != 0) - return (1); - if (ft_strcmp(ft_strtok(NULL, " "), "") != 0 || ft_strtok(NULL, - " ")) - return (2); - if (ft_strcmp(ft_strtok(test, ":"), "path/to/file") != 0 - || ft_strcmp(ft_strtok(NULL, ":"), "another/path") != 0) - return (3); - if (ft_strcmp(ft_strtok(NULL, ":/"), "yet") != 0) - return (4); - if (ft_strcmp(ft_strtok(NULL, ":/"), "another") != 0) - return (5); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_strtrim.c b/libft/tests/ft_string/ft_str/test_strtrim.c deleted file mode 100644 index 33334c1..0000000 --- a/libft/tests/ft_string/ft_str/test_strtrim.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:19:56 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 09:00:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_strtrim(void) -{ - const char *str_ugly = " Hello World! "; - const char *str_ugly_front = " Hello World!"; - char *res[7]; - - res[0] = ft_strtrim(ft_strchr(str_ugly, 'H'), " "); - res[1] = ft_strtrim(str_ugly, " "); - res[2] = ft_strtrim(str_ugly_front, " "); - res[3] = ft_strtrim(str_ugly, " !Wd"); - res[4] = ft_strtrim(str_ugly, NULL); - res[5] = ft_strtrim(" ", " "); - res[6] = ft_strtrim(NULL, " "); - if (ft_strcmp(res[0], "Hello World!") != 0 || ft_strcmp(res[1], \ - "Hello World!") != 0 || ft_strcmp(res[2], "Hello World!") != 0 || \ - ft_strcmp(res[3], "Hello Worl") != 0 || ft_strcmp(res[4], str_ugly) \ - != 0 || ft_strcmp(res[5], "") != 0 || res[6]) - return (1); - ft_apply_2d((void **)res, free); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_substr.c b/libft/tests/ft_string/ft_str/test_substr.c deleted file mode 100644 index 8468b92..0000000 --- a/libft/tests/ft_string/ft_str/test_substr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_substr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 12:25:34 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 09:02:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_substr(void) -{ - const char *str = "Hello World!"; - char *res[7]; - - res[0] = ft_substr(str, 0, 5); - res[1] = ft_substr(str, 6, 6); - res[2] = ft_substr(str, 6, 100); - res[3] = ft_substr(str, 6, 0); - res[4] = ft_substr(str, 12, 0); - res[5] = ft_substr(str, 12, 100); - res[6] = ft_substr(NULL, 0, 5); - if (ft_strcmp(res[0], "Hello") != 0 || ft_strcmp(res[1], "World!") != 0 - || ft_strcmp(res[2], "World!") != 0) - return (1); - if (ft_strcmp(res[3], "") != 0 || ft_strcmp(res[4], "") != 0 - || ft_strcmp(res[5], "") != 0 || res[6]) - return (2); - ft_apply_2d((void **)res, free); - return (0); -} diff --git a/libft/tests/ft_string/ft_str/test_utoa.c b/libft/tests/ft_string/ft_str/test_utoa.c deleted file mode 100644 index 3e86956..0000000 --- a/libft/tests/ft_string/ft_str/test_utoa.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_utoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/26 11:17:28 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:39:44 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include - -int test_utoa(void) -{ - char *res; - size_t i; - const unsigned int t_cases[] = {0, 123, 456, 7890, 12345}; - const char *expected_results[] = \ - {"0", "123", "456", "7890", "12345"}; - - i = 0; - while (i < sizeof(t_cases) / sizeof(t_cases[0])) - { - res = ft_utoa(t_cases[i]); - if (ft_strcmp(res, expected_results[i++]) != 0) - return (i); - free(res); - } - return (0); -} diff --git a/libft/tests/ft_string/ft_string/t_string_tests.c b/libft/tests/ft_string/ft_string/t_string_tests.c deleted file mode 100644 index cf9dd6e..0000000 --- a/libft/tests/ft_string/ft_string/t_string_tests.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* t_string_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/30 13:39:25 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:36:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/str__t_str_test.h" -#include "tests/tests.h" - -static const t_test *loadtests01(void) -{ - static const t_test tests[] = { - {"append_c", test_string_append_c}, {"append_n", test_string_append_n}, - {"append_sn", test_string_append_sn}, {"append_s", test_string_append_s}, - {"append", test_string_append}, {"cap", test_string_cap}, - {"chr", test_string_chr}, {"clear", test_string_clear}, - {"cmp_str", test_string_cmp_str}, {"cmp", test_string_cmp}, - {"destroy", test_string_destroy}, {"from_c", test_string_from_c}, - {"from_n", test_string_from_n}, {"from_sn", test_string_from_sn}, - {"from_s", test_string_from_s}, {"from", test_string_from}, - {"get", test_string_get}, {"insert_c", test_string_insert_c}, - {"insert_n", test_string_insert_n}, {"insert_sn", test_string_insert_sn}, - {"insert_s", test_string_insert_s}, {"insert", test_string_insert}, - {"length", test_string_len}, {"ncmp_str", test_string_ncmp_str}, - {"ncmp", test_string_ncmp}, {"new", test_string_new}, - {"offset", test_string_offset}, {"put", test_string_put}, - {"rchr", test_string_rchr}, {"replace_c", test_string_replace_chr}, - {"replace", test_string_replace}, {"reserve", test_string_reserve}, - {"resize", test_string_resize}, {"roffset", test_string_roffset}, - {"set", test_string_set}, {"set_n", test_string_set_n}, - {"set_inplace", test_string_set_inplace}, {"shrink", test_string_shrink}, - {"substr", test_string_substr}, {"to_str", test_string_to_str}, - {"trim_chr", test_string_trim_chr}, {"trimstr", test_string_trimstr}, - {"trim", test_string_trim}, {NULL, NULL}}; - - return (tests); -} - -static const t_test *loadtests02(void) -{ - return (NULL); -} - -int t_string_tests(void) -{ - int sum; - const t_test *tests = loadtests01(); - const t_test *tests02 = loadtests02(); - - sum = 0; - (void)tests02; - run_test(tests, &sum); - return (sum); -} diff --git a/libft/tests/ft_string/ft_string/test_append.c b/libft/tests/ft_string/ft_string/test_append.c deleted file mode 100644 index e019d17..0000000 --- a/libft/tests/ft_string/ft_string/test_append.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_append.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:24:16 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_append(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_append(str, " World"); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_destroy(&str); - str = ft_string_from("hi"); - ft_string_append(str, "i"); - if (ft_string_cmp(str, "hii") != 0) - return (3); - if (str->length != 3 || str->capacity < 3) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_append_c.c b/libft/tests/ft_string/ft_string/test_append_c.c deleted file mode 100644 index 183f1c4..0000000 --- a/libft/tests/ft_string/ft_string/test_append_c.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_append_c.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:32 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:26:58 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -// second test for ft_string_append_c is to check in case buffer is greater -// than current lenght that char will be indeed appended -int test_string_append_c(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_append_c(str, ' '); - if (ft_string_cmp(str, "Hello ") != 0) - return (1); - if (str->length != 6 || str->capacity < 6) - return (2); - ft_string_destroy(&str); - str = ft_string_from("hi"); - ft_string_append_c(str, 'i'); - if (ft_string_cmp(str, "hii") != 0) - return (3); - if (str->length != 3 || str->capacity < 3) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_append_n.c b/libft/tests/ft_string/ft_string/test_append_n.c deleted file mode 100644 index b26d595..0000000 --- a/libft/tests/ft_string/ft_string/test_append_n.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_append_n.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:05 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:27:16 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_append_n(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_append_n(str, " World", 5); - if (ft_string_cmp(str, "Hello Worl") != 0) - return (1); - if (str->length != 10) - return (2); - if (str->capacity < 10) - return (3); - ft_string_destroy(&str); - str = ft_string_from("hi"); - ft_string_append_n(str, "i", 1); - if (ft_string_cmp(str, "hii") != 0) - return (4); - if (str->length != 3 || str->capacity < 3) - return (5); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_append_s.c b/libft/tests/ft_string/ft_string/test_append_s.c deleted file mode 100644 index 071c7c2..0000000 --- a/libft/tests/ft_string/ft_string/test_append_s.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_append_s.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:56:56 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:27:43 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_append_s(void) -{ - t_string *str; - t_string *str2; - - str = ft_string_from("Hello"); - str2 = ft_string_from(" World"); - ft_string_append_s(str, str2); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11) - return (2); - if (str->capacity < 11) - return (3); - ft_string_destroy(&str); - ft_string_destroy(&str2); - str = ft_string_from("hi"); - str2 = ft_string_from("i"); - ft_string_append_s(str, str2); - if (ft_string_cmp(str, "hii") != 0) - return (4); - if (str->length != 3 || str->capacity < 3) - return (5); - return (ft_string_destroy(&str), ft_string_destroy(&str2), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_append_sn.c b/libft/tests/ft_string/ft_string/test_append_sn.c deleted file mode 100644 index 19c3b95..0000000 --- a/libft/tests/ft_string/ft_string/test_append_sn.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_append_sn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:55:52 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:30:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_append_sn(void) -{ - t_string *str; - t_string *str2; - - str = ft_string_from("Hello"); - str2 = ft_string_from(" World!!!!"); - ft_string_append_s_n(str, str2, 6); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_destroy(&str); - ft_string_destroy(&str2); - str = ft_string_from("hi"); - str2 = ft_string_from("ii"); - ft_string_append_s_n(str, str2, 1); - if (ft_string_cmp(str, "hii") != 0) - return (3); - if (str->length != 3 || str->capacity < 3) - return (4); - return (ft_string_destroy(&str), ft_string_destroy(&str2), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_cap.c b/libft/tests/ft_string/ft_string/test_cap.c deleted file mode 100644 index 50eed55..0000000 --- a/libft/tests/ft_string/ft_string/test_cap.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_cap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_cap(void) -{ - t_string *str; - - str = ft_string_from("Hello world this is zod!"); - if (str->capacity != ft_string_cap(str)) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_chr.c b/libft/tests/ft_string/ft_string/test_chr.c deleted file mode 100644 index 1a31d92..0000000 --- a/libft/tests/ft_string/ft_string/test_chr.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_chr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:35:34 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_chr(void) -{ - t_string *str; - const char c[] = "z!H@\0"; - char *ptr_exp[sizeof(c) / sizeof(c[0])]; - size_t i; - - str = ft_string_from("Hello world this is zod!"); - i = 0; - while (i < sizeof(c) / sizeof(c[0])) - { - ptr_exp[i] = ft_strchr(str->str, c[i]); - if (ft_string_chr(str, c[i]) != ptr_exp[i]) - return (i + 1); - i++; - } - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_clear.c b/libft/tests/ft_string/ft_string/test_clear.c deleted file mode 100644 index aa34cff..0000000 --- a/libft/tests/ft_string/ft_string/test_clear.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_clear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_clear(void) -{ - t_string *str; - size_t capacity; - - str = ft_string_from("Hello"); - capacity = str->capacity; - ft_string_clear(str); - if (ft_string_cmp(str, "") != 0) - return (1); - if (str->length != 0) - return (2); - if (str->capacity != capacity) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_cmp.c b/libft/tests/ft_string/ft_string/test_cmp.c deleted file mode 100644 index 56ce46e..0000000 --- a/libft/tests/ft_string/ft_string/test_cmp.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_cmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:20:23 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_cmp(void) -{ - t_string *str; - - str = ft_string_from("Hello World"); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (ft_string_cmp(str, "Hello Warld!") != 'o' - 'a') - return (2); - if (ft_string_cmp(str, "Hello Wprld!") != 'o' - 'p') - return (3); - if (ft_string_cmp(str, "Hello World!") != '\0' - '!') - return (4); - if (ft_string_cmp(str, "Hell") != 'o' - '\0') - return (5); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_cmp_str.c b/libft/tests/ft_string/ft_string/test_cmp_str.c deleted file mode 100644 index c7c1d4d..0000000 --- a/libft/tests/ft_string/ft_string/test_cmp_str.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_cmp_str.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 11:01:15 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_cmp_str(void) -{ - t_string *str; - t_string *str2; - - str = ft_string_from("Hello"); - str2 = ft_string_from("Hello"); - if (ft_string_cmpstr(str, str2) != 0) - return (1); - ft_string_destroy(&str2); - str2 = ft_string_from("Hello World"); - if (ft_string_cmpstr(str, str2) >= 0) - return (2); - ft_string_destroy(&str2); - str2 = ft_string_from("Hell"); - if (ft_string_cmpstr(str, str2) <= 0) - return (3); - ft_string_destroy(&str); - ft_string_destroy(&str2); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_destroy.c b/libft/tests/ft_string/ft_string/test_destroy.c deleted file mode 100644 index 6240a5a..0000000 --- a/libft/tests/ft_string/ft_string/test_destroy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/25 17:37:36 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -/* - ft_string_destroy(&str); // null resiliancy - ft_string_destroy(NULL); // null resiliancy -*/ -int test_string_destroy(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_destroy(&str); - if (str) - return (1); - ft_string_destroy(&str); - ft_string_destroy(NULL); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_from.c b/libft/tests/ft_string/ft_string/test_from.c deleted file mode 100644 index 81e968d..0000000 --- a/libft/tests/ft_string/ft_string/test_from.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_from.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:35:08 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_from(void) -{ - t_string *str; - - str = ft_string_from("Hello World"); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_destroy(&str); - str = ft_string_from(NULL); - if (str->length != 0 || str->capacity < 1) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_from_c.c b/libft/tests/ft_string/ft_string/test_from_c.c deleted file mode 100644 index 02494d3..0000000 --- a/libft/tests/ft_string/ft_string/test_from_c.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_from_c.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_from_c(void) -{ - t_string *str; - - str = ft_string_from_c('c'); - if (ft_string_cmp(str, "c") != 0) - return (1); - if (str->length != 1) - return (2); - if (str->capacity < 1) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_from_n.c b/libft/tests/ft_string/ft_string/test_from_n.c deleted file mode 100644 index 4fbb1bd..0000000 --- a/libft/tests/ft_string/ft_string/test_from_n.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_from_n.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:36:12 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_from_n(void) -{ - t_string *str; - - str = ft_string_from_n("Hello World", 5); - if (ft_string_cmp(str, "Hello") != 0) - return (1); - if (str->length != 5 || str->capacity < 5) - return (2); - ft_string_destroy(&str); - str = ft_string_from_n(NULL, 5); - if (str->length != 0 || str->capacity < 1) - return (3); - ft_string_destroy(&str); - str = ft_string_from_n("Hello World", 0); - if (str->length != 0 || str->capacity < 1) - return (4); - return (ft_string_destroy(&str), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_from_s.c b/libft/tests/ft_string/ft_string/test_from_s.c deleted file mode 100644 index e64a447..0000000 --- a/libft/tests/ft_string/ft_string/test_from_s.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_from_s.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:38:05 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_from_s(void) -{ - t_string *str; - t_string *str_src; - - str_src = ft_string_from("Hello World"); - str = ft_string_from_s(str_src); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_destroy(&str); - str = ft_string_from_s(NULL); - if (str->length != 0 || str->capacity < 1) - return (3); - return (ft_string_destroy(&str), ft_string_destroy(&str_src), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_from_sn.c b/libft/tests/ft_string/ft_string/test_from_sn.c deleted file mode 100644 index d957359..0000000 --- a/libft/tests/ft_string/ft_string/test_from_sn.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_from_sn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:41:58 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_from_sn(void) -{ - t_string *str; - t_string *str_src; - - str_src = ft_string_from("Hello World"); - str = ft_string_from_s_n(str_src, 5); - if (ft_string_cmp(str, "Hello") != 0) - return (1); - if (str->length != 5) - return (2); - if (str->capacity < 5) - return (3); - ft_string_destroy(&str); - str = ft_string_from_s_n(NULL, 5); - if (str->length != 0 || str->capacity < 1) - return (4); - ft_string_destroy(&str); - str = ft_string_from_s_n(str_src, 0); - if (str->length != 0 || str->capacity < 1) - return (5); - return (ft_string_destroy(&str), ft_string_destroy(&str_src), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_get.c b/libft/tests/ft_string/ft_string/test_get.c deleted file mode 100644 index a24f85e..0000000 --- a/libft/tests/ft_string/ft_string/test_get.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_get.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 06:21:54 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_get(void) -{ - t_string *str; - const char *c_str; - - str = ft_string_from("Hello worlds!"); - c_str = ft_string_get(str); - if (ft_strncmp(str->str, c_str, str->length) != 0) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_insert.c b/libft/tests/ft_string/ft_string/test_insert.c deleted file mode 100644 index 9cdecc2..0000000 --- a/libft/tests/ft_string/ft_string/test_insert.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_insert.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:14:37 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_insert(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_insert(str, " World", 0); - if (ft_string_cmp(str, " WorldHello") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_insert(str, "!", 99); - if (ft_string_cmp(str, " WorldHello!") != 0) - return (3); - if (str->length != 12 || str->capacity < 12) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_insert_c.c b/libft/tests/ft_string/ft_string/test_insert_c.c deleted file mode 100644 index 9e956eb..0000000 --- a/libft/tests/ft_string/ft_string/test_insert_c.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_insert_c.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:15:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_insert_c(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_insert_c(str, ' ', 0); - if (ft_string_cmp(str, " Hello") != 0) - return (1); - if (str->length != 6 || str->capacity < 6) - return (2); - ft_string_insert_c(str, '!', 99); - if (ft_string_cmp(str, " Hello!") != 0) - return (3); - if (str->length != 7 || str->capacity < 7) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_insert_n.c b/libft/tests/ft_string/ft_string/test_insert_n.c deleted file mode 100644 index 2844b1a..0000000 --- a/libft/tests/ft_string/ft_string/test_insert_n.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_insert_n.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:16:00 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_insert_n(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_insert_n(str, " World", 0, 5); - if (ft_string_cmp(str, " WorlHello") != 0) - return (1); - if (str->length != 10 || str->capacity < 10) - return (2); - ft_string_insert_n(str, "!", 99, 1); - if (ft_string_cmp(str, " WorlHello!") != 0) - return (3); - if (str->length != 11 || str->capacity < 11) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_insert_s.c b/libft/tests/ft_string/ft_string/test_insert_s.c deleted file mode 100644 index 772b62f..0000000 --- a/libft/tests/ft_string/ft_string/test_insert_s.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_insert_s.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:18:17 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_insert_s(void) -{ - t_string *str; - t_string *str2; - - str = ft_string_from("Hello"); - str2 = ft_string_from(" World"); - ft_string_insert_s(str, str2, 0); - if (ft_string_cmp(str, " WorldHello") != 0) - return (1); - if (str->length != 11 || str->capacity < 11) - return (2); - ft_string_insert_s(str, str2, 99); - if (ft_string_cmp(str, " WorldHello World") != 0) - return (3); - if (str->length != 17 || str->capacity < 17) - return (4); - ft_string_destroy(&str); - ft_string_destroy(&str2); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_insert_sn.c b/libft/tests/ft_string/ft_string/test_insert_sn.c deleted file mode 100644 index 4c203af..0000000 --- a/libft/tests/ft_string/ft_string/test_insert_sn.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_insert_sn.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:21:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_insert_sn(void) -{ - t_string *str; - t_string *str2; - - str = ft_string_from("Hello"); - str2 = ft_string_from(" World!!!!"); - ft_string_insert_s_n(str, str2, 0, 5); - if (ft_string_cmp(str, " WorlHello") != 0) - return (1); - if (str->length != 10 || str->capacity < 10) - return (2); - ft_string_insert_s_n(str, str2, 99, 1); - if (ft_string_cmp(str, " WorlHello ") != 0) - return (3); - if (str->length != 11 || str->capacity < 11) - return (4); - ft_string_destroy(&str); - ft_string_destroy(&str2); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_len.c b/libft/tests/ft_string/ft_string/test_len.c deleted file mode 100644 index 26a0a95..0000000 --- a/libft/tests/ft_string/ft_string/test_len.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_len.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 06:21:27 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_len(void) -{ - t_string *str; - - str = ft_string_from("Hello worlds!"); - if (ft_string_len(str) != 13) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_ncmp.c b/libft/tests/ft_string/ft_string/test_ncmp.c deleted file mode 100644 index fd4528e..0000000 --- a/libft/tests/ft_string/ft_string/test_ncmp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_ncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:23:02 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_ncmp(void) -{ - t_string *str; - - str = ft_string_from("Hello World"); - if (ft_string_ncmp(str, "Hello World", 11) != 0) - return (1); - if (ft_string_ncmp(str, "Hello_foobar", 5) != 0) - return (2); - if (ft_string_ncmp(str, "Hello World!", 12) == 0) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_ncmp_str.c b/libft/tests/ft_string/ft_string/test_ncmp_str.c deleted file mode 100644 index 839ea7e..0000000 --- a/libft/tests/ft_string/ft_string/test_ncmp_str.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_ncmp_str.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/23 18:29:22 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_ncmp_str(void) -{ - t_string *str; - t_string *str2; - t_string *str3; - t_string *str4; - - str = ft_string_from("Hello World"); - str2 = ft_string_from("Hello Worle"); - str3 = ft_string_from("Hello Worla"); - str4 = ft_string_from("Hello"); - if (ft_string_ncmpstr(str, str2, 10) != 0 || \ - ft_string_ncmpstr(str, str3, 10) != 0) - return (1); - if (ft_string_ncmpstr(str, str2, 11) == 0 || \ - ft_string_ncmpstr(str, str3, 11) == 0 || \ - ft_string_ncmpstr(str3, str, 11) == 0) - return (2); - if (ft_string_ncmpstr(str2, str, 99) == 0 || \ - ft_string_ncmpstr(str3, str4, 9) == 0) - return (6); - return (ft_string_destroy(&str), ft_string_destroy(&str2), - ft_string_destroy(&str3), ft_string_destroy(&str4), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_new.c b/libft/tests/ft_string/ft_string/test_new.c deleted file mode 100644 index 9580e2d..0000000 --- a/libft/tests/ft_string/ft_string/test_new.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 19:34:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_new(void) -{ - t_string *str; - - str = ft_string_new(42); - if (!str->str || str->length != 0 || str->capacity < 42) - return (1); - ft_string_destroy(&str); - str = ft_string_new(0); - if (!str->str || str->length != 0 || str->capacity < 1) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_offset.c b/libft/tests/ft_string/ft_string/test_offset.c deleted file mode 100644 index fb4a119..0000000 --- a/libft/tests/ft_string/ft_string/test_offset.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_offset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 13:31:02 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_offset(void) -{ - t_string *str; - const char *src; - char c; - - src = "Hello world this is zod!"; - str = ft_string_from(src); - c = 'z'; - if (ft_string_offset(str, c) != 20) - return (1); - c = '!'; - if (ft_string_offset(str, c) != 23) - return (2); - c = '@'; - if (ft_string_offset(str, c) != -1) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_put.c b/libft/tests/ft_string/ft_string/test_put.c deleted file mode 100644 index 653d874..0000000 --- a/libft/tests/ft_string/ft_string/test_put.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_put.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 12:45:09 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:27:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -static int normal_cases(void) -{ - t_string *str; - const char *src; - char *res; - int fd; - const char *file = TESTS_FPREFIX "test_string_put.txt"; - - src = "Hello world this is zod!"; - str = ft_string_from(src); - fd = open(file, O_CREAT | O_RDWR | O_TRUNC, 0644); - if (fd == -1) - return (1); - ft_string_put(str, fd); - close(fd); - fd = open(file, O_RDONLY); - if (fd == -1) - return (2); - res = ft_fd_to_buff(fd); - destroy_test_file(fd, file); - if (ft_strcmp(src, res) != 0) - return (3); - return (free(res), ft_string_destroy(&str), 0); -} - -static int error_case(void) -{ - t_string *str; - const int fd = -1; - - str = ft_string_from("Hello"); - if (ft_string_put(str, fd) != -1) - return (1); - if (ft_string_put(NULL, STDOUT_FILENO) != -1) - return (2); - ft_free((void **)&str->str); - if (ft_string_put(str, STDOUT_FILENO) != -1) - return (3); - str->str = NULL; - str->length = 0; - if (ft_string_put(str, STDOUT_FILENO) != 0) - return (4); - return (ft_string_destroy(&str), 0); -} - -int test_string_put(void) -{ - int ret; - - ret = normal_cases(); - if (ret) - return (ret); - ret = error_case(); - if (ret) - return (ret + 10); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_rchr.c b/libft/tests/ft_string/ft_string/test_rchr.c deleted file mode 100644 index 6c15803..0000000 --- a/libft/tests/ft_string/ft_string/test_rchr.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_rchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 10:37:31 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_rchr(void) -{ - t_string *str; - const char c[] = "z!Hol@\0"; - char *ptr_exp[sizeof(c) / sizeof(c[0])]; - size_t i; - - str = ft_string_from("Hello world this is zod!"); - i = 0; - while (i < sizeof(c) / sizeof(c[0])) - { - ptr_exp[i] = ft_strrchr(str->str, c[i]); - if (ft_string_rchr(str, c[i]) != ptr_exp[i]) - return (i + 1); - i++; - } - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_replace.c b/libft/tests/ft_string/ft_string/test_replace.c deleted file mode 100644 index c11a9ba..0000000 --- a/libft/tests/ft_string/ft_string/test_replace.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_replace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 06:21:43 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_replace(void) -{ - t_string *str; - - str = ft_string_from("Hello worlds!"); - ft_string_replace(str, "worlds", "Worlds"); - if (ft_string_cmp(str, "Hello Worlds!")) - return (1); - ft_string_append(str, " Worlds!"); - ft_string_replace(str, "Worlds", "earth"); - if (ft_string_cmp(str, "Hello earth! earth!")) - return (2); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_replace_chr.c b/libft/tests/ft_string/ft_string/test_replace_chr.c deleted file mode 100644 index ead5dd8..0000000 --- a/libft/tests/ft_string/ft_string/test_replace_chr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_replace_chr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 06:21:48 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_replace_chr(void) -{ - t_string *str; - - str = ft_string_from("Hello worlds!"); - ft_string_replace_chr(str, 'o', 'O'); - if (ft_string_cmp(str, "HellO wOrlds!")) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_reserve.c b/libft/tests/ft_string/ft_string/test_reserve.c deleted file mode 100644 index 43de776..0000000 --- a/libft/tests/ft_string/ft_string/test_reserve.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_reserve.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:36:35 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_reserve(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_reserve(str, 42); - if (ft_string_cmp(str, "Hello") != 0) - return (1); - if (str->length != 5 || str->capacity < 42) - return (2); - ft_string_reserve(str, 10); - if (ft_string_cmp(str, "Hello") != 0) - return (3); - if (str->length != 5 || str->capacity < 42) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_resize.c b/libft/tests/ft_string/ft_string/test_resize.c deleted file mode 100644 index 7472d47..0000000 --- a/libft/tests/ft_string/ft_string/test_resize.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_resize.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_resize(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_resize(str, 42); - if (ft_string_cmp(str, "Hello") != 0) - return (1); - if (str->length != 5) - return (2); - if (str->capacity < 42) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_roffset.c b/libft/tests/ft_string/ft_string/test_roffset.c deleted file mode 100644 index fb6f672..0000000 --- a/libft/tests/ft_string/ft_string/test_roffset.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_roffset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 13:28:27 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_roffset(void) -{ - t_string *str; - const char *src; - char c; - - src = "Hello world this is zod!"; - str = ft_string_from(src); - c = 'z'; - if (ft_string_roffset(str, c) != 20) - return (1); - c = '!'; - if (ft_string_roffset(str, c) != 23) - return (2); - c = '@'; - if (ft_string_roffset(str, c) != -1) - return (4); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_set.c b/libft/tests/ft_string/ft_string/test_set.c deleted file mode 100644 index 0685507..0000000 --- a/libft/tests/ft_string/ft_string/test_set.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_set.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 12:50:00 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:39:55 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_string_set(void) -{ - t_string *str; - const char *src; - const char *res; - - src = "Hello world this is zod!"; - str = ft_string_new(0); - ft_string_set(str, src); - res = ft_string_get(str); - if (ft_strcmp(src, res) != 0) - return (1); - ft_string_destroy(&str); - str = ft_string_new(99); - ft_string_set(str, src); - res = ft_string_get(str); - if (ft_strcmp(src, res) != 0) - return (2); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_set_inplace.c b/libft/tests/ft_string/ft_string/test_set_inplace.c deleted file mode 100644 index abfa6c8..0000000 --- a/libft/tests/ft_string/ft_string/test_set_inplace.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_set_inplace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 12:56:27 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:43:09 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_string_set_inplace(void) -{ - t_string *str; - char *src; - const char *res; - - src = ft_strdup("Hello world this is zod!"); - str = ft_string_new(0); - ft_string_set_inplace(str, src); - res = ft_string_get(str); - if (ft_strcmp(src, res) != 0) - return (1); - src = ft_strdup("Hello world this is zod!"); - free(str->str); - str->str = NULL; - ft_string_set_inplace(str, src); - res = ft_string_get(str); - if (ft_strcmp(src, res) != 0) - return (2); - return (ft_string_destroy(&str), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_set_n.c b/libft/tests/ft_string/ft_string/test_set_n.c deleted file mode 100644 index 339b8c3..0000000 --- a/libft/tests/ft_string/ft_string/test_set_n.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_set_n.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/31 12:57:59 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 13:12:45 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" - -int test_string_set_n(void) -{ - t_string *str; - const char *src; - const char *res; - - src = "Hello world this is zod!"; - str = ft_string_new(0); - ft_string_set_n(str, src, 6); - res = ft_string_get(str); - if (ft_strcmp("Hello", res) != 0) - return (1); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_shrink.c b/libft/tests/ft_string/ft_string/test_shrink.c deleted file mode 100644 index a81884e..0000000 --- a/libft/tests/ft_string/ft_string/test_shrink.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_shrink.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/06/03 10:56:52 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_shrink(void) -{ - t_string *str; - - str = ft_string_from("Hello"); - ft_string_shrink(str); - if (ft_string_cmp(str, "Hello") != 0) - return (1); - if (str->length != 5 || str->capacity < 5) - return (2); - ft_string_destroy(&str); - str = ft_string_from("^_^"); - if (str->length != 3 || str->capacity != T_STRING_BUFF) - return (3); - ft_string_shrink(str); - if (ft_string_cmp(str, "^_^") != 0) - return (4); - if (str->length != 3 || str->capacity < 3) - return (5); - ft_string_shrink(str); - if (ft_string_cmp(str, "^_^") != 0) - return (6); - if (str->length != 3 || str->capacity < 3) - return (7); - return (ft_string_destroy(&str), 0); -} diff --git a/libft/tests/ft_string/ft_string/test_substr.c b/libft/tests/ft_string/ft_string/test_substr.c deleted file mode 100644 index a34ea77..0000000 --- a/libft/tests/ft_string/ft_string/test_substr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_substr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:16:12 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_substr(void) -{ - t_string *str; - t_string *sub; - - str = ft_string_from("Hello World"); - sub = ft_string_substr(str, 0, 6); - if (!sub) - return (1); - if (ft_strcmp(sub->str, "Hello") != 0) - return (2); - if (sub->length != 5) - return (3); - if (sub->capacity < 5) - return (4); - ft_strlen(sub->str); - ft_string_destroy(&str); - ft_string_destroy(&sub); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_to_str.c b/libft/tests/ft_string/ft_string/test_to_str.c deleted file mode 100644 index 7964ca0..0000000 --- a/libft/tests/ft_string/ft_string/test_to_str.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* test_to_str.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:16:39 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_to_str(void) -{ - t_string *str; - char *cstr; - - str = ft_string_from("Hello World"); - cstr = ft_string_to_str(str); - if (ft_strcmp(cstr, "Hello World") != 0) - return (1); - ft_string_destroy(&str); - free(cstr); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_trim.c b/libft/tests/ft_string/ft_string/test_trim.c deleted file mode 100644 index d099a9e..0000000 --- a/libft/tests/ft_string/ft_string/test_trim.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_trim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_trim(void) -{ - t_string *str; - - str = ft_string_from(" Hello World "); - ft_string_trim(str); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11) - return (2); - if (str->capacity < 11) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_trim_chr.c b/libft/tests/ft_string/ft_string/test_trim_chr.c deleted file mode 100644 index 1f12dad..0000000 --- a/libft/tests/ft_string/ft_string/test_trim_chr.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_trim_chr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_trim_chr(void) -{ - t_string *str; - - str = ft_string_from(" Hello World "); - ft_string_trim_chr(str, ' '); - if (ft_string_cmp(str, "Hello World") != 0) - return (1); - if (str->length != 11) - return (2); - if (str->capacity < 11) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/ft_string/test_trimstr.c b/libft/tests/ft_string/ft_string/test_trimstr.c deleted file mode 100644 index fa7b2fe..0000000 --- a/libft/tests/ft_string/ft_string/test_trimstr.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_t_str_trimstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_string_types.h" - -int test_string_trimstr(void) -{ - t_string *str; - - str = ft_string_from(" Hello World "); - ft_string_trimstr(str, " d"); - if (ft_string_cmp(str, "Hello Worl") != 0) - return (1); - if (str->length != 10) - return (2); - if (str->capacity < 10) - return (3); - ft_string_destroy(&str); - return (0); -} diff --git a/libft/tests/ft_string/string_tests.c b/libft/tests/ft_string/string_tests.c deleted file mode 100644 index a2d05b0..0000000 --- a/libft/tests/ft_string/string_tests.c +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* string_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/30 13:36:16 by bgoulard #+# #+# */ -/* Updated: 2024/06/26 19:26:02 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -int t_string_tests(void); -int mem_tests(void); -int str_tests(void); -int char_tests(void); - -static const t_test *load_submodules_tests(void) -{ - static const t_test tests[] = { - {"mem", mem_tests}, - {"str", str_tests}, - {"char", char_tests}, - {"t_string", t_string_tests}, - {NULL, NULL} - }; - - return (tests); -} - -int tests_string(void) -{ - size_t i; - int collect; - int prev; - const t_test *tests = load_submodules_tests(); - - i = 0; - collect = 0; - while (tests[i].name) - { - prev = collect; - ft_putendl_fd("\nTesting::", STDOUT_FILENO); - ft_putendl_fd(tests[i].name, STDOUT_FILENO); - collect += tests[i++].test(); - ft_putstr_fd("\nTesting sub-module ", STDOUT_FILENO); - ft_putstr_fd(tests[i - 1].name, STDOUT_FILENO); - if (prev != collect) - ft_putendl_fd(" \033[31mKO\033[0m", STDOUT_FILENO); - else - ft_putendl_fd(" \033[32mOK\033[0m", STDOUT_FILENO); - } - return (collect); -} diff --git a/libft/tests/ft_vector/tests_vec_add.c b/libft/tests/ft_vector/tests_vec_add.c deleted file mode 100644 index 4b499ed..0000000 --- a/libft/tests/ft_vector/tests_vec_add.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_add.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:13:02 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:13:07 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_add(void) -{ - t_vector *vec; - - vec = ft_vec_new(); - ft_vec_add(&vec, (void *)42); - if (vec->count != 1) - return (1); - if (vec->datas[0] != (void *)42) - return (1); - ft_vec_add(&vec, (void *)43); - ft_vec_add(&vec, (void *)44); - ft_vec_add(&vec, (void *)45); - ft_vec_add(&vec, (void *)46); - ft_vec_add(&vec, (void *)47); - if (vec->count != 6) - return (1); - if (vec->datas[0] != (void *)42 || vec->datas[1] != (void *)43 || \ - vec->datas[2] != (void *)44 || vec->datas[3] != (void *)45 || \ - vec->datas[4] != (void *)46 || vec->datas[5] != (void *)47) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_apply.c b/libft/tests/ft_vector/tests_vec_apply.c deleted file mode 100644 index 36adc99..0000000 --- a/libft/tests/ft_vector/tests_vec_apply.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_apply.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:13:11 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 17:13:35 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include "tests/tests_lambda_functions.h" - -int test_vec_apply(void) -{ - t_vector *vec; - int i; - - i = 0; - vec = ft_vec_new(); - ft_vec_add(&vec, &i); - ft_vec_apply(vec, add42); - if (*(int *)vec->datas[0] != 42) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_at.c b/libft/tests/ft_vector/tests_vec_at.c deleted file mode 100644 index 2200f4d..0000000 --- a/libft/tests/ft_vector/tests_vec_at.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_at.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:22:41 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 20:44:28 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_at(void) -{ - t_vector *vec; - int a; - int b; - int c; - - a = 0; - b = 1; - c = 2; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - if (*(int *)ft_vec_at(vec, 0) != 0) - return (1); - else if (*(int *)ft_vec_at(vec, 1) != 1) - return (1); - else if (*(int *)ft_vec_at(vec, 2) != 2) - return (1); - else if (ft_vec_at(vec, 3)) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_cat.c b/libft/tests/ft_vector/tests_vec_cat.c deleted file mode 100644 index 48cfa63..0000000 --- a/libft/tests/ft_vector/tests_vec_cat.c +++ /dev/null @@ -1,70 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_cat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:15:21 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:11:59 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include - -/* - ft_vec_add(&vec_a, &a); // 42 - ft_vec_add(&vec_a, &b); // 42 43 - ft_vec_add(&vec_a, &c); // 42 43 44 - ft_vec_add(&vec_b, &d); // 45 - ft_vec_add(&vec_b, &e); // 45 46 - ft_vec_add(&vec_b, &f); // 45 46 47 - ret = ft_vec_cat(&vec_a, vec_b); // 42 43 44 + 45 46 47 - ft_vec_add(&vec_a, &a); // 42 - ft_vec_add(&vec_a, &b); // 42 43 - ft_vec_add(&vec_a, &c); // 42 43 44 - ret = ft_vec_cat(&vec_a, vec_b); // 42 43 44 + 45 46 47 -*/ - -void init_vec_cat(t_vector **vec_a, t_vector **vec_b) -{ - *vec_a = ft_vec_from_size(6); - ft_vec_add(vec_a, (void *)42); - ft_vec_add(vec_a, (void *)43); - ft_vec_add(vec_a, (void *)44); - *vec_b = ft_vec_new(); - ft_vec_add(vec_b, (void *)45); - ft_vec_add(vec_b, (void *)46); - ft_vec_add(vec_b, (void *)47); -} - -int test_vec_cat(void) -{ - bool ret; - t_vector *vec_a; - t_vector *vec_b; - - init_vec_cat(&vec_a, &vec_b); - ret = ft_vec_cat(&vec_a, vec_b); - if (ret != true || vec_a->count != 6) - return (1); - else if (ft_vec_at(vec_a, 0) != (void *)42 || ft_vec_at(vec_a, 1) != \ - (void *)43 || ft_vec_at(vec_a, 2) != (void *)44 || ft_vec_at(vec_a, 3) != \ - (void *)45 || ft_vec_at(vec_a, 4) != (void *)46 || ft_vec_at(vec_a, 5) != \ - (void *)47) - return (2); - ft_vec_destroy(&vec_a); - vec_a = ft_vec_new(); - ft_vec_add(&vec_a, (void *)42); - ft_vec_add(&vec_a, (void *)43); - ft_vec_add(&vec_a, (void *)44); - ret = ft_vec_cat(&vec_a, vec_b); - if (ret != false || vec_a->count != 3) - return (3); - else if (ft_vec_at(vec_a, 0) != (void *)42 || ft_vec_at(vec_a, 1) != \ - (void *)43 || ft_vec_at(vec_a, 2) != (void *)44) - return (4); - return (ft_vec_destroy(&vec_a), ft_vec_destroy(&vec_b), 0); -} diff --git a/libft/tests/ft_vector/tests_vec_clear.c b/libft/tests/ft_vector/tests_vec_clear.c deleted file mode 100644 index 7f9592f..0000000 --- a/libft/tests/ft_vector/tests_vec_clear.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_clear.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:21:55 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:05:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_clear(void) -{ - t_vector *vec; - int a; - int b; - int c; - - a = 0; - b = 1; - c = 2; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - ft_vec_clear(vec); - if (vec->count != 0) - return (1); - else if (vec->cappacity == 0) - return (1); - else if (vec->datas[0]) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_convert_alloc_array.c b/libft/tests/ft_vector/tests_vec_convert_alloc_array.c deleted file mode 100644 index ad7c6be..0000000 --- a/libft/tests/ft_vector/tests_vec_convert_alloc_array.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_convert_alloc_array.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:30:26 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:32:32 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include - -// ft_vec_destroy(&vec); - // free(data); -> segfault : double free or corruption. - // ft_vec_convert_alloccarray takes ownership of the data. refert to the - // doc. - -int test_vec_convert_alloc_array(void) -{ - void **data; - t_vector *vec; - int arr[3]; - - arr[0] = 42; - arr[1] = 43; - arr[2] = 44; - data = malloc(sizeof(void *) * 3); - data[0] = (void *)&arr[0]; - data[1] = (void *)&arr[1]; - data[2] = (void *)&arr[2]; - vec = ft_vec_convert_alloccarray(data, 3); - if (vec->count != 3 || vec->cappacity != 3 || vec->datas != data) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 42 || *(int *)ft_vec_at(vec, 1) != \ - 43 || *(int *)ft_vec_at(vec, 2) != 44) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_destroy.c b/libft/tests/ft_vector/tests_vec_destroy.c deleted file mode 100644 index 3533f1f..0000000 --- a/libft/tests/ft_vector/tests_vec_destroy.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_destroy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:20:58 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:20:59 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_destroy(void) -{ - t_vector *vec; - int a; - int b; - int c; - - a = 0; - b = 1; - c = 2; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - ft_vec_destroy(&vec); - if (vec) - return (1); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_filter.c b/libft/tests/ft_vector/tests_vec_filter.c deleted file mode 100644 index 2809f41..0000000 --- a/libft/tests/ft_vector/tests_vec_filter.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_filter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:20:40 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:29:04 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include "tests/tests_lambda_functions.h" -#include - -int test_vec_filter(void) -{ - const int arr[3] = {21, 42, 63}; - t_vector *vec; - int *pp[3]; - - vec = ft_vec_new(); - ft_vec_add(&vec, (void *)&arr[0]); - ft_vec_add(&vec, (void *)&arr[1]); - ft_vec_add(&vec, (void *)&arr[2]); - ft_vec_filter(vec, is42, NULL); - if (vec->count != 1 || *(int *)ft_vec_at(vec, 0) != 42) - return (1); - ft_vec_clear(vec); - pp[0] = malloc(sizeof(int)); - *pp[0] = 21; - pp[1] = malloc(sizeof(int)); - *pp[1] = 42; - pp[2] = malloc(sizeof(int)); - *pp[2] = 63; - ft_vec_add(&vec, pp[0]); - ft_vec_add(&vec, pp[1]); - ft_vec_add(&vec, pp[2]); - ft_vec_filter(vec, is42, free); - if (vec->count != 1 || ft_vec_at(vec, 0) != pp[1]) - return (1); - return (ft_vec_apply(vec, free), ft_vec_destroy(&vec), 0); -} diff --git a/libft/tests/ft_vector/tests_vec_from_array.c b/libft/tests/ft_vector/tests_vec_from_array.c deleted file mode 100644 index b7af6da..0000000 --- a/libft/tests/ft_vector/tests_vec_from_array.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_from_array.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:19:37 by bgoulard #+# #+# */ -/* Updated: 2024/05/28 08:04:26 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int checks_01(t_vector *vec, void **data) -{ - if (vec->count != 3 || vec->cappacity != FT_VECTOR_BASE_LEN - || !vec->datas) - return (1); - else if (ft_vec_at(vec, 0) != data[0] || ft_vec_at(vec, 1) != data[1] - || ft_vec_at(vec, 2) != data[2]) - return (2); - return (0); -} - -int checks_02(t_vector *vec, void **data) -{ - if (vec->count != 6 || vec->cappacity != 6 || !vec->datas) - return (3); - else if (ft_vec_at(vec, 0) != data[0] || ft_vec_at(vec, 1) != data[1] - || ft_vec_at(vec, 2) != data[2] || ft_vec_at(vec, 3) != data[3] - || ft_vec_at(vec, 4) != data[4] || ft_vec_at(vec, 5) != data[5]) - return (4); - return (0); -} - -int test_vec_from_array(void) -{ - void *data[3]; - void *data2[6]; - t_vector *vec; - - data[0] = (void *)12; - data[1] = (void *)13; - data[2] = (void *)14; - data2[0] = (void *)20; - data2[1] = (void *)21; - data2[2] = (void *)22; - data2[3] = (void *)23; - data2[4] = (void *)24; - data2[5] = (void *)25; - vec = ft_vec_from_array(data, sizeof(data) / sizeof(data[0])); - if (checks_01(vec, data)) - return (checks_01(vec, data)); - ft_vec_destroy(&vec); - vec = ft_vec_from_array(data2, sizeof(data2) / sizeof(*data2)); - if (checks_02(vec, data2)) - return (checks_02(vec, data2)); - return (ft_vec_destroy(&vec), 0); -} diff --git a/libft/tests/ft_vector/tests_vec_from_size.c b/libft/tests/ft_vector/tests_vec_from_size.c deleted file mode 100644 index 7c9420a..0000000 --- a/libft/tests/ft_vector/tests_vec_from_size.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_from_size.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:20:00 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:20:03 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_from_size(void) -{ - t_vector *vec; - - vec = ft_vec_from_size(42); - if (vec->count != 0) - return (1); - else if (vec->cappacity != 42) - return (1); - else if (!vec->datas) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_get.c b/libft/tests/ft_vector/tests_vec_get.c deleted file mode 100644 index e1eb031..0000000 --- a/libft/tests/ft_vector/tests_vec_get.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_get.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 11:25:01 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:41:24 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_vector.h" - -static int cmp_fun(const void *v_data, const void *key) -{ - return (ft_strcmp(v_data, key)); -} - -int test_vec_get(void) -{ - t_vector *vector; - void *data_ret; - - vector = ft_vec_new(); - ft_vec_add(&vector, "Hello"); - ft_vec_add(&vector, "world"); - ft_vec_add(&vector, "this"); - ft_vec_add(&vector, "is"); - ft_vec_add(&vector, "Zod"); - data_ret = ft_vec_get(vector, "world", cmp_fun); - if (ft_strcmp(data_ret, "world") != 0) - return (1); - data_ret = ft_vec_get(vector, "Zod", cmp_fun); - if (ft_strcmp(data_ret, "Zod") != 0) - return (1); - data_ret = ft_vec_get(vector, "not here", cmp_fun); - if (data_ret) - return (1); - ft_vec_destroy(&vector); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_map.c b/libft/tests/ft_vector/tests_vec_map.c deleted file mode 100644 index 0aa7ccc..0000000 --- a/libft/tests/ft_vector/tests_vec_map.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_map.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:21:45 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:12:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include "tests/tests_lambda_functions.h" -#include - -int test_vec_map(void) -{ - t_vector *vec; - t_vector *ret; - int **arr; - - arr = (int **)creat_tb(); - vec = ft_vec_from_array((void **)arr, 3); - ret = ft_vec_map(vec, add42_ret); - if (ret->count != 3) - return (1); - else if (*(int *)ft_vec_at(ret, 0) != 84 || *(int *)ft_vec_at(ret, 1) != 85 - || *(int *)ft_vec_at(ret, 2) != 86) - return (2); - ft_vec_apply(ret, free); - ft_vec_destroy(&vec); - ft_vec_destroy(&ret); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_new.c b/libft/tests/ft_vector/tests_vec_new.c deleted file mode 100644 index a023a34..0000000 --- a/libft/tests/ft_vector/tests_vec_new.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:21:20 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 20:44:14 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_new(void) -{ - t_vector *vec; - - vec = ft_vec_new(); - if (vec->count != 0) - return (1); - else if (vec->cappacity != FT_VECTOR_BASE_LEN) - return (1); - else if (!vec->datas) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_pop.c b/libft/tests/ft_vector/tests_vec_pop.c deleted file mode 100644 index 303bf2a..0000000 --- a/libft/tests/ft_vector/tests_vec_pop.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_pop.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/06/01 13:47:14 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 13:56:27 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_vector.h" -#include - -int test_vec_pop(void) -{ - t_vector *vec; - const char *str; - - vec = ft_vec_new(); - ft_vec_add(&vec, "value1"); - ft_vec_add(&vec, "value2"); - ft_vec_add(&vec, "value3"); - str = ft_vec_pop(vec); - if (!str || ft_strcmp(str, "value3") != 0 || vec->count != 2) - return (1); - str = ft_vec_pop(vec); - if (!str || ft_strcmp(str, "value2") != 0 || vec->count != 1) - return (2); - str = ft_vec_pop(vec); - if (!str || ft_strcmp(str, "value1") != 0 || vec->count != 0) - return (3); - str = ft_vec_pop(vec); - if (str) - return (4); - return (ft_vec_destroy(&vec), 0); -} diff --git a/libft/tests/ft_vector/tests_vec_remove.c b/libft/tests/ft_vector/tests_vec_remove.c deleted file mode 100644 index fef15b8..0000000 --- a/libft/tests/ft_vector/tests_vec_remove.c +++ /dev/null @@ -1,71 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_remove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/25 10:13:12 by bgoulard #+# #+# */ -/* Updated: 2024/05/31 15:55:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include - -// tests vector has removed the arr[2]orrect element -// and -// tests vector_remove is bound checked with 42's call -static int checks_01(t_vector *vec) -{ - if (vec->count != 2) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 42 || \ - *(int *)ft_vec_at(vec, 1) != 44) - return (2); - ft_vec_remove(vec, 42, NULL); - if (vec->count != 2) - return (3); - return (0); -} - -// tests vector_remove calls free on the correct element -static int checks_02(t_vector *vec, const int *arr) -{ - if (vec->count != 2) - return (1); - if (*(int *)ft_vec_at(vec, 0) != arr[0] || *(int *)ft_vec_at(vec, 1) != \ - arr[2]) - return (1); - return (0); -} - -int test_vec_remove(void) -{ - t_vector *vec; - const int arr[3] = {42, 43, 44}; - int *ptr; - size_t i; - - i = 0; - vec = ft_vec_new(); - ft_vec_add(&vec, (void *)&arr[0]); - ft_vec_add(&vec, (void *)&arr[1]); - ft_vec_add(&vec, (void *)&arr[2]); - ft_vec_remove(vec, 1, NULL); - if (checks_01(vec)) - return (checks_01(vec)); - ft_vec_destroy(&vec); - vec = ft_vec_new(); - while (i < 3) - { - ptr = (int *)malloc(sizeof(int)); - *ptr = arr[i++]; - ft_vec_add(&vec, (void *)ptr); - } - ft_vec_remove(vec, 1, free); - if (checks_02(vec, arr)) - return (checks_02(vec, arr)); - return (ft_vec_apply(vec, free), ft_vec_destroy(&vec), 0); -} diff --git a/libft/tests/ft_vector/tests_vec_remove_if.c b/libft/tests/ft_vector/tests_vec_remove_if.c deleted file mode 100644 index 61aeec4..0000000 --- a/libft/tests/ft_vector/tests_vec_remove_if.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_remove_if.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:30:26 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:51:57 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include "tests/tests_lambda_functions.h" - -int test_vec_remove_if(void) -{ - t_vector *vec; - int a; - int b; - int c; - - a = 42; - b = 43; - c = 44; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - ft_vec_remove_if(vec, is42, NULL); - if (vec->count != 2) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 43) - return (1); - else if (*(int *)ft_vec_at(vec, 1) != 44) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_reserve.c b/libft/tests/ft_vector/tests_vec_reserve.c deleted file mode 100644 index fff26f0..0000000 --- a/libft/tests/ft_vector/tests_vec_reserve.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_reserve.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:28:57 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:30:10 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_reserve(void) -{ - t_vector *vec; - bool ret[3]; - - vec = ft_vec_from_size(FT_VECTOR_BASE_LEN - 1); - ret[0] = ft_vec_reserve(&vec, FT_VECTOR_BASE_LEN - 2); - ret[1] = ft_vec_reserve(&vec, FT_VECTOR_BASE_LEN); - ret[2] = ft_vec_reserve(&vec, FT_VECTOR_BASE_LEN + 2); - if (ret[0] != true) - return (1); - else if (ret[1] != true) - return (1); - else if (ret[2] == false) - return (1); - else if (vec->cappacity != FT_VECTOR_BASE_LEN + 2) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_reverse.c b/libft/tests/ft_vector/tests_vec_reverse.c deleted file mode 100644 index 39d1e48..0000000 --- a/libft/tests/ft_vector/tests_vec_reverse.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_reverse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:30:26 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:30:33 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_reverse(void) -{ - t_vector *vec; - int a; - int b; - int c; - - a = 42; - b = 43; - c = 44; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - ft_vec_shrink(vec); - ft_vec_reverse(vec); - if (vec->count != 3) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 44) - return (1); - else if (*(int *)ft_vec_at(vec, 1) != 43) - return (1); - else if (*(int *)ft_vec_at(vec, 2) != 42) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_shift.c b/libft/tests/ft_vector/tests_vec_shift.c deleted file mode 100644 index 92e459c..0000000 --- a/libft/tests/ft_vector/tests_vec_shift.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_shift.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:28:19 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 11:28:35 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_shift(void) -{ - t_vector *vec; - int a; - int b; - int c; - int d; - - a = 42; - b = 43; - c = 44; - d = 45; - vec = ft_vec_new(); - ft_vec_add(&vec, &a); - ft_vec_add(&vec, &b); - ft_vec_add(&vec, &c); - ft_vec_add(&vec, &d); - ft_vec_shift(vec, 1, 2); - if (vec->count != 2) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 42) - return (1); - else if (*(int *)ft_vec_at(vec, 1) != 45) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_shrink.c b/libft/tests/ft_vector/tests_vec_shrink.c deleted file mode 100644 index 3dcee44..0000000 --- a/libft/tests/ft_vector/tests_vec_shrink.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_shrink.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:28:19 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 20:43:58 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -/* -// try to shrink an already shrunk vector - ft_vec_shrink(vec); -*/ - -int test_vec_shrink(void) -{ - t_vector *vec; - void *data[3]; - int numbers[3]; - - numbers[0] = 42; - numbers[1] = 43; - numbers[2] = 44; - data[0] = (void *)&numbers[0]; - data[1] = (void *)&numbers[1]; - data[2] = (void *)&numbers[2]; - vec = ft_vec_from_array(data, sizeof(data) / sizeof(data[0])); - ft_vec_shrink(vec); - if (vec->count != 3 || vec->cappacity != 3) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 42 || *(int *)ft_vec_at(vec, 1) != \ - 43 || *(int *)ft_vec_at(vec, 2) != 44) - return (1); - ft_vec_shrink(vec); - if (!vec || !vec->datas || !vec->cappacity || !vec->count || \ - vec->count != vec->cappacity || vec->count != 3) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_sort.c b/libft/tests/ft_vector/tests_vec_sort.c deleted file mode 100644 index a7fc0c0..0000000 --- a/libft/tests/ft_vector/tests_vec_sort.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_sort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:27:57 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:04:49 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" -#include "tests/tests_lambda_functions.h" - -int test_vec_sort(void) -{ - t_vector *vec; - int nbrs[3]; - - nbrs[0] = 44; - vec = ft_vec_new(); - ft_vec_add(&vec, (void *)&nbrs[0]); - nbrs[1] = 43; - ft_vec_add(&vec, (void *)&nbrs[1]); - nbrs[2] = 42; - ft_vec_add(&vec, (void *)&nbrs[2]); - ft_vec_sort(vec, cmp_int); - if (vec->count != 3) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 42) - return (2); - else if (*(int *)ft_vec_at(vec, 1) != 43) - return (3); - else if (*(int *)ft_vec_at(vec, 2) != 44) - return (4); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_swap.c b/libft/tests/ft_vector/tests_vec_swap.c deleted file mode 100644 index 3a629bc..0000000 --- a/libft/tests/ft_vector/tests_vec_swap.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_swap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:27:24 by bgoulard #+# #+# */ -/* Updated: 2024/05/24 21:18:13 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vector.h" -#include "ft_vector_types.h" - -int test_vec_swap(void) -{ - t_vector *vec; - void *data[3]; - int arr[3]; - - arr[0] = 42; - arr[1] = 43; - arr[2] = 44; - data[0] = (void *)&arr[0]; - data[1] = (void *)&arr[1]; - data[2] = (void *)&arr[2]; - vec = ft_vec_from_array(data, sizeof(data) / sizeof(data[0])); - ft_vec_swap(vec, 0, 2); - if (vec->count != 3) - return (1); - else if (*(int *)ft_vec_at(vec, 0) != 44) - return (1); - else if (*(int *)ft_vec_at(vec, 1) != 43) - return (1); - else if (*(int *)ft_vec_at(vec, 2) != 42) - return (1); - ft_vec_destroy(&vec); - return (0); -} diff --git a/libft/tests/ft_vector/tests_vec_to_array.c b/libft/tests/ft_vector/tests_vec_to_array.c deleted file mode 100644 index a616572..0000000 --- a/libft/tests/ft_vector/tests_vec_to_array.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_vec_to_array.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/30 11:35:25 by bgoulard #+# #+# */ -/* Updated: 2024/05/30 11:41:05 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "ft_vector.h" - -int test_vec_to_array(void) -{ - t_vector *vector; - const char **array; - - vector = ft_vec_new(); - ft_vec_add(&vector, "Hello"); - ft_vec_add(&vector, "world"); - ft_vec_add(&vector, "this"); - ft_vec_add(&vector, "is"); - ft_vec_add(&vector, "Zod"); - array = (const char **)ft_vec_to_array(&vector); - if (ft_strcmp(array[0], "Hello") != 0) - return (1); - if (ft_strcmp(array[1], "world") != 0) - return (1); - if (ft_strcmp(array[2], "this") != 0) - return (1); - if (ft_strcmp(array[3], "is") != 0) - return (1); - if (ft_strcmp(array[4], "Zod") != 0) - return (1); - free(array); - return (0); -} diff --git a/libft/tests/ft_vector/vector_tests.c b/libft/tests/ft_vector/vector_tests.c deleted file mode 100644 index 999f9fc..0000000 --- a/libft/tests/ft_vector/vector_tests.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* vector_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/13 08:30:25 by bgoulard #+# #+# */ -/* Updated: 2024/06/02 11:33:20 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "tests/tests.h" -#include "tests/vector_tests.h" - -int tests_vector(void) -{ - int collect; - const t_test tests[] = { - {"add", test_vec_add}, {"apply", test_vec_apply}, {"at", test_vec_at}, \ - {"cat", test_vec_cat}, {"clear", test_vec_clear}, \ - {"destroy", test_vec_destroy}, {"filter", test_vec_filter}, \ - {"map", test_vec_map}, {"new", test_vec_new}, {"pop", test_vec_pop}, \ - {"from_size", test_vec_from_size}, {"from_array", test_vec_from_array}, \ - {"convert_alloc_array", test_vec_convert_alloc_array}, \ - {"remove", test_vec_remove}, {"remove_if", test_vec_remove_if}, \ - {"reserve", test_vec_reserve}, {"reverse", test_vec_reverse}, \ - {"shift", test_vec_shift}, {"sort", test_vec_sort}, \ - {"shrink", test_vec_shrink}, {"swap", test_vec_swap}, \ - {"get", test_vec_get}, {"to_array", test_vec_to_array}, \ - {NULL, NULL} - }; - - collect = 0; - run_test(tests, &collect); - return (collect); -} diff --git a/libft/tests/lambdas_for_tests.c b/libft/tests/lambdas_for_tests.c deleted file mode 100644 index 6742799..0000000 --- a/libft/tests/lambdas_for_tests.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lambdas_for_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/24 11:08:37 by bgoulard #+# #+# */ -/* Updated: 2024/05/29 00:03:50 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include - -void **creat_tb(void) -{ - static int a; - static int b; - static int c; - static int *tab[3] = {0}; - - a = 42; - b = 43; - c = 44; - tab[0] = &a; - tab[1] = &b; - tab[2] = &c; - return ((void **)tab); -} - -void add42(void *data) -{ - int *ptr; - - ptr = (int *)data; - *ptr += 42; -} - -bool is42(const void *data) -{ - if (!data) - return (false); - return (*(int *)data == 42); -} - -void *add42_ret(const void *data) -{ - int *ret; - - ret = malloc(sizeof(int)); - *ret = *(int *)data; - *ret += 42; - return ((void *)ret); -} - -int cmp_int(const void *a, const void *b) -{ - return (*(int *)a - *(int *)b); -} diff --git a/libft/tests/main_tests.c b/libft/tests/main_tests.c deleted file mode 100644 index f92bdae..0000000 --- a/libft/tests/main_tests.c +++ /dev/null @@ -1,67 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* main_tests.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/12 20:33:46 by iron #+# #+# */ -/* Updated: 2024/07/06 16:23:30 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" - -const t_test *get_tests(void) -{ - static const t_test tests[] = { - {"string", tests_string}, - {"vec", tests_vector}, - {"map", tests_map}, - {"simply linked lists", tests_linked_list_all}, - {"doubly linked lists", tests_doubly_linked_list_all}, - {"optional", tests_optional}, - {"args", tests_args}, - {"math", tests_math}, - {"pair", tests_pair}, - {NULL, NULL} - }; - - return (tests); -} - -static int exit_msg(int collect) -{ - if (collect == 0) - ft_putendl_fd("\033[32mAll tests passed\033[0m", STDOUT_FILENO); - else - ft_putendl_fd("\033[31mSome tests failed\033[0m", STDOUT_FILENO); - return (collect != 0); -} - -int main(void) -{ - int collect; - int prev; - size_t i; - const t_test *tests = get_tests(); - - i = 0; - collect = 0; - while (tests[i].name) - { - prev = collect; - ft_putstr_fd("\n\nTesting ", STDOUT_FILENO); - ft_putendl_fd(tests[i].name, STDOUT_FILENO); - collect += tests[i].test(); - ft_putstr_fd("\nModule:: ", STDOUT_FILENO); - ft_putstr_fd(tests[i].name, STDOUT_FILENO); - if (collect == prev) - ft_putstr_fd(" \033[32mOK\033[0m\n", STDOUT_FILENO); - else - ft_putstr_fd(" \033[31mKO\033[0m\n", STDOUT_FILENO); - i++; - } - return (exit_msg(collect)); -} diff --git a/libft/tests/tests_utils.c b/libft/tests/tests_utils.c deleted file mode 100644 index b24a9df..0000000 --- a/libft/tests/tests_utils.c +++ /dev/null @@ -1,111 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tests_utils.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bgoulard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/01/05 04:18:57 by bgoulard #+# #+# */ -/* Updated: 2024/06/01 12:12:53 by bgoulard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_string.h" -#include "tests/tests.h" -#include -#include -#include - -#ifdef FORK_TESTS - -static int run_t_test(t_test test, int *collect) -{ - int ret; - int pid; - - pid = fork(); - if (pid == 0) - exit(test.test()); - else - { - waitpid(pid, &ret, 0); - ft_putstr_fd(test.name, STDOUT_FILENO); - if (WIFEXITED(ret) && ret == 0) - ft_putstr_fd(" \033[32mOK \033[0m", STDOUT_FILENO); - else - { - ft_putstr_fd(" \033[31mKO\033[0m ret::", STDOUT_FILENO); - if (WIFEXITED(ret)) - ft_putnbr_fd(WEXITSTATUS(ret), STDOUT_FILENO); - else - ft_putstr_fd("crash", STDOUT_FILENO); - } - ft_putstr_fd("\n", STDOUT_FILENO); - *collect += ret; - } - return (ret); -} - -#else - -static int run_t_test(t_test test, int *collect) -{ - int ret; - - ret = test.test(); - *collect += ret; - if (ret != 0) - { - ft_putstr_fd(test.name, STDOUT_FILENO); - ft_putstr_fd(" \033[31mKO\033[0m ret::", STDOUT_FILENO); - ft_putnbr_fd(ret, STDOUT_FILENO); - ft_putstr_fd("\n", STDOUT_FILENO); - } - else - ft_putstr_fd(" \033[32mOK\033[0m", STDOUT_FILENO); - return (ret); -} - -#endif - -int open_test_file(char **func_to_test) -{ - char *file; - int fd; - - file = ft_strjoin(TESTS_FPREFIX, *func_to_test); - fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - { - ft_putstr_fd("Error: on oppening ", STDERR_FILENO); - ft_putstr_fd(file, STDERR_FILENO); - return (free(file), -1); - } - *func_to_test = file; - return (fd); -} - -void destroy_test_file(int fd, const char *file) -{ - close(fd); - unlink(file); -} - -int run_test(const t_test *test, int *collect) -{ - size_t i; - int ret; - int sum; - - ret = 0; - sum = 0; - i = 0; - while (test[i].name) - { - ret = run_t_test(test[i], &sum); - *collect += ret; - sum += ret; - i++; - } - return (sum); -} diff --git a/maps/valid_01.cub b/maps/valid_01.cub index eba4ccc..dba1964 100644 --- a/maps/valid_01.cub +++ b/maps/valid_01.cub @@ -1,7 +1,7 @@ -SO ./textures/b.xpm -NO ./textures/wasteland_32.xpm -WE ./textures/sandy_32.xpm -EA ./textures/cobblestone_32.xpm +SO ./textures/chiseled_tuff.xpm +NO ./textures/chiseled_tuff_bricks.xpm +WE ./textures/chiseled_stone_bricks.xpm +EA ./textures/chiseled_tuff_bricks_top.xpm F 0,255,0 C 0,255,255 diff --git a/textures/a.xpm b/textures/a.xpm deleted file mode 100644 index 5d7ac8c..0000000 --- a/textures/a.xpm +++ /dev/null @@ -1,154 +0,0 @@ -/* XPM */ -static char *_cb59dce4f574e3bd6a1e2f025c0312agi1mGDihwOOx8j7A[] = { -/* columns rows colors chars-per-pixel */ -"32 32 116 2 ", -" c #100F10", -". c #161515", -"X c #191717", -"o c #191718", -"O c #1E1C1C", -"+ c #211E1E", -"@ c #252222", -"# c #292626", -"$ c #2D2B2B", -"% c #322E2E", -"& c #3A2F2E", -"* c #36302F", -"= c #3C312E", -"- c #342F30", -"; c #353131", -": c #3A3434", -"> c #3D3836", -", c #3C3738", -"< c #3E3A3A", -"1 c #43332F", -"2 c #433534", -"3 c #4C3633", -"4 c #433A36", -"5 c #4C3937", -"6 c #433C3B", -"7 c #4B3D3B", -"8 c #503835", -"9 c #523D3C", -"0 c #46413E", -"q c #4B433D", -"w c #524433", -"e c #55443B", -"r c #453F41", -"t c #563D40", -"y c #474141", -"u c #4B4442", -"i c #4E4845", -"p c #4F4949", -"a c #544442", -"s c #584644", -"d c #534A42", -"f c #5A4A46", -"g c #554D4B", -"h c #5C4D4C", -"j c #545146", -"k c #56514C", -"l c #5B524D", -"z c #5D5552", -"x c #5F5A53", -"c c #614D46", -"v c #61534D", -"b c #625D4C", -"n c #625553", -"m c #635A53", -"M c #655B59", -"N c #695D5A", -"B c #636052", -"V c #696354", -"C c #6E6852", -"Z c #66615A", -"A c #6B625D", -"S c #6D695B", -"D c #70675F", -"F c #736A5D", -"G c #6C6360", -"H c #6B6463", -"J c #6F6563", -"K c #6D6865", -"L c #706763", -"P c #726766", -"I c #716A62", -"U c #726A63", -"Y c #756D63", -"T c #746A64", -"R c #786B66", -"E c #786D66", -"W c #716A68", -"Q c #746B69", -"! c #776E6C", -"~ c #7B6F69", -"^ c #796E6A", -"/ c #786E6C", -"( c #767161", -") c #7B7366", -"_ c #7C7367", -"` c #7E7A66", -"' c #767069", -"] c #79706B", -"[ c #7C716B", -"{ c #7F7868", -"} c #7F796C", -"| c #7E7572", -" . c #807D6D", -".. c #807776", -"X. c #837B70", -"o. c #847972", -"O. c #857C72", -"+. c #847B79", -"@. c #8A7F78", -"#. c #868172", -"$. c #898171", -"%. c #8C8673", -"&. c #8A8174", -"*. c #8D8870", -"=. c #8D867B", -"-. c #928B7C", -";. c #938C7D", -":. c #968F7F", -">. c #96907B", -",. c #98907F", -"<. c #8D8681", -"1. c #938C80", -"2. c #948C88", -"3. c #979081", -"4. c #999087", -"5. c #A29C81", -/* pixels */ -"V : H + Z m % - $ $ ' ! # -.$ k g x $ $ 2 &.$ % % 2 >.g ; z $ A ", -"&.d % $ 1 F 5.@ X.1 f [ % % % : z Y % ; O.L ] # @ N a T ; % , :.", -"A ; $ 6 = C $ , % , ; a $ I %.% 7 % o + 1 Z = 1 O % $ < @ & v L ", -"O ; T # 3 X @ 2 l z % % % g p % $ % A l $ ; : M t % = f G % # # ", -"e ; ; 6 > k $ & $ % @ % % : 4 % 0 % > T 4 $ % a % @ % $ 9 N $ -.", -"J % / z ~ 3.k , , f Z k e 3 # % O.d % % % } 6 : ; I | l $ , $ l ", -"N 8 2 2 3 O.m 6 , % E % = % 5 L E S % % 7 N J k = > u [ & D $ R ", -"= % + # ; % 2 % $ 7 l $ % : % : > $ $ $ , 2 q 4 % % % , , 4 % * ", -"$ h Z A $ % % 7 % : : $ A z q ; ; : ] I % ; $ ; D N 0 $ | Z z p ", -"M l g X.< 7 7 W u < % ; n { m , > > i > ; j % m q d g O 7 g g $ ", -"6 , n @ $ z : 2 % m .d % 9 % , l > ; ; m M @ : % , x @ $ % $ ; ", -"L 4 $ ; I <.u ; # A P A $ % # x 0 , % # z X.x < $ m P 9 = _ < g ", -"A 7 , + @.M & 9 % ; $ : % > % ; # ; % : n N n ; k % $ % G H % u ", -"$ % O.; $ $ . ` l % # $ # $ =.I 7 <.2.A ; % $ $ 6 x : , V Y > 6 ", -"2 ] [ s $ 9 @ E { m A O ] f A ; l s +.@ F I $ | / O.% % 2 0 $ : ", -"% % f a % $ ; A E = % # 3 i > $ $ , ..+ O g ; ~ N $ : : % $ 4 k ", -"$.j , < & #.% 6 : $ ;.a % 2 % g *.; g ; c v , $ : 6 T ~ % u ; ( ", -"g Z # : O.L ] # 6 N a T # % , D p d % % = F ` ; Z = f [ , % $ u ", -"v % @ # 1 Z = 1 $ % $ ; 6 % v l A @ @ ; & j $ ; # $ ; a . I S : ", -"# $ g l $ $ , M t % = f G , ; $ ; # z , 2 6 # 7 L ~ ; 7 % u 6 ; ", -") % 0 z e , # a % ; % # 9 N $ -.n , < 6 > k $ & $ % $ # % < 4 $ ", -": : ; $ % } b d , I | l $ $ # l W % / z ~ 3.S ; * f #.S e 3 ; * ", -"0 6 % p s N J k = > J [ & D @ R N 8 3 9 3 O.m ; # % E % 2 % 9 A ", -"v $ $ $ , : 4 : % * ; % 6 4 % % % % O < % % 2 % % > D @ ; q % z ", -"# 2 ] z % , % # l N 0 # | +.4.p % q O.A $ r # a ; w = , A g m o ", -"( i 0 c 7 j % ] l 6 , % 2 G N % > J A o.# 7 a W Q A + n k [ % ", -"k M 9 @ S M # 2 $ 6 ] , # % % % % % n # # Q * 2 % d .d < 9 % ; ", -"u u # $ Z 1.Z % % m P 9 = _ @ A x % $ ; I <.L $ $ g P ~ % % y [ ", -"p $ % : u g a $ D % $ % G H % A y : ; % @.M 2 9 $ % # 3 @ f ; $ ", -"7 K z y % # ; % 6 ] 7 , V ,.d 6 % % O.% $ ; % B ; % y ; ; $ =.I ", -"J 7 g < u I $ M x O.% # 7 Z ; 1 9 ] [ s $ 2 # 6 { i q O ] f A , ", -"u ; .., ; A u ~ N $ ; $ + $ 1 l % % f a , % # A z % % $ 3 n 9 % " -}; diff --git a/textures/b.xpm b/textures/b.xpm deleted file mode 100644 index 99258e6..0000000 --- a/textures/b.xpm +++ /dev/null @@ -1,49 +0,0 @@ -/* XPM */ -static char *_947bb94b4e04fd3d8b6e97faaaaa774DMhsGHANfMg9UIKL[] = { -/* columns rows colors chars-per-pixel */ -"32 32 11 1 ", -" c #422816", -". c #4E371C", -"X c #584529", -"o c #655131", -"O c #665232", -"+ c #655339", -"@ c #705C41", -"# c #756349", -"$ c #796442", -"% c #816D54", -"& c #948066", -/* pixels */ -"##++XX#@###%@%%O@X++.X#@@XX+++++", -"#@o+X #%##@O+X@@++XX+++@+@@++#%", -"#%#OO.+XXo+%#&%##.X.X##%@@@++##O", -"oooXXXX. +@@OX#.X##+X+..+#@O@X++", -"+OX@O@%%##@XX++OooXXX.X+XXX+@OXX", -"$X#O@.X@XXX.+.XX..+XX+XX+@+X....", -"#+%%++X+@@@X++#+X..+@+#####%#$#@", -"+X+X...XX@#.+#X@@+.++#&%@@@#+.++", -"X+XXX+XXXX@#%.@##@@.@++++#X.X.@%", -".+XX..X+@@++..#@++...X.XXX+@+XX+", -"X+X@#%+X.X++#+X XX++++...++X+X+", -"X..++@.XXXXOO@@@&##%@@+...++.++X", -"+@+X...#@#%@+@@+@#+X@#++@X.+@#++", -"X.XXX++&+@++X+.X+++X+XX###@@@X+X", -" .#++###+%#@+X#oXX+@@#@+@##+##..", -".%@##XOX%#@.@@X..X.X@@+@@@@@XX++", -"#@#X.XXXX+++.XX@#+++X XXX#+X+X+&", -"X@#%+X@XX.XX++O##@+..X++@#@%%++@", -"##@##.@+XXXX.XX@XX+X..+XX@#%%#@X", -"..X##.+X+@XX++@++X++.+X++++X+++.", -"+#+.XX+XX#+%&#@@@#X XX@XX.XX# .+", -"XX+X.+%%%%@@XX++%+%&%#++.X+X@.XX", -"# ++@+@#+XX.+X##+X##+@++@+@@#%", -"##X+X+@oX@....XXXX+o+#@@@++ X#X@", -"%+@XX..XX.X#..@X+X++#+XX+.@X+X%@", -"+X.X.X+++#XX+XX@@@@#+++.+++@+%OX", -"XOX+@X+@+@@+++X+++X+@X+++@X@X+X ", -"@##&@#++++@+++@X+. ..++@@.X++X+%", -"@#@#X+@++X@+XXXX++@+@XXX.X+@@@@%", -"XXOXXX...+@@#@@X@@#@#@&...X@#@.X", -"XX@...+@%&#XX@XX++@ .@@#@@+@X.X+", -"%@.@%@@+++@o++++X+X+@++XXO@@@%#&" -}; diff --git a/textures/chiseled_stone_bricks.xpm b/textures/chiseled_stone_bricks.xpm new file mode 100644 index 0000000..1e21413 --- /dev/null +++ b/textures/chiseled_stone_bricks.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char *_34726b4cc9a48cf855554a215e8f0c7evbrtsS0TvCY5cKQ[] = { +/* columns rows colors chars-per-pixel */ +"32 32 7 1 ", +" c #5A595A", +". c gray39", +"X c #6A6D6A", +"o c #787678", +"O c gray50", +"+ c #8B898B", +"@ c #9C999C", +/* pixels */ +"@@@@@@@@@@@++@++@@@@@++++@@@@++X", +"@+++++OO++++O++OOO+++++++++OOOo ", +"@++OO++OOOOOOOOOO+OO++OOoOOOOOO ", +"@+OooXXooXXXXXXoXXXXoooOOoOOOoo ", +"@++o. . . ....XoOoX ", +"@OOo @@@@@@@+++@@@@+@@@@@+.OOoo ", +"@+OX @++++++OO++++O++++++o.+OOo ", +"@++X.@++OOO++OO+OOOOOO+OOX.+OOO ", +"@+OX @+OOO++OOOOooOO+OOOoX.@+OO ", +"@+oX @+++OoOOOoooO++O+OOOX.@+Oo ", +"@+OX @++OoOoOooooooOoOO+Oo @OOo ", +"@OOX @+OOooooXXXoXooOO++Oo +OOO ", +"@OoX ++OOOoX ++OOOoX +OOo ", +"+Ooo +++OOoo ...@++OOOX.@OOo ", +"@+Oo ++OOOoX ....X@++OOoo @OOo ", +"@+OX @+O+OoX .....X@++Oooo @OOX ", +"@++X @+++OoX ...X.X@++OOoX @OoX ", +"+++o ++OOooX ..X.XX@+OOOOX @Ooo ", +"++Oo @+OOOOo.XXXXXX@+OOooX @OOo ", +"@+Oo.@+OOooo+@@@@@@+++OOoX @+Oo ", +"@OOX.@+OooOo++++++++OOOOoX ++Oo ", +"@+Oo.@+OOO+OO++OOOO++OoOoX +Ooo ", +"@+Oo.@+OOOOO++OOooOOOOoooX.@OoX ", +"@+OO.+OOOOoooOoooO+OoooooX @OoX ", +"@OOO.+OOoooooooOOooooXooXX.+OOX ", +"@Ooo.OoXXXXXoXXXooXXXXXXXX.+OOo ", +"+OOOX..... .. . . ...+oOo ", +"+OO++@@@@@+++@@@@@@@@++++++Oooo ", +"OooO+++++OOOO++OOO++++OO++OOOoo ", +"oOOOOOOooooOoOOOooOOooooooOOooX ", +"oooO+OooooOOoooXXooooooXXXooXXX ", +"X " +}; diff --git a/textures/chiseled_tuff.xpm b/textures/chiseled_tuff.xpm new file mode 100644 index 0000000..8714ba0 --- /dev/null +++ b/textures/chiseled_tuff.xpm @@ -0,0 +1,47 @@ +/* XPM */ +static char *_b2e0c82ad794314af2bb9115d57d40cKOsT9KYIoosREFqw[] = { +/* columns rows colors chars-per-pixel */ +"32 32 9 1 ", +" c #85837A", +". c #76776F", +"X c #6C716B", +"o c #4B5145", +"O c #525A51", +"+ c #636C6D", +"@ c #454A42", +"# c #5B625E", +"$ c #918E80", +/* pixels */ +" .Xoo .Xoo .Xoo .Xoo ", +"X.XXoO.XX.XXoO.XX.XXoO.XX.XXoO.X", +"OO.XoOX+OO.XoOX+OO.XoOX+OO.XoOX+", +"OO.+OO.+OO.+OO.+OO.+OO.+OO.+OO.+", +"oOX+OO.XoOX+OO.XoOX+OO.XoOX+OO.X", +"oOXXo@oooooooooooooooo@@@@@ooo.+", +"ooo@@@@@@@@@@@ooooooooooo@@@@@oo", +"oo@@@@@@@@@@@@@@@oooOOOOOOoo@@@o", +"ooOO@@@@+......+@@oo#####OOOOO@o", +"oo##@@@o########@@oo##########oo", +"oo##@@@o##o@oo##@@@ooooooooooooo", +"oo##@@@o#+oo@o+#oo@@@@@@@@@@@@oo", +"ooO#@@@o#+++@@+#+......++++###@o", +"ooO+@@@o####@@################@o", +"oo#+@@@@ooo@@@+###oo@@@@@ooo##@o", +"oo#+o@@@@@@@@o+###o@@@@@@@oo##@o", +"OO####++......+###@@+++#@@@o##@o", +"###OO#############@o####@@@o##@o", +"@@@@@@@@@@@@@ooo##@ooo##@@@@##@o", +"ooooooooo@@@@@@o##oooo+#@@@@##oo", +"####+++++++.@@@@#+....+#@@@oO###", +"OOO########.o@@@########@@@oO#OO", +"@@@o#######.ooo@@@@@@@@@@@ooo@@@", +"oooo+#####+.oooooooooooooooooooo", +" . ++###+........++++++ .Xoo", +".XX.XX $$$$$$ $$$ $$ X.XXoO", +"X+OO.XoOX+OO.XoOX+OO.XoOX+OO.XoO", +".+OO.+OO.+OO.+OO.+OO.+OO.+OO.+OO", +".XoOX+OO.XoOX+OO.XoOX+OO.XoOX+OO", +".+oOXX .+oOXX .+oOXX .+oOXX ", +"X+oo.XX.X+oo.XX.X+oo.XX.X+oo.XX.", +"o@@ooo@@@@o@@oo@@o@ooo@@@@o@@ooo" +}; diff --git a/textures/chiseled_tuff_bricks.xpm b/textures/chiseled_tuff_bricks.xpm new file mode 100644 index 0000000..a5f5d22 --- /dev/null +++ b/textures/chiseled_tuff_bricks.xpm @@ -0,0 +1,47 @@ +/* XPM */ +static char *_f08c454006643348fde03abec495508LYfG9oduOg0Aqa1A[] = { +/* columns rows colors chars-per-pixel */ +"32 32 9 1 ", +" c #85837A", +". c #76776F", +"X c #6C716B", +"o c #4B5145", +"O c #525A51", +"+ c #636C6D", +"@ c #454A42", +"# c #918E80", +"$ c #5B625E", +/* pixels */ +" .Xoo .Xoo .Xoo .Xoo ", +"X.XXoO.XX.XXoO.XX.XXoO.XX.XXoO.X", +"OO.XoOX+OO.XoOX+OO.XoOX+OO.XoOX+", +"OO.+OO.+OO.+OO.+OO.+OO.+OO.+OO.+", +"oOX+OO.XoOX+OO.XoOX+OO.XoOX+OO.X", +"oOXX .+oOXX .+oOXX .+oOXX .+", +"oo.XX.X+oo.XX.X+oo.XX.X+oo.XX.X+", +"o@@ooo@@@@o@@oo@@o@ooo@@@@o@@ooo", +"# .... $", +" ## ........ $O", +" #### ........ $Oo", +" #X++XX++++++++++++++++++++XOOo", +" #+XXX+++++++++XXX++++++++X+oOO", +" XXX++++++X+XXXX++++++++XX+oOO", +" ++XX++++++XXXXXXXX+++X..XXOOo", +". ++++++++++++++X....XXXXX.XOoo", +". +++++++X++++XX...XXXXXXX..OoO", +". X++++XX++++++++++XXXXXX...ooO", +".. X+++++XXX++++++X++XXX.... ooo", +"...XX++XXXX+++XX+++XX..... ooo", +"X.X$OOOOO$$$$$$OOOOOO$$$$$$OoOoo", +".X$OOO$$$OO$$OOOOO$$$OO$$$OOOooo", +"XOOO$$$$OO$$$$OOOOO$$$$$$O$OOOoo", +"@oo@@ooo@@o@ooooo@@o@@ooooo@o@@@", +" .Xoo .Xoo .Xoo .Xoo", +".XX.XXoO.XX.XXoO.XX.XXoO.XX.XXoO", +"X+OO.XoOX+OO.XoOX+OO.XoOX+OO.XoO", +".+OO.+OO.+OO.+OO.+OO.+OO.+OO.+OO", +".XoOX+OO.XoOX+OO.XoOX+OO.XoOX+OO", +".+oOXX .+oOXX .+oOXX .+oOXX ", +"X+oo.XX.X+oo.XX.X+oo.XX.X+oo.XX.", +"o@@ooo@@@@o@@oo@@o@ooo@@@@o@@ooo" +}; diff --git a/textures/chiseled_tuff_bricks_top.xpm b/textures/chiseled_tuff_bricks_top.xpm new file mode 100644 index 0000000..b78b686 --- /dev/null +++ b/textures/chiseled_tuff_bricks_top.xpm @@ -0,0 +1,46 @@ +/* XPM */ +static char *e71190f36661423dc627e558854b225eNGSgXIZyGIf8Lo6k[] = { +/* columns rows colors chars-per-pixel */ +"32 32 8 1 ", +" c #76776F", +". c #85837A", +"X c #636C6D", +"o c #5B625E", +"O c #4B5145", +"+ c #525A51", +"@ c #6C716B", +"# c #918E80", +/* pixels */ +" ..... .. ..... ... ", +".. ", +". XoooooooooooooooooooooooooX .", +". oOO+OOOOOOOOOOOO++++O+++++@@ .", +". o++OOOOOOOOOOOO++OO++++++ .X ", +". o+OOOOOOOOOOOOOOOO++++++ ..X ", +" oOOO..... @@@@@@ @@@...X .", +" o+OO @@XXX@@@@@ @@@...X .", +" o+O+@@XXX@@@@@ @@@@...X .", +" o+++@XXX@@@@@ @@@@@#..X .", +" o+++XXX@@@@@ @@@@@@##.X .", +" o+++XX@@@@@ @@@@@@@##.X .", +". o+++X@@@@@ @@@@@@@@##.X .", +". o+++@@@@@ @@@@@@@@X#.#X .", +". o+++@@@@ @@@@@@@@XX###X ", +". o+++@@@ @@@@@@@@XXX###X ", +". o+++@@ @@@@@@@@XXXX###X ", +". o+++@ @@@@@@@@XXXX@###X ", +" o+++ @@@@@@@@XXXX@@###X ", +" o+++ @@@@@@@@XXXX@@@###X .", +" o+++ @@@@@@@@XXXX@@@@###@ .", +" o++o @@@@@@@@XXXX@@@@ ###@ ", +". o++o @@@@@@@@XXXX@@@@ ###@ ", +". X+oo @@@@@@@@XXXX@@@@ ###@ ", +". Xooo@@@@@@@@XXXX@@@@ ###@ .", +". o+oo@@@@@@@XXXX@@@@ ###@ .", +" X+o@ .............###@ .", +" Xo@ .................##@ .", +" X@ . .................#@ ", +". @XXXXXXXXXX@@X@@XX@@@@@@@@@ ", +". .", +" .... ...... ..... ......." +}; diff --git a/textures/chiseled_tuff_top.xpm b/textures/chiseled_tuff_top.xpm new file mode 100644 index 0000000..fb63c3a --- /dev/null +++ b/textures/chiseled_tuff_top.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char *_c69ba904c1a4779daa615bdd2b1983fpwkqde2L6SKaPdA7[] = { +/* columns rows colors chars-per-pixel */ +"32 32 7 1 ", +" c #76776F", +". c #85837A", +"X c #525A51", +"o c #4B5145", +"O c #5B625E", +"+ c #636C6D", +"@ c #454A42", +/* pixels */ +" ..... ..... ... .... ", +". ", +". XXXXXXXXXXXXXXXXXXXXXXXXXXXX ", +". XXooooooooXXXXoooXXXooooooXX .", +". XoO+OOOOOOOO+++OOOOOOOOOOOoX .", +". Xo+++++++O+++++++OOO+++++OoX .", +" Xo++oo@@@@@@@@@@@@@@@oXX++oX .", +" XX++o@@@@@@@@@@@@@@@@@oX++oX .", +" XXO+@@@@OOOOOOOOOOOO@@@o+OXX ", +". XoO+@@@@O++OO+O+++OO@@@o+OXX ", +". XoO+@@@@OOo@@@@ooo+O@@@@++oX ", +". XoOO@@@@OOo@@@@@oo+O@@@@+OoX ", +". XoOO@@@oO+o@@@OO@o+O@@@@+OoX ", +". XXOO@@@oO+oo@@ +@o Oo@@@OOoX ", +" XXO+@@@oO+oo@@ O@@ Oo@@@+OoX ", +" XXO+@@ooOOoo@@ O@@++oo@@+OoX .", +". XoO+@@ooO+ooo@ +@@ +oo@@+OXX .", +". XoO+@@ooO+oooo +@@ Oooo@+OXX .", +". XXOO@oooOO+++ +O@@ +ooo@OOXX .", +". XoOO@oooOOOOOOOO@o Oooo@OOXX ", +" XoOO@oo@@@@@@@@@oo+Oooo@OOXX ", +". XoO+oooo@@@@@@oooo+O@oo@+OoX ", +". XoO+++O+ + ++O@oo@+OXX .", +" oo+++OOOO+++OOO+++OO@oo@+OoX .", +" oo+++Ooo@@@@@@@@@@@@@@oo+OoX .", +". oo++OOoo@@@@@ooooo@@@@o +OoX .", +". oo++OOooo@O+++ + +OOoX .", +". XoOOOOooooOO+OOO++++OOOOOOoX ", +" XoooooooXooooXXXXooooXXoooXX .", +" XXoooooXXXXXXXXXXXXXXXXXXXXX .", +" .", +"..... ... .. . ... ....." +}; diff --git a/textures/cobblestone_32.xpm b/textures/cobblestone_32.xpm deleted file mode 100644 index 5d7ac8c..0000000 --- a/textures/cobblestone_32.xpm +++ /dev/null @@ -1,154 +0,0 @@ -/* XPM */ -static char *_cb59dce4f574e3bd6a1e2f025c0312agi1mGDihwOOx8j7A[] = { -/* columns rows colors chars-per-pixel */ -"32 32 116 2 ", -" c #100F10", -". c #161515", -"X c #191717", -"o c #191718", -"O c #1E1C1C", -"+ c #211E1E", -"@ c #252222", -"# c #292626", -"$ c #2D2B2B", -"% c #322E2E", -"& c #3A2F2E", -"* c #36302F", -"= c #3C312E", -"- c #342F30", -"; c #353131", -": c #3A3434", -"> c #3D3836", -", c #3C3738", -"< c #3E3A3A", -"1 c #43332F", -"2 c #433534", -"3 c #4C3633", -"4 c #433A36", -"5 c #4C3937", -"6 c #433C3B", -"7 c #4B3D3B", -"8 c #503835", -"9 c #523D3C", -"0 c #46413E", -"q c #4B433D", -"w c #524433", -"e c #55443B", -"r c #453F41", -"t c #563D40", -"y c #474141", -"u c #4B4442", -"i c #4E4845", -"p c #4F4949", -"a c #544442", -"s c #584644", -"d c #534A42", -"f c #5A4A46", -"g c #554D4B", -"h c #5C4D4C", -"j c #545146", -"k c #56514C", -"l c #5B524D", -"z c #5D5552", -"x c #5F5A53", -"c c #614D46", -"v c #61534D", -"b c #625D4C", -"n c #625553", -"m c #635A53", -"M c #655B59", -"N c #695D5A", -"B c #636052", -"V c #696354", -"C c #6E6852", -"Z c #66615A", -"A c #6B625D", -"S c #6D695B", -"D c #70675F", -"F c #736A5D", -"G c #6C6360", -"H c #6B6463", -"J c #6F6563", -"K c #6D6865", -"L c #706763", -"P c #726766", -"I c #716A62", -"U c #726A63", -"Y c #756D63", -"T c #746A64", -"R c #786B66", -"E c #786D66", -"W c #716A68", -"Q c #746B69", -"! c #776E6C", -"~ c #7B6F69", -"^ c #796E6A", -"/ c #786E6C", -"( c #767161", -") c #7B7366", -"_ c #7C7367", -"` c #7E7A66", -"' c #767069", -"] c #79706B", -"[ c #7C716B", -"{ c #7F7868", -"} c #7F796C", -"| c #7E7572", -" . c #807D6D", -".. c #807776", -"X. c #837B70", -"o. c #847972", -"O. c #857C72", -"+. c #847B79", -"@. c #8A7F78", -"#. c #868172", -"$. c #898171", -"%. c #8C8673", -"&. c #8A8174", -"*. c #8D8870", -"=. c #8D867B", -"-. c #928B7C", -";. c #938C7D", -":. c #968F7F", -">. c #96907B", -",. c #98907F", -"<. c #8D8681", -"1. c #938C80", -"2. c #948C88", -"3. c #979081", -"4. c #999087", -"5. c #A29C81", -/* pixels */ -"V : H + Z m % - $ $ ' ! # -.$ k g x $ $ 2 &.$ % % 2 >.g ; z $ A ", -"&.d % $ 1 F 5.@ X.1 f [ % % % : z Y % ; O.L ] # @ N a T ; % , :.", -"A ; $ 6 = C $ , % , ; a $ I %.% 7 % o + 1 Z = 1 O % $ < @ & v L ", -"O ; T # 3 X @ 2 l z % % % g p % $ % A l $ ; : M t % = f G % # # ", -"e ; ; 6 > k $ & $ % @ % % : 4 % 0 % > T 4 $ % a % @ % $ 9 N $ -.", -"J % / z ~ 3.k , , f Z k e 3 # % O.d % % % } 6 : ; I | l $ , $ l ", -"N 8 2 2 3 O.m 6 , % E % = % 5 L E S % % 7 N J k = > u [ & D $ R ", -"= % + # ; % 2 % $ 7 l $ % : % : > $ $ $ , 2 q 4 % % % , , 4 % * ", -"$ h Z A $ % % 7 % : : $ A z q ; ; : ] I % ; $ ; D N 0 $ | Z z p ", -"M l g X.< 7 7 W u < % ; n { m , > > i > ; j % m q d g O 7 g g $ ", -"6 , n @ $ z : 2 % m .d % 9 % , l > ; ; m M @ : % , x @ $ % $ ; ", -"L 4 $ ; I <.u ; # A P A $ % # x 0 , % # z X.x < $ m P 9 = _ < g ", -"A 7 , + @.M & 9 % ; $ : % > % ; # ; % : n N n ; k % $ % G H % u ", -"$ % O.; $ $ . ` l % # $ # $ =.I 7 <.2.A ; % $ $ 6 x : , V Y > 6 ", -"2 ] [ s $ 9 @ E { m A O ] f A ; l s +.@ F I $ | / O.% % 2 0 $ : ", -"% % f a % $ ; A E = % # 3 i > $ $ , ..+ O g ; ~ N $ : : % $ 4 k ", -"$.j , < & #.% 6 : $ ;.a % 2 % g *.; g ; c v , $ : 6 T ~ % u ; ( ", -"g Z # : O.L ] # 6 N a T # % , D p d % % = F ` ; Z = f [ , % $ u ", -"v % @ # 1 Z = 1 $ % $ ; 6 % v l A @ @ ; & j $ ; # $ ; a . I S : ", -"# $ g l $ $ , M t % = f G , ; $ ; # z , 2 6 # 7 L ~ ; 7 % u 6 ; ", -") % 0 z e , # a % ; % # 9 N $ -.n , < 6 > k $ & $ % $ # % < 4 $ ", -": : ; $ % } b d , I | l $ $ # l W % / z ~ 3.S ; * f #.S e 3 ; * ", -"0 6 % p s N J k = > J [ & D @ R N 8 3 9 3 O.m ; # % E % 2 % 9 A ", -"v $ $ $ , : 4 : % * ; % 6 4 % % % % O < % % 2 % % > D @ ; q % z ", -"# 2 ] z % , % # l N 0 # | +.4.p % q O.A $ r # a ; w = , A g m o ", -"( i 0 c 7 j % ] l 6 , % 2 G N % > J A o.# 7 a W Q A + n k [ % ", -"k M 9 @ S M # 2 $ 6 ] , # % % % % % n # # Q * 2 % d .d < 9 % ; ", -"u u # $ Z 1.Z % % m P 9 = _ @ A x % $ ; I <.L $ $ g P ~ % % y [ ", -"p $ % : u g a $ D % $ % G H % A y : ; % @.M 2 9 $ % # 3 @ f ; $ ", -"7 K z y % # ; % 6 ] 7 , V ,.d 6 % % O.% $ ; % B ; % y ; ; $ =.I ", -"J 7 g < u I $ M x O.% # 7 Z ; 1 9 ] [ s $ 2 # 6 { i q O ] f A , ", -"u ; .., ; A u ~ N $ ; $ + $ 1 l % % f a , % # A z % % $ 3 n 9 % " -}; diff --git a/textures/sandy_32.xpm b/textures/sandy_32.xpm deleted file mode 100644 index ca42b14..0000000 --- a/textures/sandy_32.xpm +++ /dev/null @@ -1,45 +0,0 @@ -/* XPM */ -static char *b2ffa1f3349541dfd85c9d78164cd8f5fwrUjFoX83Qd2gcH[] = { -/* columns rows colors chars-per-pixel */ -"32 32 7 1", -" c #747474", -". c gray50", -"X c gray56", -"o c #9D9D9D", -"O c gray64", -"+ c gray66", -"@ c gray69", -/* pixels */ -". .. . XX .XXX. ...XX. .XXXX.", -" @@@+@++++OOO+++OOOooOO++++++++X", -" +OOOO+OOO+++OO+@@+@@+ooOooO+OO.", -" +++O+++OOO+OO++O+OO+++OooO+OO+ ", -" +OOooooOOOOOoooooOOOOO++++++OOX", -".@+OOooOooO++OoOOOO+O+++OO+++++X", -"XOOO++OOO++++++@@@@@+++OO+OooOOX", -".+@@@@@@++@@+OO++@@+++@@@++OO++X", -"XOOO+@@OooOO++OO++@@@@@++@@OOO+ ", -"XO+++++OOO++OO+++@@++@@@++OO+++.", -".@@@@+OO++++++OO++OOOO+OooOooO@ ", -" +@@+++++++OOOO++OOooOoooOOOOOO ", -" OO+O+@@@@@+O+@@@@@OOOOO+++++++.", -"XOOOOOOO@@+OOO+@+OOOooO+++@@@OO ", -"XOOOoooooOooO++OOO+OO++OOOOO+++ ", -"X++OOoOoOOOOOOOO++++OOOOO++++++.", -"X+OO+++OO+OO+@@@@@@@+O++OO+OOOO.", -"X@@@@@++@@@+++@@@++OOOO+++++OO+.", -".++@@++OO+O+@@++@@++O+@@@++@@++X", -" +@@@@+++++OO+@@++++OOO++@@@OOOX", -" oO+++++OOOoooOoOO+OO+++OO+OOoOX", -".+++OOO++O++OooOO+++++@@@@@@+++X", -".++OO+++++@@@@@+@@++++++@@+OO+@X", -"X++++++++@@@@+++++OO+OOOO+++OOOX", -"X+OO+OOO++@+++OOooO+++OooooOooO.", -".++OooO+@@@@+++OO+++OO+OoOOOOooX", -".@@@@O+OOO++OO++OOO@@+++OO++O@@X", -" @@+++OOO+++++OOOO+++OOOO++OOO+.", -" +O+OO++@@@@@OOO++OO++++@@@@@@@ ", -".OooO+OO+@@+++OOO+++++++++@+@@@ ", -".++OOO+++O+OOooO+@@@@@+O+OOOOO+.", -" .XXXX. .XXXXXX. X.. . .X..." -}; diff --git a/textures/wasteland_32.xpm b/textures/wasteland_32.xpm deleted file mode 100644 index 2c8122d..0000000 --- a/textures/wasteland_32.xpm +++ /dev/null @@ -1,45 +0,0 @@ -/* XPM */ -static char *f4be72bda4ec41cce3e231f3563262e6RzcICVlC9CbSzsPX[] = { -/* columns rows colors chars-per-pixel */ -"32 32 7 1 ", -" c #5A595A", -". c gray39", -"X c #6A6D6A", -"o c #787678", -"O c gray50", -"+ c #8B898B", -"@ c #9C999C", -/* pixels */ -"++@@@@@@@@@@@@@@@@@@@@@@@@@@+++ ", -"+oO+++++++++++++++OO++++OO+OOO+ ", -"+O++OO++O++O+++OOOO++OO++OooOo+ ", -"@OOOO+O+++OooO++OO++O+OOOOOooOO ", -"@O+ooO++OOoO++OOOOOOOOOo+OOOOOO ", -"@++OooO++OO++OOOOO+OoO++OOOOOOO ", -"@O+++OoOO+ooOOO+OOooO++OooOooOo ", -"@OoOOOOOOOOOoOOO++OO+OOOOoooOoo ", -"@OOoOoOOOoOOOOOOOOOOOOOOoOOOOOO ", -"@OoooOOooO++OO+OoO+oooOooOO+OOO ", -"@OoXooooOOO+++OOOoooOOoooooO++O ", -"+ooXOoOoOOOoOOOOOOOO++OOXooOOoO ", -"+oXXoOXooooOooooooO+oOXXoooooOO ", -"OoXXXXOOooooooooOoooOOOXXXOOooo ", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.", -".. . ... .............", -"@@@@@@@@@@@@@++ +++@@@@@@@@@@@@@", -"ooOoOO+++++OOOO +OO+O+++O+++OOOO", -"OooOO++O+O++OOO @OOO+++OOOOOOOOO", -"O+O++O++OOOO+OO @OOOOOOO+OOoOO++", -"+OOOOOOOOOOOOOo @oOOO+++OOOOooO+", -"OOOO+OOOO+OOoOo @OoO+ooOoOOOOooO", -"O+OOO+O++OoOooX @oO++OooOOOO+OOO", -"OO+++++OooOoOXX @oOO++OOOoOo++OO", -"OOOO+OO+Oo+OoXX @oOOOOO++ooOOOOO", -"++OOOOOooOooXoX +ooOoO+OO++O+OOO", -"+OooOoOoO++oOoo +oooOOOoOO++OO++", -"OOOooOoOoOXOOoo +OOoOooOoOOOO+OO", -"OoXXoXooXXOOOoo +OooooooOOoOOOoo", -"oooXXooooXXXooo OoOOOoooooOOOOOo", -"XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX", -"............ .............." -};