aboutsummaryrefslogtreecommitdiff
path: root/test/src/ht/test_ft_htset.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-04-03 07:19:25 +0200
committerCharles <sircharlesaze@gmail.com>2020-04-03 07:19:25 +0200
commitd2feec1f97e9f8f201e56ad33662bb663c328a0a (patch)
treef97690082352bb1752d867d66f21a7bee1ef126c /test/src/ht/test_ft_htset.c
parent948c0953527fe3bef28904b38a16a9e4342e7e98 (diff)
downloadlibft-d2feec1f97e9f8f201e56ad33662bb663c328a0a.tar.gz
libft-d2feec1f97e9f8f201e56ad33662bb663c328a0a.tar.bz2
libft-d2feec1f97e9f8f201e56ad33662bb663c328a0a.zip
Changing hash table del function to regular one with a first order internal function, removing a few typedef to instead use standard types
Diffstat (limited to 'test/src/ht/test_ft_htset.c')
-rw-r--r--test/src/ht/test_ft_htset.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/test/src/ht/test_ft_htset.c b/test/src/ht/test_ft_htset.c
index 96d848e..70232fd 100644
--- a/test/src/ht/test_ft_htset.c
+++ b/test/src/ht/test_ft_htset.c
@@ -14,12 +14,6 @@ TEST_TEAR_DOWN(ft_htset)
/* ft_htdestroy_key(ht); */
}
-static void st_del(t_ftht_entry *c)
-{
- free(c->key);
- free(c);
-}
-
TEST(ft_htset, segfault)
{
TEST_ASSERT_SEGFAULT(ft_htset(NULL, "", strdup(""), NULL));
@@ -57,14 +51,14 @@ TEST(ft_htset, reset)
small = ft_htnew(3);
- t_ftht_entry *content = ft_htset(small, "bonjour", ft_strdup("content"), st_del);
+ t_ftht_entry *content = ft_htset(small, "bonjour", ft_strdup("content"), free);
TEST_ASSERT_NOT_NULL(content);
TEST_ASSERT_NOT_NULL(content->key);
TEST_ASSERT_NOT_NULL(content->value);
TEST_ASSERT_EQUAL_STRING(content->key, "bonjour");
TEST_ASSERT_EQUAL_STRING(content->value, "content");
- t_ftht_entry *content_re = ft_htset(small, "bonjour", ft_strdup("yo"), st_del);
+ t_ftht_entry *content_re = ft_htset(small, "bonjour", ft_strdup("yo"), free);
TEST_ASSERT_NOT_NULL(content_re);
TEST_ASSERT_NOT_NULL(content_re->key);
TEST_ASSERT_NOT_NULL(content_re->value);
@@ -77,21 +71,21 @@ TEST(ft_htset, collision)
t_ftht *small = NULL;
small = ft_htnew(1);
- t_ftht_entry *content1 = ft_htset(small, "bonjour", strdup("content1"), st_del);
+ t_ftht_entry *content1 = ft_htset(small, "bonjour", strdup("content1"), free);
TEST_ASSERT_NOT_NULL(content1);
TEST_ASSERT_NOT_NULL(content1->key);
TEST_ASSERT_NOT_NULL(content1->value);
TEST_ASSERT_EQUAL_STRING(content1->key, "bonjour");
TEST_ASSERT_EQUAL_STRING(content1->value, "content1");
- t_ftht_entry *content2 = ft_htset(small, "aurevoir", strdup("content2"), st_del);
+ t_ftht_entry *content2 = ft_htset(small, "aurevoir", strdup("content2"), free);
TEST_ASSERT_NOT_NULL(content2);
TEST_ASSERT_NOT_NULL(content2->key);
TEST_ASSERT_NOT_NULL(content2->value);
TEST_ASSERT_EQUAL_STRING(content2->key, "aurevoir");
TEST_ASSERT_EQUAL_STRING(content2->value, "content2");
- t_ftht_entry *content3 = ft_htset(small, "aloa", strdup("content3"), st_del);
+ t_ftht_entry *content3 = ft_htset(small, "aloa", strdup("content3"), free);
TEST_ASSERT_NOT_NULL(content3);
TEST_ASSERT_NOT_NULL(content3->key);
TEST_ASSERT_NOT_NULL(content3->value);