aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-30 10:36:49 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-30 10:36:49 +0100
commitaa9613efb6fb39bd96fc4836b5d38c3746af1b15 (patch)
tree0fac2b661a860b3ca2e3effa868384290064f708
parentfe37597119353ce183fc404417b81bd4702f64b7 (diff)
downloadlibft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.tar.gz
libft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.tar.bz2
libft-aa9613efb6fb39bd96fc4836b5d38c3746af1b15.zip
hash table draft
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml2
-rw-r--r--include/ft_lst.h5
-rw-r--r--include/ft_types.h3
-rw-r--r--include/libft_ht.h53
-rw-r--r--src/ht/ft_htcontent_new.c31
-rw-r--r--src/ht/ft_htdelone.c19
-rw-r--r--src/ht/ft_htdelone_key.c18
-rw-r--r--src/ht/ft_htdestroy.c23
-rw-r--r--src/ht/ft_htdestroy_all.c26
-rw-r--r--src/ht/ft_htdestroy_key.c25
-rw-r--r--src/ht/ft_htdestroy_value.c25
-rw-r--r--src/ht/ft_htget.c24
-rw-r--r--src/ht/ft_hthash.c26
-rw-r--r--src/ht/ft_htnew.c28
-rw-r--r--src/ht/ft_htset.c33
-rw-r--r--src/ht/ft_inter_htkey_equal.c20
-rw-r--r--src/lst/ft_lstbsearch.c56
-rw-r--r--src/lst/ft_lstremove_if.c32
-rw-r--r--src/str/ft_strcpy.c2
-rw-r--r--src/str/ft_strlen.c2
-rw-r--r--test/Makefile52
m---------test/ctest0
-rw-r--r--test/main_test.c7
-rw-r--r--test/str/ft_strlen_test.c34
-rw-r--r--test/test_libft.h9
26 files changed, 449 insertions, 107 deletions
diff --git a/.gitignore b/.gitignore
index c58fcb1..a406d47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ a.out
test_libft
main.c
build/*
+test/*
diff --git a/.travis.yml b/.travis.yml
index 07ce8a3..49462fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
language: c
compiler: gcc
-script: make && make test
+script: make all
diff --git a/include/ft_lst.h b/include/ft_lst.h
index 134df71..23fb192 100644
--- a/include/ft_lst.h
+++ b/include/ft_lst.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/17 09:58:02 by cacharle #+# #+# */
-/* Updated: 2020/01/17 09:58:45 by cacharle ### ########.fr */
+/* Updated: 2020/01/30 09:55:43 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -32,5 +32,8 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *),
void ft_lstpop_front(t_list **lst, void (*del)(void *));
t_list *ft_lstreverse_ret(t_list *lst);
void ft_lstreverse(t_list **lst);
+void ft_lstremove_if(t_list **lst,
+ t_ftbool (*equal)(void *ref, void *content), void *ref,
+ void (*del)(void *content));
#endif
diff --git a/include/ft_types.h b/include/ft_types.h
index 948e33d..b465382 100644
--- a/include/ft_types.h
+++ b/include/ft_types.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/17 09:59:15 by cacharle #+# #+# */
-/* Updated: 2020/01/17 10:16:14 by cacharle ### ########.fr */
+/* Updated: 2020/01/30 09:54:28 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
typedef unsigned char t_ftbyte;
typedef int t_ftbool;
+typedef unsigned int t_ftsize;
typedef char t_ftchar;
typedef unsigned char t_ftuchar;
diff --git a/include/libft_ht.h b/include/libft_ht.h
new file mode 100644
index 0000000..bd67b47
--- /dev/null
+++ b/include/libft_ht.h
@@ -0,0 +1,53 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_ht.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:19:23 by cacharle #+# #+# */
+/* Updated: 2020/01/30 10:34:40 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FT_HT
+# define FT_HT
+
+# include "libft.h"
+
+typedef struct
+{
+ char *key;
+ void *value;
+} t_ftht_content;
+
+typedef t_list* t_ftht_entry;
+
+typedef struct
+{
+ t_ftsize size;
+ t_ftht_entry *entries;
+} t_ftht;
+
+typedef t_ftuint t_ftht_digest;
+
+
+t_ftht *ft_htnew(t_ftsize size);
+void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*));
+void ft_htdestroy_all(t_ftht *ht);
+void ft_htdestroy_key(t_ftht *ht);
+void ft_htdestroy_value(t_ftht *ht);
+t_ftht_content *ft_htget(t_ftht *ht, char *key);
+t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value);
+void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*));
+void ft_htdelone_key(t_ftht *ht, char *key);
+t_ftht_content *ft_htcontent_new(char *key, void *value);
+
+/*
+** internals
+*/
+
+void ft_inter_htdelcontent_key(t_ftht_content *content);
+t_ftbool ft_inter_htkey_equal(char *ref_key, t_ftht_content *content);
+
+#endif
diff --git a/src/ht/ft_htcontent_new.c b/src/ht/ft_htcontent_new.c
new file mode 100644
index 0000000..4ffa9bf
--- /dev/null
+++ b/src/ht/ft_htcontent_new.c
@@ -0,0 +1,31 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htcontent_new.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:45:36 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:52:28 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include "libft_ht.h"
+
+t_ftht_content *ft_htcontent_new(char *key, void *value)
+{
+ t_ftht_content *content;
+
+ if (key == NULL)
+ return (NULL);
+ if ((content = (t_ftht_content*)malloc(sizeof(t_ftht_content))) == NULL)
+ return (NULL);
+ if ((content->key = ft_strdup(key)) == NULL)
+ {
+ free(content);
+ return (NULL);
+ }
+ content->value = value;
+ return (content);
+}
diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c
new file mode 100644
index 0000000..8d350ae
--- /dev/null
+++ b/src/ht/ft_htdelone.c
@@ -0,0 +1,19 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdelone.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:27:18 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:55:06 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include "libft_ht.h"
+
+void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*))
+{
+ ft_lstremove_if(ht->entries + ft_hthash(key), ft_iter_htkey_equal, key, del);
+}
diff --git a/src/ht/ft_htdelone_key.c b/src/ht/ft_htdelone_key.c
new file mode 100644
index 0000000..5dc0c16
--- /dev/null
+++ b/src/ht/ft_htdelone_key.c
@@ -0,0 +1,18 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdelone_key.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:45:11 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:46:42 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void ft_htdelone_key(t_ftht *ht, char *key)
+{
+ ft_htdelone(ht, key, ft_inter_htdelcontent_key);
+}
diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c
new file mode 100644
index 0000000..6e04386
--- /dev/null
+++ b/src/ht/ft_htdestroy.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdestroy.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:19:06 by cacharle #+# #+# */
+/* Updated: 2020/01/30 08:33:09 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*))
+{
+ if (ht == NULL)
+ return ;
+ while (ht->size-- > 0)
+ ft_lstclear(ht->entries + ht->size, del);
+ free(ht->entries);
+ free(ht);
+}
diff --git a/src/ht/ft_htdestroy_all.c b/src/ht/ft_htdestroy_all.c
new file mode 100644
index 0000000..761f577
--- /dev/null
+++ b/src/ht/ft_htdestroy_all.c
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdestroy_all.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:29:58 by cacharle #+# #+# */
+/* Updated: 2020/01/30 08:30:53 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static void st_htdelcontent_all(t_ftht_content *content)
+{
+ if (content == NULL)
+ return ;
+ free(content->key);
+ free(content->value);
+}
+
+void ft_htdestroy_all(t_ftht *ht)
+{
+ ft_htdestroy(ht, *st_dtdelcontent_all);
+}
diff --git a/src/ht/ft_htdestroy_key.c b/src/ht/ft_htdestroy_key.c
new file mode 100644
index 0000000..e3d562f
--- /dev/null
+++ b/src/ht/ft_htdestroy_key.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdestroy_key.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:31:02 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:46:14 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void ft_inter_htdelcontent_key(t_ftht_content *content)
+{
+ if (content == NULL)
+ return ;
+ free(content->key);
+}
+
+void ft_htdestroy_key(t_ftht *ht)
+{
+ ft_htdestroy(ht, *st_dtdelcontent_key);
+}
diff --git a/src/ht/ft_htdestroy_value.c b/src/ht/ft_htdestroy_value.c
new file mode 100644
index 0000000..b71b960
--- /dev/null
+++ b/src/ht/ft_htdestroy_value.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htdestroy_value.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:31:29 by cacharle #+# #+# */
+/* Updated: 2020/01/30 08:31:49 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static void st_htdelcontent_value(t_ftht_content *content)
+{
+ if (content == NULL)
+ return ;
+ free(content->value);
+}
+
+void ft_htdestroy_value(t_ftht *ht)
+{
+ ft_htdestroy(ht, *st_dtdelcontent_value);
+}
diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c
new file mode 100644
index 0000000..983fd74
--- /dev/null
+++ b/src/ht/ft_htget.c
@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htget.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:33:21 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:25:51 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_ftht_content *ft_htget(t_ftht *ht, char *key)
+{
+ t_ftht_digest digest;
+
+ if (ht == NULL || key == NULL)
+ return (NULL);
+ digest = ft_hthash(ht, key);
+ return (ft_lstbsearch(ht->entries[digest],
+ &ft_inter_htkey_equal, key)->content);
+}
diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c
new file mode 100644
index 0000000..66f8efb
--- /dev/null
+++ b/src/ht/ft_hthash.c
@@ -0,0 +1,26 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_hthash.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:56:01 by cacharle #+# #+# */
+/* Updated: 2020/01/30 10:34:27 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+t_ftht_digest ft_hthash(t_ftht *ht, char *key)
+{
+ t_ftht_digest digest;
+
+ if (*key == '\0')
+ return (0);
+ digest = *key++ << 7;
+ while (*key != '\0')
+ {
+ digest = ((1000003 * digest) ^ *key) & (1<<32);
+ key++;
+ }
+ return (digest);
+}
diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c
new file mode 100644
index 0000000..c3b7cc7
--- /dev/null
+++ b/src/ht/ft_htnew.c
@@ -0,0 +1,28 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htnew.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:19:16 by cacharle #+# #+# */
+/* Updated: 2020/01/30 08:19:18 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_ftht *ft_htnew(t_ftsize size)
+{
+ t_ftht *ht;
+
+ if ((ht = (t_ftht*)malloc(sizeof(t_ftht))) == NULL)
+ return (NULL);
+ if ((ht->entries = (t_ftht_entry*)ft_calloc(size, sizeof(t_ftht_entry))) == NULL)
+ {
+ free(ht);
+ return (NULL);
+ }
+ ht->size = size;
+ return (ht);
+}
diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c
new file mode 100644
index 0000000..32aa448
--- /dev/null
+++ b/src/ht/ft_htset.c
@@ -0,0 +1,33 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_htset.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 08:41:52 by cacharle #+# #+# */
+/* Updated: 2020/01/30 08:50:48 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value)
+{
+ t_ftht_digest digest;
+ t_ftht_content *content;
+ t_ftht_entry entry;
+
+ if (ht == NULL || key == NULL)
+ return (NULL)
+ if ((content = ft_htcontent_new(key, value)) == NULL)
+ return (NULL);
+ if ((entry = ft_lstnew(content)) = NULL)
+ {
+ free(content);
+ return (NULL);
+ }
+ digest = ft_hthash(ht, key);
+ ft_lstadd_front(ht->entries + digest, entry);
+ return (content);
+}
diff --git a/src/ht/ft_inter_htkey_equal.c b/src/ht/ft_inter_htkey_equal.c
new file mode 100644
index 0000000..b652bba
--- /dev/null
+++ b/src/ht/ft_inter_htkey_equal.c
@@ -0,0 +1,20 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_internal_htkey_equal.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:24:39 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:25:36 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+t_ftbool ft_inter_htkey_equal(char *ref_key, t_ftht_content *content)
+{
+ if (ref_key == NULL || content == NULL)
+ return (FALSE);
+ return (ft_strcmp(ref_key, content->key) == 0)
+}
diff --git a/src/lst/ft_lstbsearch.c b/src/lst/ft_lstbsearch.c
new file mode 100644
index 0000000..6af9cae
--- /dev/null
+++ b/src/lst/ft_lstbsearch.c
@@ -0,0 +1,56 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lstbsearch.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:17:51 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:17:53 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+static t_list *st_lstmiddle(t_list *lst, t_list)
+{
+ t_list *slow;
+ t_list *fast;
+
+ if (lst == NULL)
+ return (NULL);
+ slow = lst;
+ fast = lst;
+ while (fast != last)
+ {
+ fast = fast->next;
+ if (fast == NULL)
+ break;
+ slow = slow->next;
+ fast = fast->next;
+ }
+ return (slow);
+}
+
+static t_list *st_lstbsearch_rec(t_list *lst, t_list *last,
+ t_ftbool (*equal)(void *ref, void *content), void *ref)
+{
+ t_list *mid;
+ t_list *left;
+
+ if (lst == NULL)
+ return (NULL);
+ if ((*equal)(lst->content))
+ return (lst);
+ mid = st_lstmiddle(lst, last);
+ left = ft_lstbsearch_rec(lst->next, mid, equal));
+ if (left != NULL)
+ return (left);
+ return (ft_lstbsearch_rec(mid, NULL, equal));
+}
+
+t_list *ft_lstbsearch(t_list *lst,
+ t_ftbool (*equal)(void *ref, void *content), void *ref)
+{
+ return (ft_lstbsearch_rec(lst, NULL, equal));
+}
diff --git a/src/lst/ft_lstremove_if.c b/src/lst/ft_lstremove_if.c
new file mode 100644
index 0000000..2fa06a3
--- /dev/null
+++ b/src/lst/ft_lstremove_if.c
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lstremove_if.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/30 09:36:49 by cacharle #+# #+# */
+/* Updated: 2020/01/30 09:55:47 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+
+void ft_lstremove_if(t_list **lst,
+ t_ftbool (*equal)(void *ref, void *content), void *ref,
+ void (*del)(void *content))
+{
+ t_list *saved_next;
+
+ if (lst == NULL || *lst == NULL)
+ return ;
+ if (!equal(ref, &(*lst)->val))
+ {
+ ft_lstremove_if(&(*lst)->next, equal, ref, del);
+ return ;
+ }
+ saved_next = (*lst)->next;
+ ft_lstdelone(*lst, del);
+ *lst = saved_next;
+ ref_ft_list_remove_if(lst, equal, ref, del);
+}
diff --git a/src/str/ft_strcpy.c b/src/str/ft_strcpy.c
index 9677b24..ee6ff0d 100644
--- a/src/str/ft_strcpy.c
+++ b/src/str/ft_strcpy.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:38:36 by cacharle #+# #+# */
-/* Updated: 2019/11/20 23:25:57 by cacharle ### ########.fr */
+/* Updated: 2020/01/17 11:36:19 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/str/ft_strlen.c b/src/str/ft_strlen.c
index 0e0a47c..0d593e1 100644
--- a/src/str/ft_strlen.c
+++ b/src/str/ft_strlen.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:32:48 by cacharle #+# #+# */
-/* Updated: 2019/11/21 01:45:42 by cacharle ### ########.fr */
+/* Updated: 2020/01/17 11:13:43 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 3f31059..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-MAKE_ARGS = --no-print-directory
-
-NAME = test_libft
-
-BUILD_DIR = build
-LIBFT_DIR = ..
-CTEST_DIR = ctest
-
-CC = gcc
-CCFLAGS = -Wall -Wextra -I$(LIBFT_DIR)/include -I$(CTEST_DIR)
-LDFLAGS = -L$(LIBFT_DIR) -lft
-
-HEADER = $(shell find . -name "*.h")
-SRC = $(shell find . -name "*_test.c")
-SRC += $(shell find $(CTEST_DIR) -name "*.c")
-OBJ = $(SRC:%.c=$(BUILD_DIR)/%.o)
-
-all: make_build_dirs $(NAME)
-
-run_raw: all
- @./$(NAME)
-
-make_build_dirs:
- @for dir in $$(find . -not -path "*build*" -type d | sed 's/.*/$(BUILD_DIR)\/&/'); \
- do \
- if [ ! -d "$$dir" ]; then \
- mkdir -p $$dir; echo "Making build dir: $$dir"; fi \
- done
-
-$(NAME): $(OBJ) libft_all
- @echo "Test: Linking $@"
- @$(CC) -o $@ $(OBJ) $(LDFLAGS)
-
-$(BUILD_DIR)/%.o: %.c $(HEADER)
- @echo "Test: Compiling: $@"
- @$(CC) $(CCFLAGS) -c -o $@ $<
-
-clean:
- @echo "Test: Removing objects"
- @$(RM) -r $(BUILD_DIR)
-
-fclean: clean
- @echo "Test: Removing library"
- @$(RM) $(NAME)
- @echo "Test: Removing libft"
- @$(MAKE) $(MAKE_ARGS) -C $(LIBFT_DIR) fclean
-
-re: fclean all
-
-libft_all:
- @echo "Test: Making libft"
- @$(MAKE) $(MAKE_ARGS) -C $(LIBFT_DIR) all
diff --git a/test/ctest b/test/ctest
deleted file mode 160000
-Subproject ab5906865fab359cbb0a814ef3863bbc1fe5f10
diff --git a/test/main_test.c b/test/main_test.c
deleted file mode 100644
index 6b74ac4..0000000
--- a/test/main_test.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "test_libft.h"
-
-int main(void)
-{
- TEST_CALL(ft_strlen);
- return 0;
-}
diff --git a/test/str/ft_strlen_test.c b/test/str/ft_strlen_test.c
deleted file mode 100644
index 1c444ba..0000000
--- a/test/str/ft_strlen_test.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <string.h>
-#include "libft.h"
-#include "ctest.h"
-
-TEST_SEGV_FUNC(ft_strlen, char *str)
-{
- ft_strlen(str);
-}
-TEST_SEGV_FUNC_END
-
-ASSERT_FUNC1(ft_strlen, char*, str)
-{
- return ft_strlen(str) == strlen(str);
-}
-ASSERT_FUNC1_END
-
-ASSERT_PRINT_ARG_FUNC1(ft_strlen, char*, str)
-{
- printf("(str: \"%.30s", str);
- if (strlen(str) > 30)
- fputs("...", stdout);
- fputs("\")", stdout);
-}
-ASSERT_PRINT_ARG_FUNC1_END
-
-
-TEST(ft_strlen)
-{
- ASSERT(ft_strlen, CTEST_DEF_EMPTY);
- ASSERT(ft_strlen, CTEST_DEF_HELLO);
- ASSERT(ft_strlen, CTEST_DEF_HIDDEN);
- ASSERT(ft_strlen, CTEST_DEF_FORMAT);
- ASSERT(ft_strlen, CTEST_DEF_LOREM_IPSUM);
-}
diff --git a/test/test_libft.h b/test/test_libft.h
deleted file mode 100644
index aa23e54..0000000
--- a/test/test_libft.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef TEST_LIBFT_H
-# define TEST_LIBFT_H
-
-# include "ctest.h"
-# include "libft.h"
-
-TEST(ft_strlen);
-
-#endif