aboutsummaryrefslogtreecommitdiff
path: root/test/src/ht/test_ft_htnew.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-31 10:44:30 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-02 22:12:42 +0100
commitac0559db82bfef3b7ca3d976b1d7700ed2c1c1fc (patch)
tree214d344c714bdf5b53d651dbd11fec9e0db283cb /test/src/ht/test_ft_htnew.c
parent9db52bc5ef545a3fa9973002e9a28a2ece68d029 (diff)
downloadlibft-ac0559db82bfef3b7ca3d976b1d7700ed2c1c1fc.tar.gz
libft-ac0559db82bfef3b7ca3d976b1d7700ed2c1c1fc.tar.bz2
libft-ac0559db82bfef3b7ca3d976b1d7700ed2c1c1fc.zip
hash table unit testing, norming
Diffstat (limited to 'test/src/ht/test_ft_htnew.c')
-rw-r--r--test/src/ht/test_ft_htnew.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/src/ht/test_ft_htnew.c b/test/src/ht/test_ft_htnew.c
new file mode 100644
index 0000000..2696e7f
--- /dev/null
+++ b/test/src/ht/test_ft_htnew.c
@@ -0,0 +1,38 @@
+#include "libft_test.h"
+
+
+TEST_GROUP(ft_htnew);
+
+TEST_SETUP(ft_htnew)
+{}
+
+TEST_TEAR_DOWN(ft_htnew)
+{}
+
+int helper_segfault_pid;
+
+TEST(ft_htnew, segfault)
+{
+ TEST_ASSERT_SEGFAULT(ft_htnew(10));
+ TEST_ASSERT_SEGFAULT(ft_htnew(0));
+ TEST_ASSERT_SEGFAULT(ft_htnew((1 << 14) + 1));
+}
+
+TEST(ft_htnew, error_null)
+{
+ TEST_ASSERT_NOT_NULL(ft_htnew(10)); // leak
+ TEST_ASSERT_NULL(ft_htnew(0));
+ TEST_ASSERT_NULL(ft_htnew((1 << 14) + 1));
+}
+
+TEST(ft_htnew, happy_path)
+{
+ t_ftht *ht;
+
+ ht = ft_htnew(10);
+ TEST_ASSERT_NOT_NULL(ht);
+ TEST_ASSERT_EQUAL(ht->size, 10);
+ TEST_ASSERT_NOT_NULL(ht->entries);
+ for (t_ftsize i = 0; i < ht->size; i++)
+ TEST_ASSERT_NULL(ht->entries[i]);
+}