aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile79
-rw-r--r--test/include/helper/helper_segfault.h20
-rw-r--r--test/include/libft_test.h28
-rw-r--r--test/src/algo/test_ft_bsearch.c55
-rw-r--r--test/src/algo/test_ft_compar_int.c20
-rw-r--r--test/src/algo/test_ft_heapsort.c27
-rw-r--r--test/src/algo/test_ft_is_set.c23
-rw-r--r--test/src/algo/test_ft_lfind.c38
-rw-r--r--test/src/algo/test_ft_lsearch.c52
-rw-r--r--test/src/algo/test_ft_mergesort.c26
-rw-r--r--test/src/algo/test_ft_qsort.c50
-rw-r--r--test/src/algo/test_ft_reverse.c19
-rw-r--r--test/src/ctype/test_ft_isalnum.c15
-rw-r--r--test/src/ctype/test_ft_isalpha.c15
-rw-r--r--test/src/ctype/test_ft_isascii.c15
-rw-r--r--test/src/ctype/test_ft_isblank.c15
-rw-r--r--test/src/ctype/test_ft_isdigit.c15
-rw-r--r--test/src/ctype/test_ft_isprint.c15
-rw-r--r--test/src/ctype/test_ft_isspace.c15
-rw-r--r--test/src/ctype/test_ft_todigit.c20
-rw-r--r--test/src/ctype/test_ft_tolower.c15
-rw-r--r--test/src/ctype/test_ft_toupper.c15
-rw-r--r--test/src/dstr/test_ft_dstrdestroy.c26
-rw-r--r--test/src/dstr/test_ft_dstrerase.c69
-rw-r--r--test/src/dstr/test_ft_dstrgrow.c52
-rw-r--r--test/src/dstr/test_ft_dstrinsert.c59
-rw-r--r--test/src/dstr/test_ft_dstrnew.c60
-rw-r--r--test/src/dstr/test_ft_dstrsubstitute.c64
-rw-r--r--test/src/dstr/test_ft_dstrunwrap.c42
-rw-r--r--test/src/ht/test_ft_htdelone.c62
-rw-r--r--test/src/ht/test_ft_htdestroy.c32
-rw-r--r--test/src/ht/test_ft_htget.c106
-rw-r--r--test/src/ht/test_ft_hthash.c0
-rw-r--r--test/src/ht/test_ft_htnew.c46
-rw-r--r--test/src/ht/test_ft_htset.c94
-rw-r--r--test/src/ht/test_ftht_entry_new.c43
-rw-r--r--test/src/lst/test_ft_lstbsearch.c37
-rw-r--r--test/src/lst/test_ft_lstdelone.c26
-rw-r--r--test/src/lst/test_ft_lstdestroy.c14
-rw-r--r--test/src/lst/test_ft_lstiter.c52
-rw-r--r--test/src/lst/test_ft_lstlast.c29
-rw-r--r--test/src/lst/test_ft_lstlfind.c55
-rw-r--r--test/src/lst/test_ft_lstlsearch.c55
-rw-r--r--test/src/lst/test_ft_lstmap.c82
-rw-r--r--test/src/lst/test_ft_lstnew.c25
-rw-r--r--test/src/lst/test_ft_lstpop_front.c31
-rw-r--r--test/src/lst/test_ft_lstpush_back.c41
-rw-r--r--test/src/lst/test_ft_lstpush_front.c41
-rw-r--r--test/src/lst/test_ft_lstremove_if.c70
-rw-r--r--test/src/lst/test_ft_lstreverse.c45
-rw-r--r--test/src/lst/test_ft_lstreverse_ret.c45
-rw-r--r--test/src/lst/test_ft_lstsize.c37
-rw-r--r--test/src/lst/test_ft_lstsort.c38
-rw-r--r--test/src/lst/test_ft_lstsorted_merge.c40
-rw-r--r--test/src/main.c105
-rw-r--r--test/src/mem/test_ft_bzero.c30
-rw-r--r--test/src/mem/test_ft_calloc.c33
-rw-r--r--test/src/mem/test_ft_memccpy.c45
-rw-r--r--test/src/mem/test_ft_memchr.c35
-rw-r--r--test/src/mem/test_ft_memcmp.c42
-rw-r--r--test/src/mem/test_ft_memcpy.c47
-rw-r--r--test/src/mem/test_ft_memmem.c65
-rw-r--r--test/src/mem/test_ft_memmove.c39
-rw-r--r--test/src/mem/test_ft_memset.c42
-rw-r--r--test/src/mem/test_ft_memset_pattern4.c42
-rw-r--r--test/src/mem/test_ft_memswap.c41
-rw-r--r--test/src/runner/test_runner_algo.c60
-rw-r--r--test/src/runner/test_runner_ctype.c64
-rw-r--r--test/src/runner/test_runner_dstr.c48
-rw-r--r--test/src/runner/test_runner_ht.c51
-rw-r--r--test/src/runner/test_runner_lst.c103
-rw-r--r--test/src/runner/test_runner_mem.c69
-rw-r--r--test/src/runner/test_runner_str.c37
-rw-r--r--test/src/runner/test_runner_vec.c64
-rw-r--r--test/src/str/test_ft_fnmatch.c117
-rw-r--r--test/src/str/test_ft_strlen.c24
-rw-r--r--test/src/str/test_ft_strsjoin.c57
-rw-r--r--test/src/str/test_ft_strsjoinf.c87
-rw-r--r--test/src/str/test_ft_strsub.c54
-rw-r--r--test/src/str/test_ft_strsubf.c61
-rw-r--r--test/src/str/test_ft_strtol.c129
-rw-r--r--test/src/vec/test_ft_vecdestroy.c26
-rw-r--r--test/src/vec/test_ft_vecgrow.c74
-rw-r--r--test/src/vec/test_ft_vecinsert.c66
-rw-r--r--test/src/vec/test_ft_veciter.c52
-rw-r--r--test/src/vec/test_ft_vecnew.c47
-rw-r--r--test/src/vec/test_ft_vecpop.c47
-rw-r--r--test/src/vec/test_ft_vecpush.c57
-rw-r--r--test/src/vec/test_ft_vecpush_safe.c45
-rw-r--r--test/src/vec/test_ft_vecremove.c64
-rw-r--r--test/src/vec/test_ft_vecsort.c34
91 files changed, 0 insertions, 4213 deletions
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 48e08a9..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-# **************************************************************************** #
-# #
-# ::: :::::::: #
-# Makefile :+: :+: :+: #
-# +:+ +:+ +:+ #
-# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
-# +#+#+#+#+#+ +#+ #
-# Created: 2020/02/15 04:35:44 by cacharle #+# #+# #
-# Updated: 2020/04/04 20:58:20 by charles ### ########.fr #
-# #
-# **************************************************************************** #
-
-MAKE = make
-MAKE_ARGS = --no-print-directory
-
-UNITY_DIR = ../vendor/_unity
-LIBFT_DIR = ..
-
-SRC_DIR = src
-INCLUDE_DIR = include
-
-CC = gcc
-CCFLAGS = -I$(INCLUDE_DIR) -I$(UNITY_DIR)/include -I$(LIBFT_DIR)/include -Wall -Wextra #-Werror
-LDFLAGS = -L$(UNITY_DIR) -lunity -L$(LIBFT_DIR) -lft
-
-NAME = libft_test
-
-INCLUDE = $(shell find $(INCLUDE_DIR) -type f -name "*.h")
-SRC = $(shell find $(SRC_DIR) -type f -name "*.c")
-OBJ = $(SRC:.c=.o)
-
-
-all: unity_all $(NAME)
-
-run: all
- @echo "Test: Running"
- @./$(NAME)
-
-run_v: all
- @echo "Test: Running"
- @./$(NAME) -v
-
-run_s: all
- @echo "Test: Running"
- @./$(NAME) -s
-
-$(NAME): libft_all $(OBJ)
- @echo "Test: Linking: $@"
- @$(CC) -o $@ $(OBJ) $(LDFLAGS)
-
-%.o: %.c $(INCLUDE) $(LIBFT_SRC)
- @echo "Test: Compiling: $@"
- @$(CC) $(CCFLAGS) -c -o $@ $<
-
-clean:
- @echo "Test: Removing object"
- @$(RM) $(OBJ)
-
-clean_dep: unity_fclean libft_fclean
-
-fclean: clean
- @echo "Test: Removing executable"
- @$(RM) $(NAME)
-
-re: fclean all
-
-re_dep: clean_dep fclean all
-
-unity_all:
- @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) all
-
-unity_fclean:
- @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) fclean
-
-libft_all:
- @$(MAKE) $(MAKE_ARGS) -s -C $(LIBFT_DIR) all
-
-libft_fclean:
- @$(MAKE) $(MAKE_ARGS) -s -C $(LIBFT_DIR) fclean
diff --git a/test/include/helper/helper_segfault.h b/test/include/helper/helper_segfault.h
deleted file mode 100644
index d638a70..0000000
--- a/test/include/helper/helper_segfault.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef HELPER_SEGFAULT_H
-# define HELPER_SEGFAULT_H
-
-extern int helper_segfault_pid;
-
-# define TEST_ASSERT_SEGFAULT(code) do { \
- fflush(stdout); \
- if ((helper_segfault_pid = fork()) < 0) \
- exit(EXIT_FAILURE); \
- if (helper_segfault_pid == 0) \
- { \
- do { code; } while (0); \
- exit(EXIT_FAILURE); \
- } \
- wait(&helper_segfault_pid); \
- if (WIFSIGNALED(helper_segfault_pid)) \
- TEST_FAIL_MESSAGE("Segfault"); \
-} while (0)
-
-#endif
diff --git a/test/include/libft_test.h b/test/include/libft_test.h
deleted file mode 100644
index c58d533..0000000
--- a/test/include/libft_test.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef LIBFT_TEST_H
-# define LIBFT_TEST_H
-
-# include <string.h>
-# include <ctype.h>
-# include <sys/wait.h>
-# ifdef __APPLE__
-# include <malloc/malloc.h>
-# endif
-
-# include "unity.h"
-# include "unity_fixture.h"
-
-# undef free
-# undef malloc
-
-# include <stdlib.h>
-
-# include "libft.h"
-# include "libft_algo.h"
-# include "libft_lst.h"
-# include "libft_ht.h"
-# include "libft_vec.h"
-# include "libft_dstr.h"
-
-# include "helper/helper_segfault.h"
-
-#endif
diff --git a/test/src/algo/test_ft_bsearch.c b/test/src/algo/test_ft_bsearch.c
deleted file mode 100644
index 27858ee..0000000
--- a/test/src/algo/test_ft_bsearch.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_bsearch);
-
-TEST_SETUP(ft_bsearch)
-{}
-
-TEST_TEAR_DOWN(ft_bsearch)
-{}
-
-TEST(ft_bsearch, basic)
-{
- int arr[] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34};
- t_ftsearch_const consts;
-
- int a = 189;
- consts.key = &a;
- consts.compar = ft_compar_int;
-
- size_t nelp = sizeof(arr) / sizeof(int);
- qsort(arr, nelp, sizeof(int), ft_compar_int);
-
- void *ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-
- int b = 123;
- consts.key = &b;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_NULL(ptr);
-
- int c = -134;
- consts.key = &c;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-
- int e = 1;
- consts.key = &e;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-
- int d = -1;
- consts.key = &d;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-
- int f = 34;
- consts.key = &f;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-
- int g = 7;
- consts.key = &g;
- ptr = ft_bsearch(arr, nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(bsearch(consts.key, arr, nelp, sizeof(int), consts.compar), ptr);
-}
diff --git a/test/src/algo/test_ft_compar_int.c b/test/src/algo/test_ft_compar_int.c
deleted file mode 100644
index 39cc322..0000000
--- a/test/src/algo/test_ft_compar_int.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_compar_int);
-
-TEST_SETUP(ft_compar_int)
-{}
-
-TEST_TEAR_DOWN(ft_compar_int)
-{}
-
-TEST(ft_compar_int, basic)
-{
- int a = 4;
- int b = 3;
-
- TEST_ASSERT_GREATER_THAN(0, ft_compar_int(&a, &b));
- TEST_ASSERT_LESS_THAN(0, ft_compar_int(&b, &a));
- TEST_ASSERT_EQUAL(0, ft_compar_int(&a, &a));
- TEST_ASSERT_EQUAL(0, ft_compar_int(&b, &b));
-}
diff --git a/test/src/algo/test_ft_heapsort.c b/test/src/algo/test_ft_heapsort.c
deleted file mode 100644
index 6c2c3fb..0000000
--- a/test/src/algo/test_ft_heapsort.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_heapsort);
-
-TEST_SETUP(ft_heapsort)
-{}
-
-TEST_TEAR_DOWN(ft_heapsort)
-{}
-
-static int compar(const void *a, const void *b)
-{
- return *(int*)a - *(int*)b;
-}
-
-TEST(ft_heapsort, basic)
-{
- TEST_IGNORE();
- int arr[] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34};
- int sorted_arr[sizeof(arr)];
-
- memcpy(sorted_arr, arr, sizeof(arr));
- qsort(sorted_arr, sizeof(arr) / sizeof(int), sizeof(int), compar);
-
- ft_heapsort(arr, sizeof(arr) / sizeof(int), sizeof(int), compar);
- TEST_ASSERT_EQUAL_INT_ARRAY(sorted_arr, arr, sizeof(arr) / sizeof(int));
-}
diff --git a/test/src/algo/test_ft_is_set.c b/test/src/algo/test_ft_is_set.c
deleted file mode 100644
index 604ec53..0000000
--- a/test/src/algo/test_ft_is_set.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_is_set);
-
-TEST_SETUP(ft_is_set)
-{}
-
-TEST_TEAR_DOWN(ft_is_set)
-{}
-
-static int compar(const void *a, const void *b)
-{
- return *(int*)a - *(int*)b;
-}
-
-TEST(ft_is_set, basic)
-{
- int arr[] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34};
- int unique_arr[] = {3, 4, 2, 189, -1, -134, 7, 1, 34};
-
- TEST_ASSERT_FALSE(ft_is_set(arr, sizeof(arr) / sizeof(int), sizeof(int), compar));
- TEST_ASSERT_TRUE(ft_is_set(unique_arr, sizeof(unique_arr) / sizeof(int), sizeof(int), compar));
-}
diff --git a/test/src/algo/test_ft_lfind.c b/test/src/algo/test_ft_lfind.c
deleted file mode 100644
index 0080d55..0000000
--- a/test/src/algo/test_ft_lfind.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_lfind);
-
-TEST_SETUP(ft_lfind)
-{}
-
-TEST_TEAR_DOWN(ft_lfind)
-{}
-
-TEST(ft_lfind, basic)
-{
- int arr[] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34};
- t_ftsearch_const consts;
-
- int a = 189;
- consts.key = &a;
- consts.compar = ft_compar_int;
-
- size_t nelp = sizeof(arr) / sizeof(int);
- void *ptr = ft_lfind(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr + 5, ptr);
-
- int b = 123;
- consts.key = &b;
- ptr = ft_lfind(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_NULL(ptr);
-
- int c = 34;
- consts.key = &c;
- ptr = ft_lfind(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr + 10, ptr);
-
- int d = 3;
- consts.key = &d;
- ptr = ft_lfind(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr, ptr);
-}
diff --git a/test/src/algo/test_ft_lsearch.c b/test/src/algo/test_ft_lsearch.c
deleted file mode 100644
index 13fae13..0000000
--- a/test/src/algo/test_ft_lsearch.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_lsearch);
-
-TEST_SETUP(ft_lsearch)
-{}
-
-TEST_TEAR_DOWN(ft_lsearch)
-{}
-
-TEST(ft_lsearch, basic)
-{
- int arr[32] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34};
- t_ftsearch_const consts;
-
- int a = 189;
- consts.key = &a;
- consts.compar = ft_compar_int;
-
- size_t nelp = 11;
- void *ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr + 5, ptr);
-
- int c = 34;
- consts.key = &c;
- ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr + 10, ptr);
-
- int d = 3;
- consts.key = &d;
- ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL_PTR(arr, ptr);
-
- int b = 123;
- consts.key = &b;
- ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL(12, nelp);
- TEST_ASSERT_EQUAL(123, arr[11]);
- TEST_ASSERT_EQUAL_PTR(arr + 11, ptr);
-
- ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL(12, nelp);
- TEST_ASSERT_EQUAL(123, arr[11]);
- TEST_ASSERT_EQUAL_PTR(arr + 11, ptr);
-
- int e = 1234;
- consts.key = &e;
- ptr = ft_lsearch(arr, &nelp, sizeof(int), &consts);
- TEST_ASSERT_EQUAL(13, nelp);
- TEST_ASSERT_EQUAL(1234, arr[12]);
- TEST_ASSERT_EQUAL_PTR(arr + 12, ptr);
-}
diff --git a/test/src/algo/test_ft_mergesort.c b/test/src/algo/test_ft_mergesort.c
deleted file mode 100644
index 567e31d..0000000
--- a/test/src/algo/test_ft_mergesort.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "libft_test.h"
-
-TEST_GROUP(ft_mergesort);
-
-TEST_SETUP(ft_mergesort)
-{}
-
-TEST_TEAR_DOWN(ft_mergesort)
-{}
-
-static int compar(const void *a, const void *b)
-{